-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
random qubit order from the outcome of the simulation #4144
Comments
Hi @JiahaoYao can you provide a complete example? |
Hi @daxfohl , thanks so much. Let me try to figure out how to provide a clear example. Probably will get back to you at a later time. |
Hey @JiahaoYao, a clear example would simply be the whole program that generates the results you are getting. What is your |
Hi @vtomole and @daxfohl , thanks for your patience. Here is the MWE to reproduce the issue: import cirq
qr = cirq.LineQubit.range(6)
circuit = cirq.Circuit([cirq.H(qr[0]), [cirq.CNOT(qr[0], qr[i]) for i in range(1, 6, 1)], [cirq.measure(qr[i], key="q{}".format(i)) for i in range(len(qr))]])
result = cirq.Simulator().sample(circuit, repetitions=100)
print(result.columns) |
looks like the ordering of qubit can not be controlled, wonder if this is because the data frame does not preserve the ordering. |
Thanks for the clear example! It took me a while to figure out what was going on vs what was expected. The behavior is expected. The qubit order comes into play only when looking at the raw state vector (or density matrix, Clifford tableau, or other state representation) and how it's laid out under the hood, but not sample results. Sample results have no guaranteed ordering (defacto they are ordered by which order they are encountered in the simulation). qubit_order has no effect on those because measurements aren't the same thing as qubits; they're string keys that just happen to correspond to the qubit name if no other name is provided. (In future iterations we're expanding the concept of measurement, such that a measurement may correspond to multiple qubits or even no qubits at all). |
Hi @daxfohl, thank you for spending time looking into this! I really appreciate it! I very much agree with you and thank you again! |
Description of the issue
The output of the cirq simulation gives random order? But in the document, it says that from the tutorial
I have the line qubits
When I do
I sometimes got this,
and another run
Is this typical, or I have to state the qubit order, but it seems will use
ops.qubitorder.default
if I didn't declare? So is this the bug for the qubit order from the outcome of the simulation?Cirq version: 0.10.0
The text was updated successfully, but these errors were encountered: