-
Notifications
You must be signed in to change notification settings - Fork 27
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
Bit order: State Vector Results Inconsistent with Other Simulators #21
Comments
I think the issue is that some simulators display the state vectors in high qubit to low qubit order and some in low qubit to high qubit order. I prefer the order that you list the results but it's not consistent with a lot of the pervasive simulators. It just makes sense to me to list the elements of each result braket in the same order as the circuit was configured - like you do. |
Hi Philip 👋 I think I see what you’re saying, but let me be sure. I used Q’s Playground page to input this:
That created a circuit that was 4 moments long, operating on a single qubit. Here’s a screen grab of the resulting interactive circuit diagram and probability results: If I’m understanding you correctly, the issue is that Probability Results are being listed with
So you’re saying the order of the results list ought to be reversed like this?
Or to use a slightly more complex example, this:
ought to result in this listing?
|
Much apology. I wasn't clear. I intended four qubits with one instructions per qubit. X Some other simulators seem to list the order of probability in the order of Q4, Q3, Q2, then Q1 1 |0000> 0.00% Also an example at: https://quantum-circuit.com/home/simulate/mgbpRHGLJS3BpKMdS/browser However, the ordering which you use makes the most sense to me. |
Hi, As a convention, in quantum circuits, qubit 0 is the least significant bit. Say you want to output as 5 ( binary 101 ). I should be able to set in Q.js currently - value of qubit0 depends on total number of qubits present, as it is considered most significant bit. Can potentially cause issues when dynamically building and appending circuits. For eg. Results for both these should be binary 5 - irrespective of number of qubits in the circuit
|
I'm a casual user, but "display the circuit upside down from the bit order" has always felt confusing to me. I like the way Q.js does it |
👋 Hi, everyone! My apologies for radio silence on this repo for a span. Aside from the pandemic, work, and home life, I also put out a fan-made music “video” made of HTML elements for Thom Yorke’s “Black Swan”, a hand-pose recorder / recognizer for the WebXR API as used on Oculus Quest that interprets ASL finger spelling, a Web Audio guitar pedal of sorts, and other bits that are still in the works. It’s been a lot! @marwahaha, I have totally agreed with your view of this from the beginning—hence how I implemented the bit order in Q.js. However—and this is a big “however”—@simplygreatwork and @jag-p have opened my eyes to an interesting wrinkle (which @jag-p already described above better than I could) which amounts to this: adding a new register to your already designed circuit totally borks your output because instead of adding a binary digit to the beginning of your output string (which leaves your previous output values as they were), you’re adding it to the end (which shifts all your previous values over by 2n). Let’s take a look at a simple example, a one-register, one-moment circuit with a single Hadamard gate:
A one-register circuit has two possible outcomes,
We can write some logic to handle either outcome like so:
Now we have a problem. Our intuition says we’ve changed nothing meaningful about our circuit. Yet because of the bit order that I’ve implemented we’ve accidentally changed our circuit significantly:
We now must re-write our above logic like so:
So I’m now in the camp of wanting to reverse Q’s bit order to fall inline with other quantum libraries; now that I better understand why they were implemented that way. (I don’t have a time table for that right now, but it does seem like the right long-term decision.) What say the community? |
Hi Stewart,
I love your work. Happy anniversary for Q.js!
When run XHHH in your live editor, the results make sense to me. But the results you give are inconsistent with results of other simulators such as https://quantum-circuit.com/ and http://oreilly-qc.github.io/ Results from your live editor are grouped - yet results from the other simulators are interspersed.
Can you explain why these results are so inconsistent? Another library which returns results similar to yours for this example is https://github.com/adamisntdead/qics
The text was updated successfully, but these errors were encountered: