catalyst.passes.t_layer_reduction¶
- t_layer_reduction(qnode)[source]¶
Specify that the``–t-layer-reduction`` MLIR compiler pass, which reduces the depth and count of non-Clifford PPRs by commuting adjacent PPRs and merging compatible ones. For details, see the Figure 6 of [A Game of Surface Code](https://arXiv:1808.02892v3) paper.
A layer is a set of PPRs that mutually commute or act on disjoint qubits.
- Parameters:
fn (QNode) – QNode to apply the pass to.
- Returns:
Returns decorated QNode.
- Return type:
QNode
Example
In example below, after performing the to_ppr to merge_ppr_ppm passes, the circuit contains a four depth of Non-Clifford PPRs. The t_layer_reduction pass move the PPR(“X”) on qubit Q1 to first layer, which results in a three depth of Non-Clifford PPRs.
In the example below, after applying the to_ppr, commute_ppr, and merge_ppr_ppm passes, the circuit has four layers of non-Clifford PPRs. The t_layer_reduction pass moves the PPR(“X”) on qubit 1 into the first layer, reducing the non-Clifford depth from four to three.
import pennylane as qml from catalyst import qjit, measure from catalyst.passes import to_ppr, commute_ppr, t_layer_reduction, merge_ppr_ppm pips = [("pipe", ["enforce-runtime-invariants-pipeline"])] @qjit(pipelines=pips, target="mlir") @t_layer_reduction @merge_ppr_ppm @commute_ppr @to_ppr @qml.qnode(qml.device("null.qubit", wires=3)) def circuit(): n = 3 for i in range(n): qml.H(wires=i) qml.S(wires=i) qml.CNOT(wires=[i, (i + 1) % n]) qml.T(wires=i) qml.H(wires=i) qml.T(wires=i) return [measure(wires=i) for i in range(n)] print(circuit.mlir_opt)
Example MLIR Representation: