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

Optimize circuit/moment resolution to reuse instances if possible #5894

Merged
merged 2 commits into from
Sep 28, 2022

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Sep 28, 2022

  • Make cirq.Moment resolvable, and don't allocate a new instance if nothing changes during resolution.
  • Combine _resolve_parameter_ implementations on Circuit and FrozenCircuit.
  • Use _from_moments to avoid constructor overhead when creating resolved circuits.
  • Return self if nothing has changed in circuit during resolution, to avoid unnecessary allocations.

@maffoo maffoo requested review from a team, vtomole and cduck as code owners September 28, 2022 05:12
@CirqBot CirqBot added the size: M 50< lines changed <250 label Sep 28, 2022
@tanujkhattar tanujkhattar self-assigned this Sep 28, 2022
Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

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

This is great. Thanks!

@maffoo maffoo merged commit cfe1d8b into master Sep 28, 2022
@maffoo maffoo deleted the u/maffoo/circuit-resolve branch September 28, 2022 17:12
pavoljuhas added a commit to dv8081/Cirq that referenced this pull request Nov 19, 2024
Verify if the optimization from quantumlib#5894 is covered by unit tests.
Here we make such test deliberately fail.
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