-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Optimization level 3 in transpile gives the wrong circuit when increasing the depth #7341
Comments
Yes. Optimization level 3 gives (for 15 steps):
where as 2 gives something much longer, a small snippet of which is:
|
It is independent of the routing method, so something else is breaking. |
Do we know yet if this is due to changes in |
Here is the raw circuit used above: |
def cb(pass_, dag, **kwargs):
print(type(pass_).__name__, dag.count_ops())
qct3 = transpile(qc, backend, initial_layout=layout, optimization_level=3, callback=cb) Going from 268
|
I think the problem here is the basic interaction of small-step Trotterization (which makes the interaction-per-step become small) with approximate unitary synthesis (which avoids emitting 2q gates when the interaction becomes small enough). The solution is to use fewer Trotter steps or to turn off approximate synthesis. |
It appears that this happens only with the default |
QiskitGH-6581 introduced a behavior of setting the basis_fidelity used by decomposer2q from the reported device gate_error of the corresponding 2q gate. QiskitGH-7341 reported a case where this approximation removed small but significant interactions resulting in an non-equivalent output circuit. As a workaround, revert to the prior behavior of using decomposer2q's default basis_fidelity (1, no approximation).
#7348 takes the approach of disabling approximate synthesis entirely Thinking about this a bit more though, could it be the case that this is a sound optimization to make (in the interest of best approximating the given unitary with the available device gate fidelities), even though when simulating (on an ideal simulator) you'll end up quite far from the intended operation? |
This is the intention, that you do the best you can given available gate fidelities. It may end up far from the intended, but better than not approximating. Of course the decision is heuristic and local, so may not always succeed - something like trotterization where the repeated trotter steps are intended to add coherently would be an example where the heuristic based on assuming a depolarizing channel of equivalent infidelity might choose poorly. |
In that case, I'd lean toward the transpiler behavior being not a bug. It may be a bug though that users can compile based on a set of |
As an user I am actually surprised that this was enabled by default. To me at least, it seems to be implicitly breaking the idea that the transpiler faithfully performs the unitary in question (up to certain permutations, transformations etc.). To me this feels akin to the I think approximations like this should be explicit, and turned on by the user with knowledge that bad things can some times happen. |
I agree with @nonhermitian. Personally, I would not expect that the circuit returned is an approximation and would prefer to explicitly activate an option to approximate the unitary given the hardware characteristics. |
Since #8595 has merged I think this has been implemented so I'm going to close this. If I'm missing something here though or misinterpreting what was needed for this issue please feel free to reopen this. |
Environment
What is happening?
Using
optimization_level=3
within thetranspile
method yields a circuit with different outcomes that the one produced either from settingoptimization_level=2
or evaluating the non transpiled circuit withStatevector
.The wrong behaviour was observed while increasing the number of trotter steps in a Trotterization time evolution, and the circuits obtained from
optimization_level=3
perform as expected as long as the original circuit remains relatively shallow (see plots below).How can we reproduce the issue?
Output:
![issue_qiskit](https://user-images.githubusercontent.com/5624856/144403132-a24fb242-d87e-4478-9f32-2174d5ff8309.png)
What should happen?
In the output plots the line for
optimization_level=3
should coincide with thestatevector
andoptimization_level=2
lines.Any suggestions?
No response
The text was updated successfully, but these errors were encountered: