Closed christian512 closed 2 days ago
Thanks for raising this issue. This is definetly something we should address.
Maybe just emitting a warning saying that the circuit contains implcit permutations is the best way to tackle this. Any thoughts @cqc-alec ?
Note that there is also a replace_implicit_swaps
argument to tk_to_qiskit
that implements the implicit permutation using swaps. But yes, I think emitting a warning if this is omitted (or False
) and the circuit has a non-trivial implicit permutation is a good idea.
Adding this warning actually had an unintended consequence that I should've anticipated. Namely that the different backends in pytket-qiskit use the tk_to_qiskit
function on circuits that have implcit swaps introduced by passes in optimisation level=2.
The statevector and unitary backends handle these swaps in postprocessing so the results are still correct. This does however spam the user with unhelpful warning messgaes which they are not able to address directly.
We could make the backends handle this by adding swap gates but adding additonal gates would not be desirable for backends with quantum noise.
GIven the above, I'm thinking I'll revert #412 for now. Maybe we should just add a note in the docs for this.
What about an option to deactivate the warnings?
The backends could use tk_to_qiskit(..., warn=False)
where warn
is an optional parameter that defaults to True
.
What about an option to deactivate the warnings?
The backends could use
tk_to_qiskit(..., warn=False)
wherewarn
is an optional parameter that defaults toTrue
.
I did think this as an option too. Could be worth doing and I think it should work to give the warnings where we want them.
I'll add the warning back in with the flag. Should be quick.
If a
Circuit
object containsimplicit_permutations
the conversion usingtk_to_qiskit
ignores these permutations leading to an inequivalent circuit (see example below).I would suggest to (at least) raise a warning that the conversion function is called on a circuit containing implicit permutations.