I have a quantum circuit illustrated in the provided image, where I perform a series of quantum operations followed by a projective measurement.enter image description here.

Using Qiskit, I've already written the code for this circuit. Now, I'm interested in using the stim library to obtain the final state after the measurement. How can I accomplish this?

Qiskit code is

import numpy as np
from qiskit import QuantumCircuit, transpile, Aer, assemble

qubits = 4
qc = QuantumCircuit(qubits,1)

hx = 1
hz = 1


#even evolution
#odd evolution

qc.measure(2, 0)
# Transpile the circuit for simulation
simulator = Aer.get_backend('statevector_simulator')
compiled_circuit = transpile(qc, simulator)

# Simulate the circuit and get the final state vector
result = simulator.run(compiled_circuit).result()
final_state_vector = result.get_statevector()

# Print the final state vector

1 Answer 1


See Gates supported by Stim in stim's doc/ directory.

Stim only supports stabilizer gates, so it can't rotate by 2 radians around the Z axis like you are doing in your circuit. The closest would be the SQRT_Z gate, which rotates by $\pi/2$ radians around Z.

In a stabilizer circuit you can only do rotations that would leave a cube looking identical before and after the rotation. You can rotate by multiples of 90 degrees around the X, Y, or Z axis (e.g. gates like SQRT_X). You can rotate 180 degrees around the sum of two axes, like X+Z (gates like H). Or you can rotate 120 degrees around the sum of three axes, like X+Y+Z (gates like C_XYZ). And that's it.


Your Answer

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

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