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

Incorrect simulation result #509

Open
singular-value opened this issue May 10, 2024 · 1 comment
Open

Incorrect simulation result #509

singular-value opened this issue May 10, 2024 · 1 comment

Comments

@singular-value
Copy link

The chance display at the bottom-right of this circuit looks to be broken.

One way to see this is by noticing that the even-parity bitstrings have probability of 27.3+17.1+26.5+6.5=77.4%, which is inconsistent with the 50% individual-qubit probability.

image

Or alternatively, here is some cirq code to compare against

circuit = cirq.Circuit()
q = cirq.LineQubit.range(15)

circuit += cirq.H.on_each(q[0:3])

for bits in itertools.product([0,1], repeat=3):
    circuit += (cirq.Y(q[3]) ** (0.795 if bits[0] else 0.205)).controlled_by(*q[0:3], control_values=bits)
    circuit += (cirq.Y(q[4]) ** (0.795 if bits[1] else 0.205)).controlled_by(*q[0:3], control_values=bits)
    circuit += (cirq.Y(q[5]) ** (0.795 if bits[2] else 0.205)).controlled_by(*q[0:3], control_values=bits)

for i in range(3, 6):
    circuit += cirq.CX(q[i], q[i+3])

for bits in itertools.product([0,1], repeat=3):
    circuit += (cirq.Y(q[9]) ** (0.795 if bits[0] else 0.205)).controlled_by(*q[3:6], control_values=bits)
    circuit += (cirq.Y(q[10]) ** (0.795 if bits[1] else 0.205)).controlled_by(*q[3:6], control_values=bits)
    circuit += (cirq.Y(q[11]) ** (0.795 if bits[2] else 0.205)).controlled_by(*q[3:6], control_values=bits)

for i in range(9, 12):
    circuit += cirq.CX(q[i], q[i+3])

circuit += cirq.measure(q[6:9] + q[12:15])

result = cirq.Simulator().run(circuit, repetitions=100000)
fig, ax = plt.subplots(figsize=(25, 5))
_ = cirq.plot_state_histogram(result, ax)  # gives a uniform probability distribution over 000...111 
@Strilanc
Copy link
Owner

Strilanc commented May 12, 2024 via email

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

2 participants