-
Notifications
You must be signed in to change notification settings - Fork 116
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
QASM and its implementation seem to have bugs. #65
Comments
This is an excellent point which I was not at all aware of, thanks! I frankly don't know what to do here. Most of the time the minus sign in front of the "true" Hadamard doesn't make a difference, but it may, e.g. in a case of a CTRL-Hadamard. I am tempted to leave it as is (and document it), so it uses the "true" Hadamard from the Q++. Other option is to just add a minus sign when parsing the QASM, so |
IBM (Qiskit) is presumably the leading user of the QASM. If the fundamental H gate had been wrong, that would have affected thousands of users for a few years. I couldn't believe it. So, I take a look at the Qiskit QASM implementation. It turns out their code does not match their QASM specification either, the code being correct. The root cause is not the Using the information of that matrix, I change the Quantum++
Now, the Well, the U gate change would affect pretty much every single gate in the |
@DevelopDaily Fixed, now all gates in |
Here is a little piece of useful information. I stated earlier that the Qiskit implementation is "drastically" different from that in the spec. As a matter of fact, my statement was inaccurate. I just realize the matrix in the spec is not that different. If we divide the matrix by |
@DevelopDaily Thanks! So I hope that the fixes are also OK? |
Definitely, the fixes are perfect. I have been using them since they were released. Thanks. |
I have two simple QASM files:
Let's pass test1.qasm to this program to run first, then test2.qasm.
Running test1.qasm produces this result:
and test2.qasm this result:
Logically, however, we should expect the same results because both the QASM specification and the Quantum++ implementation, which has faithfully followed the spec, define this:
I did some analysis on the issue. Using Hadamard gate directly like the one in the test1.qasm is always correct because the H gate is hard-coded correctly in the Quantum++, bypassing the definition in the qelib1.inc.
So, the problem seems to be twofold. The QASM spec is wrong. Then, the implementation leads the API users to an illusion that the H gate is equivalent to
gate h a { u2(0,pi) a; }
. But, in fact, it does not use that definition at all.By the way, I use this QASM paper as my reference.
The text was updated successfully, but these errors were encountered: