Fix bug in circuit.insert.#7823
Conversation
Change _group_into_moment_compatible to take into account measurement and control keys.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7823 +/- ##
==========================================
- Coverage 99.57% 99.57% -0.01%
==========================================
Files 1102 1102
Lines 98772 98828 +56
==========================================
+ Hits 98352 98407 +55
- Misses 420 421 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allowing multiple measurements to the same key in the same moment was a requirement from the HW team. Unless that has changed, this would be breaking. |
|
Thank you for pointing this out @daxfohl ! Doesn't this mean this condition here is also wrong: Cirq/cirq-core/cirq/circuits/circuit.py Line 2146 in ceb9432 |
|
Maybe. Though it can't be removed completely, because then it could fall through to earlier moments and break commutativity. (There's a lot of https://xkcd.com/1172/ in the circuit construction code). |
|
cirq-cync - @codrut3 - please create an issue for this PR, e.g., to request that measurement and control keys cannot overlap in the same moment. This would be potentially a breaking change so request feedback from Ilya Drozdov and Christopher Wood for the issue to comment if the current behavior is needed in some situations. |
|
Thank you! I created #7829 |
|
This pull request has been automatically labeled as stale because 90 days have passed without activity. If no further activity occurs and the If you have questions or feedback about this process, please open a new issue in this repository to let us know. You can also send email to the maintainers at quantum-oss-maintainers@google.com. |
Change
_group_into_moment_compatibleto take into account measurement and control keys. Otherwise two incompatible operations can be put in the same moment.I also changed
_can_add_op_atto look at measurement and control keys.I added unit tests that show the issue.