-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Inefficient 1Q sequences in -O3 #6677
Comments
I like the proposed solution of an analysis pass to detect for gates outside the basis and condition running the basis translation passes on that. We only added the |
I'd like to work on this! |
Can someone supply something like a MWE? @irajput passed me the following example. After the first pair of passes from qiskit.circuit.library import QuantumVolume
from qiskit import *
from qiskit.test.mock import FakeBelem
qcomp = FakeBelem()
qv_circuit=QuantumVolume(3)
qv_circuit.draw()
from IPython.display import display
from qiskit.converters import dag_to_circuit
from qiskit.transpiler import TransformationPass
def callback_func(pass_,dag, time, property_set, count):
if True:
# if isinstance (pass_, TransformationPass):
circuit = dag_to_circuit(dag)
print(pass_.name())
display(circuit.draw(output='mpl'))
transpile(qv_circuit,backend=qcomp, optimization_level=3,callback=callback_func,translation_method='synthesis').draw(output='mpl') EDIT: I have checked out terra v0.17 here. |
Information
What is the current behavior?
synthesis(..., optimization_level=3, translation_method='synthesis')
emits programs with inefficient 1Q subsequences.Steps to reproduce the problem
Supply any sufficiently complex circuit (e.g., a quantum volume circuit) to the synthesis routine with optimization level turned up.
What is the expected behavior?
Each 1Q subsequence should be efficient, e.g., should apply
sx
no more than twice.Suggested solutions
The
_unroll
set of passes (UnitarySynthesis
specifically) is un-doing some of the work of_opt
(Optimize1qDecompose
specifically). I think what’s happening is:ConsolidateBlocks
produces operation strings likeu q[0] q[1]; v q[1] q[2];
, whereu
andv
are opaque two-qubit unitaries.UnitarySynthesis
subsequently throws single-qubit sequences ontoq[1]
afteru
and beforev
.For an 8x8 quantum volume circuit, this pushes the depth up from ~340 to ~400 — a significant effect.
Omitting
_unroll
entirely works fine for QV circuits targeting IBM devices, but the purpose of_unroll
was to re-nativize any non-native output that_opt
may have emitted. So long as we're concerned about that, we'll have to install a more delicate fix. For instance, we might run an analysis pass which checks for instructions outside ofbasis_gates
, and only apply_unroll
if any are found — though I'm not sure that this is sufficient logic.The text was updated successfully, but these errors were encountered: