3
$\begingroup$

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

qc.rx(2*hx,np.arange(qubits))
qc.rz(2*hz,np.arange(qubits))

#even evolution
qc.cx(np.arange(0,qubits-1,2),np.arange(1,qubits,2))
qc.rz(2,np.arange(1,qubits,2))
qc.cx(np.arange(0,qubits-1,2),np.arange(1,qubits,2))
#odd evolution
qc.cx(np.arange(1,qubits-1,2),np.arange(2,qubits,2))
qc.rz(2,np.arange(2,qubits,2))
qc.cx(np.arange(1,qubits-1,2),np.arange(2,qubits,2))

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
print(final_state_vector)
$\endgroup$

1 Answer 1

3
$\begingroup$

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.

$\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.