Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.28k stars 2.37k forks source link

Oxidize commutation cancellation #13072

Closed sbrandhsn closed 2 months ago

sbrandhsn commented 2 months ago

Summary

fixes #12270

Details and comments

This is almost done but requires some discussion around how to handle global phases. The Python implementation of CommutativeCancellation sets the global phase of the DAGCircuit depending on the cancelled commutations without considering the previous global phase of the DAGCircuit:

https://github.com/Qiskit/qiskit/blob/f4ca088644b4461b856b4b49c33e23b04a995019/qiskit/transpiler/passes/optimization/commutative_cancellation.py#L195

I think this line should instead be: dag.global_phase += total_phase - new_op_phase I changed the tests accordingly in this PR. This PR depends on #12995 and #12870.

The following is still missing:

qiskit-bot commented 2 months ago

One or more of the following people are relevant to this code: