Skip to content

Conversation

@rscircus
Copy link
Contributor

@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
Contributor 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 a team and vtomole 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
Contributor 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
Contributor Author

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

Copy link
Contributor

@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 :)

@github-actions github-actions bot added the Stale label Oct 28, 2024
@dstrain115
Copy link
Collaborator

It looks like there is an error in the parser:

ERROR: /home/runner/work/Cirq/Cirq/cirq-core/cirq/contrib/qasm_import/_parser.py:508: Symbol 'qreg' used, but not defined as a token or a rule

Also, please run check/formatting in order to pass the format check.

@mhucka mhucka added status/stale This has been closed due to inactivity for an extended period of time. and removed Stale labels Nov 18, 2024
@github-actions github-actions bot removed the status/stale This has been closed due to inactivity for an extended period of time. label Nov 19, 2024
@gluonhiggs
Copy link

It looks like there is an error in the parser:

ERROR: /home/runner/work/Cirq/Cirq/cirq-core/cirq/contrib/qasm_import/_parser.py:508: Symbol 'qreg' used, but not defined as a token or a rule

Also, please run check/formatting in order to pass the format check.

Hello everyone, is there anything remaining to address in this PR before it can be finalized?

@pavoljuhas
Copy link
Collaborator

@rscircus - thank you for contributing this and apologies for slow response.

I have fixed the typo in parser definition and complaints from format checker.
I also added a test of the reset instruction with OpenQASM 3.

Please take a look if you are fine with the PR as is. LGTM from my POV.

@codecov
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.85%. Comparing base (d760f00) to head (066d4ae).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6710      +/-   ##
==========================================
- Coverage   97.85%   97.85%   -0.01%     
==========================================
  Files        1084     1084              
  Lines       93742    93758      +16     
==========================================
+ Hits        91733    91745      +12     
- Misses       2009     2013       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rscircus
Copy link
Contributor Author

Thanks. I'll pull at the weekend and give it a final run.

@pavoljuhas pavoljuhas enabled auto-merge (squash) December 2, 2024 18:30
@pavoljuhas pavoljuhas merged commit 429bb9b into quantumlib:main Dec 2, 2024
37 checks passed
@pavoljuhas
Copy link
Collaborator

Thanks. I'll pull at the weekend and give it a final run.

I have merged, hope it is OK. LMK if you see anything amiss and we can address it in a follow-up PR.

@rscircus
Copy link
Contributor Author

Thanks, @pavoljuhas

BichengYing pushed a commit to BichengYing/Cirq that referenced this pull request Jun 20, 2025
Test parsing of `reset` with both OpenQASM 2.0 and 3.0.

Fixes: quantumlib#6704

---------

Co-authored-by: Pavol Juhas <juhas@google.com>
github-merge-queue bot pushed a commit that referenced this pull request Aug 6, 2025
Since recent changes have added supports for multiple statements, update
the description in the OpenQASM compatibility table accordingly.

#6917: added "gate" support
#6710: added "reset" support
#4738: added "if" support

Fixes: #7525
pavoljuhas pushed a commit that referenced this pull request Aug 14, 2025
Since recent changes have added supports for multiple statements, update
the description in the OpenQASM compatibility table accordingly.

#6917: added "gate" support
#6710: added "reset" support
#4738: added "if" support

Fixes: #7525
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants