JackHidary / quantumcomputingbook

Companion site for the textbook Quantum Computing: An Applied Approach
789 stars 215 forks source link

Flips the result measurement display #29

Open roosado opened 3 years ago

roosado commented 3 years ago

When ran, Bob's received message was printing flipped (i.e. it printed "01" when it received "10"). The issue wasn't in the measurement, because when printing "res.measurements" it correctly assigned the values to the qubits from the message as expected.

This correction flips the bitstring display so it prints the message correctly.

The error might come from a change in how cirq saves measurements from simulators, but I'm not sure.

rmlarose commented 3 years ago

Thanks @roosado - which Cirq version are you running which has the flipped measurement outcome?

krehermann commented 3 years ago

I see the same bitstring, but I'm not convinced its a problem with the bitstring function.

I'm using python 3.9.1 cirq 0.9.1

Here is the output with some extra prints:

cirq version: 0.9.1 Alice's sent msg is: 10

the superdense circuit 0: ───H───@───Z───@───H───M─── │ │ 1: ───────X───────X───M───────

Bob's meausurement values dict_values([array([[0]], dtype=int8), array([[1]], dtype=int8)])

Bob's recv: 01 bitstring([1,0]): 10

roosado commented 3 years ago

@rmlarose Same as @krehermann - cirq 0.9.1

But yeah, the problem is not in the bitstring function, it's got to be the way cirq is saving the values.

stevescia commented 3 years ago

I'm not seeing the problem,however I am using an older versions:

circ - 8.2 python 3.8

i embellished the book sample to superdense encode an arbituary string such as "hello world"

output snippet: sender's sent message = 01

cirquit: 0: ───H───@───Z───@───H───M─── │ │ 1: ───────X───────X───M─────── recv'ers recv'd message = 01