qiskit/releasenotes/notes/1.0/commutative-inv-cancellatio...

28 lines
1.3 KiB
YAML

---
features_transpiler:
- |
Added two new arguments, ``matrix_based`` and ``max_qubits``, to the
constructor of the :class:`.CommutativeInverseCancellation` transpiler pass.
When ``matrix_based`` is ``True``, the pass uses matrix representations to
check whether two operations are the inverse of each other. This makes the
checks more powerful, and in addition allows for cancelling pairs of operations
that are inverse up to a phase, while updating the global phase of the circuit
accordingly. This generally leads to more reductions at the expense of increased
runtime. The argument ``max_qubits`` limits the number of qubits in matrix-based
commutativity and inverse checks. For example::
import numpy as np
from qiskit.circuit import QuantumCircuit
from qiskit.transpiler import PassManager
from qiskit.transpiler.passes import CommutativeInverseCancellation
circuit = QuantumCircuit(1)
circuit.rz(np.pi / 4, 0)
circuit.p(-np.pi / 4, 0)
passmanager = PassManager(CommutativeInverseCancellation(matrix_based=True))
new_circuit = passmanager.run(circuit)
The pass is able to cancel the ``RZ`` and ``P`` gates, while adjusting the circuit's global
phase to :math:`\frac{15 \pi}{8}`.