catalyst.passes.ppm_specs¶
- ppm_specs(fn)[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
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.- Returns:
A Python dictionary containing PPM specs of all functions in
fn.- Return type:
dict
Example
import pennylane as qml import catalyst p = [("my_pipe", ["quantum-compilation-stage"])] device = qml.device("lightning.qubit", wires=2) @qml.qjit(pipelines=p, target="mlir") @catalyst.passes.ppm_compilation @qml.qnode(device) def circuit(): qml.H(0) qml.CNOT([0,1]) @catalyst.for_loop(0,10,1) def loop(i): qml.T(1) loop() return catalyst.measure(0), catalyst.measure(1) ppm_specs = catalyst.passes.ppm_specs(circuit) print(ppm_specs)
Because Catalyst does not currently support execution of Pauli-based computation operations, we must halt the pipeline after
quantum-compilation-stage. This ensures that only the quantum passes will be applied to the initial MLIR, without attempting to further compile for execution.Example PPM Specs:
. . . {'circuit_0': { 'depth_pi2_ppr': 7, 'depth_ppm': 15, 'logical_qubits': 2, 'max_weight_pi2': 2, 'num_of_ppm': 24, 'pi2_ppr': 16 } } . . .