mimiqcircuits.operations.measurepauli¶
Pauli product measurement (MeasurePauli).
Classes
|
Pauli product measurement. |
- class mimiqcircuits.operations.measurepauli.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 or str) – the observable, as a
PauliStringor a string ofI,X,Y,Z.- 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()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 (
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:>>> 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,CXandMeasureappear, soQASMBasisdecomposes it.StimBasiskeeps it, as Stim measures Pauli products natively (MPP), and so doesCliffordTBasis.