Fixed commutation checking between two Pauli product measurements (backport #16023)#16040
Conversation
…6023) * Fix commutation checking between two PPMs * fix for the case qubits are different * additional fixes and improvements following the review * improve test formatting * formatting (again) (cherry picked from commit 89ff976) # Conflicts: # crates/transpiler/src/commutation_checker.rs # test/python/circuit/test_commutation_checker.py
|
Cherry-pick of 89ff976 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
Coverage Report for CI Build 24451488591Coverage increased (+0.01%) to 87.606%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions11 previously-covered lines in 3 files lost coverage.
Coverage Stats
💛 - Coveralls |
Summary
We have recently realized that checking commutativity between two
PauliProductMeasurementinstructions (introduced in #15359) is incorrect in the case that both measurements measure to the same classical bit. In this case, the later measurement overwrites the result of the earlier measurement, and thus the order of these instructions in the quantum circuit matters. This PR applies a simple fix of saying that two Pauli product measurement instruction do not commute unless they are completely identical (including pauli, qubits and clbits).(Updated) This also handles "canonicalization":
PPM(XZ, qubits=[0,1], clbits=[0])is the same asPPM(ZX, qubits=[1,0], clbits=[0]), and so they are now also computed to commute.Note: the current strategy of constructing sparse observable is in the spirit of the existing code, and I am trying to do minimal changes in order to backport a variant of this to 2.4. I have a followup PR #15815 that greatly increases the efficiency of commuting PPRs/PPMs among themselves (including canonicalization, but temporarily having the same problems as being fixed here).
This also updates commutativity checking tests to pass clbits when checking commutativity between two PPMs.
One other question: do we want to backport the fix to 2.4? If so, we would need to adjust this PR to the commutation checker version before #15488.
AI/LLM disclosure
This is an automatic backport of pull request #16023 done by [Mergify](https://mergify.com).