qml.pauli_measure¶
- pauli_measure(pauli_word, wires, postselect=None)[source]¶
Perform a Pauli product measurement.
A Pauli product measurement (PPM) is the measurement of a tensor product of Pauli observables (
X,Y,Z, andI).The eigenvalue of this tensor product is one of 1 or -1, which is mapped to the 0 or 1 outcome of the PPM, respectively. After the measurement, the state collapses to the superpositions of all degenerate eigenstates corresponding to the measured eigenvalue.
Note
Circuits comprising
pauli_measureare currently not executable on any backend. This function is only for analysis using thenull.qubitdevice and potential future execution when a suitable backend is available.See also
For more information on Pauli product measurements, check out the Quantum Compilation hub and
catalyst.passes.ppm_compilation()for compiling these circuits with Catalyst.- Parameters:
pauli_word (str) – The Pauli word to measure.
wires (Wires) – The wires that the Pauli word acts on.
postselect (Optional[int]) – The postselection value, one of
0or1. It determines which subspace of degenerate eigenstates to postselect after a Pauli product measurement.Noneby default.
- Returns:
A reference to the future result of the Pauli product measurement
- Return type:
MeasurementValue
- Raises:
ValueError – if the Pauli word has characters other than X, Y and Z.
ValueError – if the number of wires does not match the length of the Pauli word.
Example:
The following example illustrates how to include a Pauli product measurement (PPM) in a circuit by specifiying the Pauli word and the wires it acts on.
@qml.qnode(qml.device("null.qubit", wires=3)) def circuit(): qml.Hadamard(0) qml.Hadamard(2) ppm = qml.pauli_measure(pauli_word="XY", wires=[0, 2]) qml.cond(ppm, qml.X)(wires=1) return qml.expval(qml.Z(0))
The
Xoperation on wire1will be applied conditionally on the value of the PPM outcome:>>> print(qml.draw(circuit)()) 0: ──H─╭┤↗X├────┤ <Z> 1: ────│──────X─┤ 2: ──H─╰┤↗Y├──║─┤ ╚════╝
Additionally, the number of PPM operations in a circuit can be easily inspected with
specs()where they are denoted as aPauliMeasuregate type:>>> print(qml.specs(circuit)()['resources']) Total wire allocations: 3 Total gates: 4 Circuit depth: 3 Gate types: Hadamard: 2 PauliMeasure: 1 Conditional(PauliX): 1 Measurements: expval(PauliZ): 1