Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
bef6aa79
Commit
bef6aa79
authored
Oct 23, 2020
by
Nguyen, Thien Minh
Browse files
Fixed gate merge optimization when there are nested composites
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
28e0c7a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
quantum/plugins/optimizers/gate_merge/GateMergeOptimizer.cpp
View file @
bef6aa79
...
...
@@ -49,12 +49,28 @@ bool compareMatIgnoreGlobalPhase(const Eigen::Matrix4cd& in_a, const Eigen::Matr
const
auto
diff
=
(
bFixedPhase
-
in_a
).
norm
();
return
std
::
abs
(
diff
)
<
TOL
;
}
void
flattenComposite
(
std
::
shared_ptr
<
CompositeInstruction
>
io_composite
)
{
std
::
vector
<
xacc
::
InstPtr
>
flatten
;
InstructionIterator
iter
(
io_composite
);
while
(
iter
.
hasNext
())
{
auto
inst
=
iter
.
next
();
if
(
!
inst
->
isComposite
())
{
flatten
.
emplace_back
(
inst
->
clone
());
}
}
io_composite
->
clear
();
io_composite
->
addInstructions
(
flatten
);
}
}
namespace
xacc
{
namespace
quantum
{
void
MergeSingleQubitGatesOptimizer
::
apply
(
std
::
shared_ptr
<
CompositeInstruction
>
program
,
const
std
::
shared_ptr
<
Accelerator
>
accelerator
,
const
HeterogeneousMap
&
options
)
{
auto
gateRegistry
=
xacc
::
getService
<
xacc
::
IRProvider
>
(
"quantum"
);
flattenComposite
(
program
);
for
(
size_t
instIdx
=
0
;
instIdx
<
program
->
nInstructions
();
++
instIdx
)
{
const
auto
sequence
=
findSingleQubitGateSequence
(
program
,
instIdx
,
2
);
...
...
@@ -173,7 +189,7 @@ std::vector<size_t> MergeSingleQubitGatesOptimizer::findSingleQubitGateSequence(
void
MergeTwoQubitBlockOptimizer
::
apply
(
std
::
shared_ptr
<
CompositeInstruction
>
program
,
const
std
::
shared_ptr
<
Accelerator
>
accelerator
,
const
HeterogeneousMap
&
options
)
{
auto
gateRegistry
=
xacc
::
getService
<
xacc
::
IRProvider
>
(
"quantum"
);
flattenComposite
(
program
);
// No need to optimize block with less than 6 gates
// since the KAK decomposition will result in at least 5 gate.
const
size_t
MIN_SIZE
=
6
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment