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

Don't construct huge repetition id lists for CircuitOperation when use_repetition_ids=False #5418

Closed
Strilanc opened this issue May 29, 2022 · 0 comments · Fixed by #5419
Closed
Labels
kind/bug-report Something doesn't seem to work.

Comments

@Strilanc
Copy link
Contributor

Strilanc commented May 29, 2022

Do not run this repro code unless you like thrashing your machine.

import cirq
op = cirq.CircuitOperation(
    cirq.FrozenCircuit(),
    repetitions=1_000_000_000_000,
    use_repetition_ids=False)

Expected behavior

Because use_repetition_ids is set to False, no list of repetition ids is ever created and the code finishes in under a second. This remains true when using the operation for other actions that don't affect the repetition ids, like transforming its qubits or putting it into a diagram.

Actual behavior

Internally, the code attempts to create a list of one trillion repetition ids. This list will never be used and also does not fit in memory. The code takes forever and eventually crashes.


For context, I know that Mike Newman has used stim to run circuits with hundreds of millions of rounds. If he ever attempted to use stimcirq to convert that circuit into a cirq circuit... *KABOOM*.

@Strilanc Strilanc added the kind/bug-report Something doesn't seem to work. label May 29, 2022
@Strilanc Strilanc changed the title Don't construct CircuitOperation huge repetition id lists when use_repetition_ids=False Don't construct huge repetition id lists for CircuitOperation when use_repetition_ids=False May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-report Something doesn't seem to work.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant