Skip to content

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

Merged
maffoo merged 2 commits intomasterfrom
u/maffoo/circuit-resolve
Sep 28, 2022
Merged

Optimize circuit/moment resolution to reuse instances if possible#5894
maffoo merged 2 commits intomasterfrom
u/maffoo/circuit-resolve

Conversation

@maffoo
Copy link
Copy Markdown
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, cduck and vtomole 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
Copy Markdown
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