2
$\begingroup$

Is there a neat way to derive and efficiently implement a measurement circuit for tensor products of arbitrary Pauli operators like $XZZXZ$ in Qiskit ?

I tried using the pauli_measurement function, where I used a PauliOperator object initialized from a corresponding label, but this function seems to perform single-qubit post-rotations for each part of the label and I am not sure if this is what I actually want to measure. I assume, that a generalization of what is described here https://github.com/MicrosoftDocs/quantum-docs/blob/main/articles/concepts-pauli-measurements.md would fit this measurement scenario.

$\endgroup$
1
  • 1
    $\begingroup$ If you want your measurements in the Z basis, then you could simply implement your Pauli string in the specific qubits and then measure. $\endgroup$ Aug 2, 2021 at 15:16

1 Answer 1

1
$\begingroup$

If you don't want to write your own function to do this then one way to do this is through qiskit pauli_measurement.

For example:

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister 
from qiskit.quantum_info import Pauli
from qiskit.aqua.operators.legacy import pauli_measurement
qr = QuantumRegister(4)
cr = ClassicalRegister(4)
qc = QuantumCircuit(qr,cr)
pauli_measurement(qc, Pauli('XYZX'), qr , cr  )
print(qc)

      ┌───┐       ┌─┐        
q2_0: ┤ H ├───────┤M├────────
      └┬─┬┘       └╥┘        
q2_1: ─┤M├─────────╫─────────
       └╥┘ ┌─────┐ ║ ┌───┐┌─┐
q2_2: ──╫──┤ SDG ├─╫─┤ H ├┤M├
        ║  └┬───┬┘ ║ └┬─┬┘└╥┘
q2_3: ──╫───┤ H ├──╫──┤M├──╫─
        ║   └───┘  ║  └╥┘  ║ 
c2: 4/══╩══════════╩═══╩═══╩═
        1          0   3   2 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.