I am following the tutorial mentioned in the circuit-knitting-toolbox.

This tutorial explains how you can replace non-local gates with local operations in the superoperator representations and effectively cut the gates, reducing the number of qubits required to run the circuit.

From the tutorial, I see they just make a random circuit :

enter image description here

Then they want it to be cut into two subcircuits of two-qubit each and then they wrote the code:

from qiskit.quantum_info import PauliList

observables = PauliList(["ZZII", "IZZI", "IIZZ", "XIXI", "ZIZZ", "IXIX"])

They are calculating the expectation value of the circuit, but I still don't understand the choice of these Pauli matrices, the order in which they are, and the fashion they are chosen. Can anyone point me in the right direction to understand how this is done?


1 Answer 1


The Pauli list says the operator or the basis on which you want to measure the quantum state. Whenever you implement a QAOA, or any other code that requires you to find the expectation value of an operator, it does so by measuring the state on some basis. Like this:


The measurement is mostly on a computational basis, which is the $Z$ basis, but you can measure on another basis as well, like the other Pauli Operators. That is what is mentioned here.

Like in QAOA when you have to minimize the energy, you do :

$$E = \langle\psi|O|\psi\rangle.$$

You need to define the operator 𝑂 you're interested in and the state |𝜓⟩ concerning which you want to compute the expectation value.

Using the code like this:

# you can define your operator as circuit
circuit = QuantumCircuit(2)
op = CircuitOp(circuit)  # and convert to an operator

# or if you have a WeightedPauliOperator, do
op = weighted_pauli_op.to_opflow()

# but here we'll use the H2-molecule Hamiltonian
from qiskit.aqua.operators import X, Y, Z, I
op =  (-1.0523732 * I^I) + (0.39793742 * I^Z) + (-0.3979374 * Z^I) \
    + (-0.0112801 * Z^Z) + (0.18093119 * X^X)

# define the state you w.r.t. which you want the expectation value
psi = QuantumCircuit(2)

# convert to a state
psi = CircuitStateFn(psi)

and then just straightforward calculating the expectation value, gives you your result.

# easy expectation value, use for small systems only!
print('Math:', psi.adjoint().compose(op).compose(psi).eval().real)

The same operators are here, you can keep them all $Z$ , or all $X$, it's for you to decide in which basis you want to measure, just keep in mind that they should be equal to the number of qubits in your quantum circuit, one for each.


Your Answer

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