qml.transforms.zx.reduce_non_clifford¶
- reduce_non_clifford(tape)[source]¶
Reduce the number of non-Clifford gates by applying a combination of phase gadgetization strategies and Clifford gate simplification rules.
This transform performs the following simplification/optimization steps:
Apply the full_reduce simplification pipeline to the
pyzx
graph representation (seeto_zx()
) of the given input circuit.Use the extract_circuit function to extract the equivalent sequence of gates and build a new optimized circuit.
Apply the basic_optimization pass to further optimize the phase-polynomial blocks in the circuit.
This pipeline does not run the Third Order Duplicate and Destroy (TODD) algorithm and thus is not restricted to Clifford + T circuits.
Note
The transformed output circuit is equivalent to the input up to a global phase.
- Parameters:
tape (QNode or QuantumScript or Callable) – the input circuit to be transformed.
- Returns:
the transformed circuit as described in
qml.transform
.- Return type:
qnode (QNode) or quantum function (Callable) or tuple[List[QuantumScript], function]
- Raises:
ModuleNotFoundError – if the required
pyzx
package is not installed.
Example:
import pennylane as qml import pennylane.transforms.zx as zx dev = qml.device("default.qubit") @zx.reduce_non_clifford @qml.qnode(dev) def circuit(x, y): qml.T(0) qml.Hadamard(0) qml.Hadamard(0) qml.CNOT([0, 1]) qml.T(0) qml.RX(x, 1) qml.RX(y, 1) return qml.state()
>>> print(qml.draw(circuit)(3.2, -2.2)) 0: ──S─╭●─────────────────┤ State 1: ────╰X──H──RZ(1.00)──H─┤ State
Note
This transform is designed to minimize non-Clifford phase gates (e.g.
T
,RZ
), and is not as effective at reducing the number of two-qubit gates (e.g.CNOT
). For example, you might see a substantial increase in CNOT gates when optimizing a circuit composed primarily of Toffoli gates. Conversely, it tends to perform quite well on Trotterized chemistry circuits.For more details about ZX calculus-based simplification of quantum circuits, see the following papers:
Ross Duncan, Aleks Kissinger, Simon Perdrix, John van de Wetering (2019), “Graph-theoretic Simplification of Quantum Circuits with the ZX-calculus”, arXiv:1902.03178;
Aleks Kissinger, John van de Wetering (2020), “Reducing T-count with the ZX-calculus”, arXiv:1903.10477.