Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

rscircus
Copy link

@rscircus rscircus commented Aug 22, 2024

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 or cirq.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.

@CirqBot CirqBot added the size: M 50< lines changed <250 label Aug 24, 2024
@rscircus
Copy link
Author

Rebased on top of main.

@rscircus rscircus force-pushed the add-reset-gate branch 2 times, most recently from 44689b7 to bfac925 Compare September 14, 2024 12:41
@rscircus rscircus marked this pull request as ready for review September 14, 2024 12:42
@rscircus rscircus requested review from vtomole and a team as code owners September 14, 2024 12:42
@rscircus rscircus force-pushed the add-reset-gate branch 2 times, most recently from a8cdb0b to dc4dffa Compare September 14, 2024 13:07
@rscircus
Copy link
Author

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.
@rscircus
Copy link
Author

Hey guys, you have any feedback on the solution proposal here?

Copy link

@natestemen natestemen left a 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))]

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];

@github-actions github-actions bot added the Stale label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250 Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants