qp.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, and I).

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_measure are currently only executable with qjit() and lightning qubit.

See also

For more information on Pauli product measurements, check out the Quantum Compilation hub and ppm_compilation() for compiling these circuits with qjit.

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 0 or 1. It determines which subspace of degenerate eigenstates to postselect after a Pauli product measurement. None by 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 specifying the Pauli word and the wires it acts on.

@qp.qnode(qp.device("null.qubit", wires=3))
def circuit():
    qp.Hadamard(0)
    qp.Hadamard(2)

    ppm = qp.pauli_measure(pauli_word="XY", wires=[0, 2])
    qp.cond(ppm, qp.X)(wires=1)

    return qp.expval(qp.Z(0))

The X operation on wire 1 will be applied conditionally on the value of the PPM outcome:

>>> print(qp.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():

>>> print(qp.specs(qp.qjit(circuit), level="top")()['resources'])
Quantum operations:
- Total: 4
- Hadamard: 2
- PPM-w2: 1
- PauliX: 1
Measurement processes:
- expval(PauliZ): 1
Total wires: 3
PBC Depths:
- Any commuting depth: 1
- Qubit disjoint depth: 1

Contents

Using PennyLane

Release news

Development

API

Internals