-
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
Commutation Checker with PauliGate #13570
Comments
Thanks Marc, this issue affects me too. In trying to find a workaround for this issue, I believe I uncovered another, somewhat related bug in CommutationChecker. The attempted workaround was to convert the PauliGate to an equivalent PauliEvolutionGate before passing it to the CommutationChecker. I'm not familiar with where PauliEvolutionGate stores the Pauli definition, but it's not in the list of parameters, and at first it looked like the commutation checker was processing the instruction correctly. The problem is that two distinct PauliEvolutionGate objects can have seemingly identical Instructions, and the CommutationChecker's caching does not distinguish between them. For example:
If we print these, we see the instructions appear superficially identical:
CommutationChecker will correctly say that Reproducer:
Output:
So when fixing the hashing for |
Thanks for the reports! Indeed for the For the |
@aeddins-ibm: you're actually pointing at something worse -- the commutation checker will try caching a gate it does not know and only use what's inside We should probably update the commutation checker to use a cache whitelist (i.e. only our standard gates, where we know the definition is only affected by |
Environment
What is happening?
The commutation checker always fails to commute a PauliGate with any other gate. I get this error message.
I think it is because the parameter in a
PauliGate
is thePauli
operator that it implements rather than aParameter
or afloat
. I realized thatCommutatorChecker
did not have a unittest for this particular case, and also I have tried it for different python versions 1.0, 1.2 and 1.3. 1.0 and 1.2 work fine but 1.3 does not.2 things have changed.
PauliGate
is a string so I don't see why we can't hash it).commute
would returnFalse
. Now it does some more invoved logic.How can we reproduce the issue?
What should happen?
For versions up to 1.2 we get
False
(which is not the correct answer). And for version 1.3 we get the error message.Any suggestions?
I think the best option would be to fix the hashing. If there is a deeper reason why that is not possible then we need to change the logic of the function.
The text was updated successfully, but these errors were encountered: