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 repeat-until functionality to subcircuits #5018

Merged
merged 21 commits into from
Mar 1, 2022

Conversation

daxfohl
Copy link
Collaborator

@daxfohl daxfohl commented Feb 23, 2022

Adds repeat-until functionality to subcircuits. It's only valid on subcircuits that do not use repetition ids, as otherwise there wouldn't be any mutating measurement value to repeat until.

@95-martin-orion no urgency here, and if we want a different approach for this I'm fine with closing it.

@daxfohl daxfohl requested review from a team, vtomole and cduck as code owners February 23, 2022 20:57
@daxfohl daxfohl requested a review from tanujkhattar February 23, 2022 20:57
@CirqBot CirqBot added the size: M 50< lines changed <250 label Feb 23, 2022
Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

Very cool. I think I'd like @mpharrigan's input on this as a potential user of this feature (e.g. would this work for measurement-based QC?), but overall I'm quite happy with how well Conditions work here.

cirq-core/cirq/circuits/circuit_operation.py Outdated Show resolved Hide resolved
cirq-core/cirq/circuits/circuit_operation.py Show resolved Hide resolved
@daxfohl
Copy link
Collaborator Author

daxfohl commented Feb 25, 2022

Should we say this closes #461?

@95-martin-orion
Copy link
Collaborator

Should we say this closes #461?

It's good to mention this on that issue, but I don't think it fully closes it. There are simulator-based optimizations for explicit post-selection (e.g. forcing measurements to a specific result) that this doesn't support.

@daxfohl
Copy link
Collaborator Author

daxfohl commented Feb 26, 2022

Also tagging #3234

Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

Opted to merge #5033 first since it's smaller - this will need conflict resolution after that finishes.

@daxfohl
Copy link
Collaborator Author

daxfohl commented Mar 1, 2022

@95-martin-orion no conflicts

@95-martin-orion 95-martin-orion merged commit 3c1c802 into quantumlib:master Mar 1, 2022
95-martin-orion pushed a commit to 95-martin-orion/Cirq that referenced this pull request Mar 2, 2022
* Allow flattening of subcircuits

* format

* Add serialization logic and tests

* Change flatten_repetitions (default False) to use_repetition_ids (default True)

* Add shape tests for simulation results from flattened subcircuits

* docs

* add repeat_until

* repr/json/etc

* format

* chagne do_while to repeat_until

* merge fix

* make mapped_single_loop private

* Address code review comments.

* Fix test

* simplify branch

* simplify branch

* simplify branch

* add unbound controls in repeat_until to control_keys
@daxfohl daxfohl deleted the repeatuntil3 branch March 4, 2022 14:07
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* Allow flattening of subcircuits

* format

* Add serialization logic and tests

* Change flatten_repetitions (default False) to use_repetition_ids (default True)

* Add shape tests for simulation results from flattened subcircuits

* docs

* add repeat_until

* repr/json/etc

* format

* chagne do_while to repeat_until

* merge fix

* make mapped_single_loop private

* Address code review comments.

* Fix test

* simplify branch

* simplify branch

* simplify branch

* add unbound controls in repeat_until to control_keys
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
* Allow flattening of subcircuits

* format

* Add serialization logic and tests

* Change flatten_repetitions (default False) to use_repetition_ids (default True)

* Add shape tests for simulation results from flattened subcircuits

* docs

* add repeat_until

* repr/json/etc

* format

* chagne do_while to repeat_until

* merge fix

* make mapped_single_loop private

* Address code review comments.

* Fix test

* simplify branch

* simplify branch

* simplify branch

* add unbound controls in repeat_until to control_keys
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.

3 participants