catalyst.passes.ppm_specs¶
- ppm_specs(fn, only_disjoint_qubit: bool = False)[source]¶
This function returns following Pauli product rotation (PPR) and Pauli product measurement (PPM) specs in a dictionary:
Pi/4 PPR (count the number of clifford PPRs)
Pi/8 PPR (count the number of non-clifford PPRs)
Pi/2 PPR (count the number of classical PPRs)
Max weight for pi/8 PPRs
Max weight for pi/4 PPRs
Max weight for pi/2 PPRs
Number of logical qubits
Number of PPMs
depth: number of PBC layersdepth_type:0if commuting ops on overlapping qubits may share a layer;1if only ops with disjoint qubit support may share a layer
Note
It is recommended to use
pennylane.specs()instead ofppm_specsto retrieve resource counts of PPR-PPM workflows.When there is control flow, this function can count the above statistics inside for loops with a statically known number of iterations. For all other cases, including dynamically sized for loops, and any conditionals and while loops, this pass exits with failure.
- Parameters:
fn (QJIT) – qjit-decorated function for which
ppm_specsneed to be printed.only_disjoint_qubit (bool) – If
True, depth is computed using disjoint-qubit layering (depth_type1). IfFalse(default), commuting ops on overlapping qubits may share a layer (depth_type0). Passed to theppm-specsMLIR pass asdisjoint-qubit.
- Returns:
A Python dictionary containing PPM specs of all functions in
fn.- Return type:
dict
Example
import pennylane as qp import catalyst from catalyst.passes import ppm_specs, to_ppr @qp.qjit(target="mlir") @to_ppr @qp.qnode(qp.device("lightning.qubit", wires=2)) def f(): qp.H(0) qp.S(1) qp.T(0) qp.CNOT(wires=[0, 1]) return qp.expval(qp.Z(0)) print(ppm_specs(f)) print(ppm_specs(f, only_disjoint_qubit=True))
Example output:
{'f_0': {'depth': 4, 'depth_type': 0, 'logical_qubits': 2, 'max_weight_pi4': 2, 'max_weight_pi8': 1, 'pi4_ppr': 7, 'pi8_ppr': 1}} {'f_0': {'depth': 7, 'depth_type': 1, 'logical_qubits': 2, 'max_weight_pi4': 2, 'max_weight_pi8': 1, 'pi4_ppr': 7, 'pi8_ppr': 1}}