Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Peephole' optimization - or: collecting and optimizing two-qubit blocks - before routing #12727

Merged
merged 51 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9965ce3
init
sbrandhsn Jul 5, 2024
f3af45a
Merge branch 'Qiskit:main' into peephole-opt
sbrandhsn Jul 5, 2024
c650503
up
sbrandhsn Jul 5, 2024
092257c
up
sbrandhsn Jul 5, 2024
3befb83
Update builtin_plugins.py
sbrandhsn Jul 8, 2024
a8c5b8c
Update builtin_plugins.py
sbrandhsn Jul 8, 2024
90e725c
reno
sbrandhsn Jul 8, 2024
fd988e3
Update builtin_plugins.py
sbrandhsn Jul 8, 2024
e765285
Update builtin_plugins.py
sbrandhsn Jul 8, 2024
1805cb8
Update peephole-before-routing-c3d184b740bb7a8b.yaml
sbrandhsn Jul 8, 2024
bce3fcd
neko check
sbrandhsn Jul 8, 2024
e6f0b39
check neko
sbrandhsn Jul 8, 2024
6f7445c
Update builtin_plugins.py
sbrandhsn Jul 8, 2024
d3a45e7
test neko
sbrandhsn Jul 8, 2024
dec91de
Update builtin_plugins.py
sbrandhsn Jul 8, 2024
45912f8
Update builtin_plugins.py
sbrandhsn Jul 8, 2024
5404822
Update builtin_plugins.py
sbrandhsn Jul 8, 2024
ed790c1
lint
sbrandhsn Jul 8, 2024
1236cd6
tests and format
sbrandhsn Jul 8, 2024
db8aa2d
remove FakeTorino test
sbrandhsn Jul 8, 2024
3e28ec6
Update peephole-before-routing-c3d184b740bb7a8b.yaml
sbrandhsn Jul 9, 2024
d064c66
Apply suggestions from code review
sbrandhsn Jul 12, 2024
b88e3f0
comments from code review
sbrandhsn Jul 12, 2024
a655001
fix precision
sbrandhsn Jul 16, 2024
8aa570d
up
sbrandhsn Jul 26, 2024
c84fa16
up
sbrandhsn Jul 26, 2024
b8fea91
update
sbrandhsn Jul 26, 2024
6137daa
up
sbrandhsn Jul 26, 2024
a6ea05b
.
sbrandhsn Jul 26, 2024
c6f4530
cyclic import
sbrandhsn Jul 28, 2024
6ec02fc
cycl import
sbrandhsn Jul 29, 2024
44f2f38
cyl import
sbrandhsn Jul 29, 2024
22bb156
Merge branch 'main' into peephole-opt
sbrandhsn Jul 29, 2024
df0897f
.
sbrandhsn Jul 29, 2024
66d0a22
circular import
sbrandhsn Jul 29, 2024
e2074b6
Merge branch 'main' into peephole-opt
sbrandhsn Jul 29, 2024
aff157b
.
sbrandhsn Jul 29, 2024
c333f5b
lint
sbrandhsn Jul 30, 2024
1bdf860
Include new pass in docs
mtreinish Jul 31, 2024
a28a564
Fix Split2QUnitaries dag manipulation
mtreinish Jul 31, 2024
6eaed5d
Update releasenotes/notes/peephole-before-routing-c3d184b740bb7a8b.yaml
mtreinish Jul 31, 2024
254ea38
Merge branch 'main' into peephole-opt
mtreinish Jul 31, 2024
9964d65
stricter check for doing split2q
sbrandhsn Aug 1, 2024
b90f9f6
Update qiskit/transpiler/preset_passmanagers/builtin_plugins.py
sbrandhsn Aug 1, 2024
a7d3594
code review
sbrandhsn Aug 1, 2024
89ac7dc
Update qiskit/transpiler/passes/optimization/split_2q_unitaries.py
sbrandhsn Aug 1, 2024
229b028
new tests
sbrandhsn Aug 1, 2024
d8fba88
Merge branch 'peephole-opt' of https://github.com/sbrandhsn/qiskit in…
sbrandhsn Aug 1, 2024
48eacd7
typo
sbrandhsn Aug 1, 2024
edde611
lint
sbrandhsn Aug 1, 2024
5404bbc
lint
sbrandhsn Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def run(self, dag: DAGCircuit):
decomp._inner_decomposition.specialization
== TwoQubitWeylDecomposition._specializations.SWAPEquiv
):
# TODO also look at swap-gate-like gates?
# TODO maybe also look into swap-gate-like gates? Things to consider:
# * As the qubit mapping may change, we'll always need to build a new dag in this pass
# * There may not be many swap-gate-like gates in an arbitrary input circuit
# * Removing swap gates from a user-routed input circuit here is unexpected
pass
return dag
21 changes: 14 additions & 7 deletions qiskit/transpiler/preset_passmanagers/builtin_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@

CONFIG = user_config.get_config()

_discrete_skipped_ops = {"delay", "reset", "measure"}
_discrete_skipped_ops = {
"delay",
"reset",
"measure",
"switch_case",
"if_else",
"for_loop",
"while_loop",
}


class DefaultInitPassManager(PassManagerStagePlugin):
Expand Down Expand Up @@ -181,11 +189,10 @@ def _is_one_op_non_discrete(ops):
if isinstance(op, str):
op = stdgates.get(op, None)

if (
op is None
or not isinstance(op, Instruction)
or op.name in _discrete_skipped_ops
):
if op is None or not isinstance(op, Instruction):
return False

if op.name in _discrete_skipped_ops:
continue

if len(op.params) > 0:
Expand All @@ -207,7 +214,7 @@ def _is_one_op_non_discrete(ops):
if do_consolidate_blocks_init:
init.append(Collect2qBlocks())
init.append(ConsolidateBlocks())
init.append(Split2QUnitaries())
init.append(Split2QUnitaries(pass_manager_config.approximation_degree))
sbrandhsn marked this conversation as resolved.
Show resolved Hide resolved
else:
raise TranspilerError(f"Invalid optimization level {optimization_level}")
return init
Expand Down
Loading