mimiqcircuits.operations.measurepauli¶
Pauli product measurement (MeasurePauli).
Classes
|
Pauli product measurement. |
- class MeasurePauli(pauli)[source]¶
Bases:
AbstractMeasurementPauli 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:
0for \(+1\),1for \(-1\). Qubits markedIare targets of the instruction but are not measured.To measure \(-P\), measure \(P\) and flip the bit with
Not.- Parameters:
pauli (PauliString | str) – The observable, as a
PauliStringor a string ofI,X,Y,Z. Stored in thepauliattribute as aPauliString.- Raises:
TypeError – If
pauliis neither aPauliStringnor astr.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()Each measured qubit is rotated to the Z basis (
HforX,SDGthenHforY), 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. OnlyH,S,SDG,CX,MeasureandID(on a trailing identity factor, to keep the width) appear, soQASMBasisdecomposes it.StimBasisandCliffordTBasiskeep it as it is, as Stim measures Pauli products natively (MPP).Measurements are not reversible:
inverse,powerandcontrolraiseTypeError.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]
One decomposition step shows the basis change and parity collection:
>>> 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]