-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Strange Behaviour of sx
gate when defined inline in QASM
#12167
Comments
I think perhaps this is happening because the |
Lev: it is, I was halfway through typing that haha. It's potentially a vagueness in the OQ3 spec, or alternatively a typo in the OQ3 example, and it should be |
If it's any help, running the 'broken' QASM through braket and quantastica simulators give the correct result, so I guess they are doing float eval behind the scenes. |
Yeah I think by the openqasm spec as written, the bug is with the qasm (and, I guess by extension there are bugs with braket/quantastica) https://openqasm.com/language/types.html#casting-specifics |
I agree that I'd read it that way; though to be pedantic the spec only mentions "promotion and conversion in mixed expressions and assignments", and I can only see a specific mention of integer division referred to for angles. |
Additionally, are there implementation defined limits on the size of the values? I can produce
|
For |
Ok it's IEEE-754 double, thanks for all your help! |
Technically OQ doesn't specify the floating-point width of floating-point literals (as far as I remember), but in practice I'd be surprised if there's any implementation out there that doesn't use |
I suppose that these huge angles are not realistic (I am autogenerating programs, hence the weirdness); it may help for troubleshooting in the future to add a stderr warning if a supplied angle seems unrealistically large or cannot be stored at full precision (as the C compilers do). Anyway, the original reason I opened this issue seems to be a typo in stdgates so I guess we're getting off-topic. |
Ok, one last thing (I hope) - does the openQASM spec specify whether operations of the same precedence evaluated left-to-right (including casts)? e.g. by C specification with left-to-right eval, |
Yes OQ does specify left-to-right evaluation https://openqasm.com/language/classical.html#evaluation-order so I believe |
Huh, I could have sworn there was a line about associativity in the spec, especially about the power operator. We should fix that - "left to right" is imprecise, and not everything ought to be left-associative. The ANTLR grammar for sure associates power to the right. |
Hi, just a follow up on this that's tangentially related; but I don't think is worth creating a new issue for. Can bit strings be treated as ‘integer’ type literals in openQASM3? Reading the spec (https://openqasm.com/language/types.html#literals), it seems that they are syntactic sugar for bracketed array literals (ie
|
Sorry, that last question seemed to get lost. It's not 100% clear in the language right now what the difference between |
Environment
What is happening?
Applying the
sx
gate seems to give a different result if I copy and paste thex
andsx
gate definitions out fromstdgates.inc
, versus if I useinclude stdgates.inc
.How can we reproduce the issue?
Output:
What should happen?
Using the include instead:
Gets the correct probabilities:
Any suggestions?
No response
The text was updated successfully, but these errors were encountered: