Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sv-sim and dm-sim run circuits with classical conditional gates giving wrong shots statistics #12

Open
nkcxliu2 opened this issue Jan 31, 2024 · 0 comments

Comments

@nkcxliu2
Copy link
Collaborator

When there are classically conditioned gates in the middle of the circuits, the shot distribution calculated from either sv-sim or dm-sim shows wrong statistics.

Taking the following teleportation circuit as an example,

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c1[1];
creg c2[1];
creg c3[1];
sx q[1];
rz(pi/2) q[1];
cx q[1],q[2];
cx q[0],q[1];
rz(pi/2) q[0];
sx q[0];
rz(pi/2) q[0];
measure q[0] -> c1[0];
measure q[1] -> c2[0];
if(c1==1) z q[2];
if(c2==1) x q[2];
measure q[2] -> c3[0];

This is a circuit that prepares a Bell state between qubit q[1] and q[2], while teleporting the state of q[0], which is in the 0 state, to the q[2]. The measurements on qubits q[0] and q[1] should have an equal probability to get either 0 or 1.

Runing noiseless sv-sim with 1024 shots to simulate this qasm code with CPU backend (macOS 14.3), the resulting shots are

===============  Measurement (tests=1024) ================
"0 0 0" : 1024

We expect the outcomes should be equally distributed shots among 000, 010, 100, and 110. The simulation result using ibmq circuit composer is attached.

In order to make this circuit implementable using dm-sim, the conditional z gate is changed to rz(pi), which will add a global phase to the state and not affect the shots. The simulation from dm-sim is

===============  Measurement (tests=1024) ================
"0 0 0" : 955
"0 0 1" : 69

which is also not consistent with the correct result.

ibmq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant