-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Speed up cirq.map_operations
and cirq.map_operations_and_unroll
#6250
Speed up cirq.map_operations
and cirq.map_operations_and_unroll
#6250
Conversation
cirq.map_operations
and cirq.map_operations_and_unroll
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #6250 +/- ##
=======================================
Coverage 97.60% 97.60%
=======================================
Files 1116 1116
Lines 95768 95848 +80
=======================================
+ Hits 93476 93556 +80
Misses 2292 2292
☔ View full report in Codecov by Sentry. |
could you explain the change in the description? also what is happening with the mypy script? |
@NoureldinYosri Added a detailed description and the change to mypy script was a mistake so I've reverted it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. just a few nits and documentation
…d_up_transformers
…d_up_transformers
…uantumlib#6250) * Speed up cirq.map_operations and cirq.map_operations_and_unroll * Mypy typing and minor bug fixes * Fix pylint * Revert unrelated change to mypy script * Address nits
Fixes #6173
Part of #6097
This leads to a roughly
~4-5x
improvement in performance forcirq.map_operations
andcirq.map_operations_and_unroll
. See #6173 (comment) for a detailed use-case specific analysis.The primary reason behind the speedup is to get rid of repeated instantiations of
cirq.Circuit
, which was being done for once for every call tomap_func(op, i)
. The intermediate circuits were constructed mainly for circuit alignment. This PR instead uses the circuit construction strategy similar to the one used inCirq/cirq-core/cirq/circuits/circuit.py
Line 1760 in 95c672a
cirq.Circuit
constructor only once at the end.