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

Fix mapped measurement keys of repeat_until fields in CircuitOperations #6881

Merged
merged 13 commits into from
Jan 30, 2025

Conversation

daxfohl
Copy link
Collaborator

@daxfohl daxfohl commented Dec 24, 2024

Create a _mapped_repeat_until cached property of CircuitOperation that ensures repeat_until conditions have the path and key mappings of the subcircuit applied during execution time or when calculating control_keys.

Fixes #6446

Create a _mapped_repeat_until cached property that ensures repeat_until conditions have the path and key mappings of the subcircuit applied during execution time or when calculating control_keys.
@daxfohl daxfohl requested review from vtomole and a team as code owners December 24, 2024 21:05
@daxfohl daxfohl requested a review from viathor December 24, 2024 21:05
@CirqBot CirqBot added the size: M 50< lines changed <250 label Dec 24, 2024
Conditions don't support params, as any unresolved symbols are expected to be measurement keys. Perhaps a future feature to consider, but outside the scope of this PR.
Built-in conditions don't support param resolvers, but custom ones plausibly could. May as well keep the functionality, and add a dummy test for coverage.
Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.89%. Comparing base (e6c1101) to head (d1c7bd7).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6881   +/-   ##
=======================================
  Coverage   97.89%   97.89%           
=======================================
  Files        1085     1085           
  Lines       95050    95098   +48     
=======================================
+ Hits        93048    93095   +47     
- Misses       2002     2003    +1     

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

@daxfohl
Copy link
Collaborator Author

daxfohl commented Jan 3, 2025

@mhucka I think another glitch. Notebook test seems to have failed to launch.

@mhucka
Copy link
Contributor

mhucka commented Jan 4, 2025

Thanks for flagging this. I have a PR for the flaky pytest runs now, and will turn attention to this notebook one next.

@daxfohl daxfohl requested a review from mhucka January 16, 2025 20:45
@daxfohl
Copy link
Collaborator Author

daxfohl commented Jan 23, 2025

@vtomole did you want to give this a look? It's a fix for issue #6446 that you filed, and uses the circuit from that issue as a test case. (The code to create the circuit is slightly different because use_repetition_ids was recently changed in #6910 to default to False, but the resulting circuit is the same as the one in the issue).

@mhucka
Copy link
Contributor

mhucka commented Jan 29, 2025

@daxfohl Sorry for how long I took to get back to this. In regards to #6881 (comment), I've been searching for the log where the notebook error shows up, but haven't been able to find it. It might have been replaced by GitHub when the checks were re-run manually (which I probably did trigger, as I have a habit of re-running failing tests to make sure the failure is consistent).

If you didn't happen to save it or a link to it, then I think for the time being, we'll have to wait to see if it occurs again. It was unusual and I don't thik it's happened since – it might have been a glitch on the GitHub side and not indicative of a flaky test.

Copy link
Contributor

@mhucka mhucka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment on the technical (in terms of circuit operations) correctness, the code looks reasonable.

It's up to you, but I would find the addition of some comments helpful, e.g., to explain that the caching is not for speed (which people might assume is the reason), but rather to fix a bug in the scoping of values used in repeat_until.

@daxfohl
Copy link
Collaborator Author

daxfohl commented Jan 29, 2025

Thanks! Good point, I'll add a couple code comments before merging.

@daxfohl daxfohl enabled auto-merge January 30, 2025 01:30
@daxfohl daxfohl added this pull request to the merge queue Jan 30, 2025
Merged via the queue into quantumlib:main with commit 0e5df4e Jan 30, 2025
38 checks passed
@daxfohl daxfohl deleted the fix-circuitop-rescoped-keys branch January 30, 2025 01:54
mhucka pushed a commit to mhucka/Cirq that referenced this pull request Jan 30, 2025
…ns (quantumlib#6881)

* Fix repeat_until scoped keys

Create a _mapped_repeat_until cached property that ensures repeat_until conditions have the path and key mappings of the subcircuit applied during execution time or when calculating control_keys.

* Remove param resolver support from repeat_until

Conditions don't support params, as any unresolved symbols are expected to be measurement keys. Perhaps a future feature to consider, but outside the scope of this PR.

* Undo previous change, just add dummy test for resolve_parameters

Built-in conditions don't support param resolvers, but custom ones plausibly could. May as well keep the functionality, and add a dummy test for coverage.

* Improve tests

* coverage

* fix test after merge from "use_repetition_ids" changes

* check for symbols in repeat_until

* doc
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.

Can't simulate a repeated CircuitOperation that contains a repeat_until CircuitOperation
3 participants