mimiqcircuits.operations.measurepauli

Pauli product measurement (MeasurePauli).

Classes

MeasurePauli(pauli)

Pauli product measurement.

class mimiqcircuits.operations.measurepauli.MeasurePauli(pauli)[source]

Bases: AbstractMeasurement

Pauli product measurement.

Projective measurement of the \(N\)-qubit observable \(P = P_1 \otimes P_2 \otimes \dots \otimes P_N\), with each \(P_i \in \{I, X, Y, Z\}\).

The instruction targets \(N\) qubits and one classical bit. The state is projected onto the \(+1\) or \(-1\) eigenspace of \(P\) and the bit records the outcome: 0 for \(+1\), 1 for \(-1\). Qubits marked I are targets of the instruction but are not measured.

To measure \(-P\), measure \(P\) and flip the bit with Not.

Parameters:

pauli (PauliString or str) – the observable, as a PauliString or a string of I, X, Y, Z.

Raises:
  • TypeError – if pauli is neither a PauliString nor a str.

  • ValueError – if the string is empty, contains a character other than I, X, Y, Z, or is the identity.

See also

PauliString, RPauli, MeasureZZ, MeasureXX, MeasureYY, pauli_based_computation()

Examples

Measure \(X_0 Z_2\) on qubits 0 to 2 and store the outcome in bit 0. Qubit 1 is a target, but is left untouched:

>>> from mimiqcircuits import *
>>> MeasurePauli("XIZ")
MP(XIZ)
>>> c = Circuit()
>>> c.push(MeasurePauli("XIZ"), 0, 1, 2, 0)
3-qubit, 1-bit circuit with 1 instruction:
└── MP(XIZ) @ q[0:2], c[0]

Decomposition:

Each measured qubit is rotated to the Z basis (H for X, SDG then H for Y), CX gates collect the parity of the measured qubits on the last one, that qubit is measured, and the CX gates and rotations are undone:

>>> decompose_step(MeasurePauli("XZ"))
2-qubit, 1-bit circuit with 5 instructions:
├── H @ q[0]
├── CX @ q[0], q[1]
├── M @ q[1], c[0]
├── CX @ q[0], q[1]
└── H @ q[0]

Only H, S, SDG, CX and Measure appear, so QASMBasis decomposes it. StimBasis keeps it, as Stim measures Pauli products natively (MPP), and so does CliffordTBasis.

__init__(pauli)[source]
pstring()[source]

Return the Pauli string as a plain str.

inverse()[source]
power(p)[source]
control(num_qubits)[source]
iswrapper()[source]
get_operation()[source]
asciiwidth(qubits, bits, zvars)[source]