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

Sweeping repetition count of circuit fragment #3266

Closed
viathor opened this issue Aug 26, 2020 · 7 comments · Fixed by #5043
Closed

Sweeping repetition count of circuit fragment #3266

viathor opened this issue Aug 26, 2020 · 7 comments · Fixed by #5043
Labels
area/circuits kind/feature-request Describes new functionality priority/p2 Next release should contain it status/needs-agreed-design We want to do this, but it needs an agreed upon design before implementation triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@viathor
Copy link
Collaborator

viathor commented Aug 26, 2020

Is your feature request related to a use case or problem? Please describe.

Oftentimes one has a circuit whose portion is to be repeated a number of times and one would like to sweep the repetition count. Example and context for this issue: implementing CPMG pulse train in cirq, see #3255.

Describe the solution you'd like

Current workaround entails parametrizing each repeated instance with a boolean parameter, so we end up with a number of parameters equal to the maximum of the repetition count. Ideally, we'd only need one parameter for this - repetition count.

What is the urgency from your perspective for this issue? Is it blocking important work?

P2 - we should do it in the next couple of quarters

@viathor viathor added kind/feature-request Describes new functionality triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Aug 26, 2020
@balopat
Copy link
Contributor

balopat commented Aug 26, 2020

Related #3235

@balopat balopat added triage/needs-feasibility [Feature requests] Needs design work to prove feasibility before accepting and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Aug 26, 2020
@balopat
Copy link
Contributor

balopat commented Aug 26, 2020

Discussed on Cirq Cynq, no objections - we just need to think through the design around this.

@balopat balopat added status/needs-agreed-design We want to do this, but it needs an agreed upon design before implementation triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on and removed triage/needs-feasibility [Feature requests] Needs design work to prove feasibility before accepting labels Sep 2, 2020
@balopat balopat added area/circuits priority/p2 Next release should contain it labels Sep 25, 2020
@balopat
Copy link
Contributor

balopat commented Sep 25, 2020

Subcircuits + loops should help in this
cc @95-martin-orion

@balopat balopat added this to the 0.10.0 milestone Sep 25, 2020
@95-martin-orion
Copy link
Collaborator

CircuitOperation is pretty close to supporting this - all we need is to allow repetitions to take a Symbol, and for the parameter resolution methods to check repetitions for parameters.

Actually sending circuits with this feature to hardware is another matter; that behavior is tracked by #3634.

@daxfohl
Copy link
Collaborator

daxfohl commented Jan 26, 2022

Requires #4888 or #4274

@daxfohl
Copy link
Collaborator

daxfohl commented Feb 11, 2022

Prototyped a "CircuitOperation.repeat_until" option here: 968773a, to go in after #4997. It only works on "flattened" subcircuits. To make it work on non-flattened circuits we'd have to do #4888 first, which is prototyped at 8a5f71d.

I started an attempt at parameterizing CircuitOperation.repetitions, but that's blocked by CircuitOperation._resolve_parameters_'s inability to handle recursive calls so I gave up.

@daxfohl
Copy link
Collaborator

daxfohl commented Mar 1, 2022

@viathor #5043 will address this.

CirqBot pushed a commit that referenced this issue Mar 15, 2022
Since recursive parameter resolution is now working (#5033) we can do this now.

The biggest caveat with this code is that params are floats, and repetitions must be an integer. I added a new type IntParam for the `repetitions` field itself, but it's still possible for the resolver to put a float value there. I added a runtime check for that. It may make sense to allow floats if they're really close to an integer, but I didn't do that here yet.

Closes #3266
rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
Since recursive parameter resolution is now working (quantumlib#5033) we can do this now.

The biggest caveat with this code is that params are floats, and repetitions must be an integer. I added a new type IntParam for the `repetitions` field itself, but it's still possible for the resolver to put a float value there. I added a runtime check for that. It may make sense to allow floats if they're really close to an integer, but I didn't do that here yet.

Closes quantumlib#3266
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this issue Oct 31, 2024
Since recursive parameter resolution is now working (quantumlib#5033) we can do this now.

The biggest caveat with this code is that params are floats, and repetitions must be an integer. I added a new type IntParam for the `repetitions` field itself, but it's still possible for the resolver to put a float value there. I added a runtime check for that. It may make sense to allow floats if they're really close to an integer, but I didn't do that here yet.

Closes quantumlib#3266
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/circuits kind/feature-request Describes new functionality priority/p2 Next release should contain it status/needs-agreed-design We want to do this, but it needs an agreed upon design before implementation triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants