-
Notifications
You must be signed in to change notification settings - Fork 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
Add reset to QASM parser #6710
base: main
Are you sure you want to change the base?
Add reset to QASM parser #6710
Conversation
f1f4288
to
be1a8a1
Compare
Rebased on top of main. |
44689b7
to
bfac925
Compare
a8cdb0b
to
dc4dffa
Compare
Squashing everything into one commit after we finish review. Thus I leave the generic 'Fix comments & typos' as it is for now. |
Add a test which can serve as example including the modifications to support the `reset` keyword in the import of QASM files in the PLY based lexer/parser.
1332b34
to
9d2be2d
Compare
Hey guys, you have any feedback on the solution proposal here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My review doesn't mean much, since I'm not very familiar with this codebase, but the diff looks reasonable! Hope this can get reviewed by a cirq maintainer soon :)
"""reset : RESET qreg ';'""" | ||
qreg = p[2] | ||
|
||
p[0] = [ops.ResetChannel().on(qreg[i]) for i in range(len(qreg))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be some sort of check here to ensure the reset is applied on a qubit that is actually defined in the quantum register? E.g. should some error be raised when trying to parse the following QASM program?
OPENQASM 2.0;
include "qelib1.inc";
qreg q[1];
reset q[2];
It looks like there is an error in the parser:
Also, please run check/formatting in order to pass the format check. |
This PR solves #6704
Note / 20240914:
After further inspection, I wonder why resets are implemented quite different to regular gates, despite following a somewhat similar terminology (
cirq.R
orcirq.reset
) however, returning a ResetChannel. It appears to me that the reset is more similar to a measurement than compared to say a Hadamard gate.