-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add cirq.google.optimized_for_xmon() #647
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
Conversation
This PR is just to keep track of experimentation into how to make the optimizers better I will peel useful sub-PRs off of it until it is a no-op.
- Use same style as EjectZ optimizer - Add with_bits_flipped to MeasurementGate - Fixes to_unitary_matrix ignoring bit flips from measurement gates Fixes #642
…_cleanup # Conflicts: # cirq/google/eject_z.py
# Conflicts: # cirq/google/eject_z.py
…_cleanup # Conflicts: # cirq/circuits/circuit.py # cirq/circuits/optimization_pass.py # cirq/google/eject_full_w.py # cirq/google/eject_z.py
- Slipped by because of a silent merge conflict overwriting updated methods with old ones - The old methods were calling the new "canonicalize_up_to_measurement_phase" with the wrong number of arguments, triggering a type error, triggering a path expecting a type error for a *different reason* (i.e. non-unitary operations in the circuit) - Removed the non-unitary fallback path and renamed the method to make it clear only measurement-implies-terminal circuits were expected - Simplified the W-over-partial-W derivation - Fixed false-positive assertions that were now correctly failing - Added a test that fails for the old behavior but not for the new behavior Fixes #684
- Slipped by because of a silent merge conflict overwriting updated methods with old ones - The old methods were calling the new "canonicalize_up_to_measurement_phase" with the wrong number of arguments, triggering a type error, triggering a path expecting a type error for a *different reason* (i.e. non-unitary operations in the circuit) - Removed the non-unitary fallback path and renamed the method to make it clear only measurement-implies-terminal circuits were expected - Simplified the W-over-partial-W derivation - Fixed false-positive assertions that were now correctly failing - Added a test that fails for the old behavior but not for the new behavior Fixes #684
# Conflicts: # cirq/google/eject_z_test.py
- Updated the cost metric to include presence-of-non-xmon - Converting gates to xmon before returning
# Conflicts: # cirq/google/merge_interactions.py # cirq/google/merge_interactions_test.py Signed-off-by: Craig Gidney <craiggidney@google.com>
…alent - Use it in eject_z_test and eject_full_w_test Fixes #670
# Conflicts: # cirq/google/eject_full_w_test.py # cirq/google/eject_z_test.py
# Conflicts: # cirq/google/merge_rotations_test.py
…_cleanup # Conflicts: # cirq/google/eject_full_w_test.py # cirq/google/eject_z_test.py # cirq/google/xmon_gates.py # cirq/testing/circuit_compare.py
…_cleanup # Conflicts: # cirq/google/merge_interactions.py
|
|
||
| after = cg.optimized_for_xmon(before) | ||
|
|
||
| assert len(after) <= 22 |
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.
Is the optimized length currently 22?
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.
Yes. But I'm happy if it goes down, too.
| before = cirq.Circuit.from_ops( | ||
| cirq.CCZ(cirq.GridQubit(5, 5), | ||
| cirq.GridQubit(5, 6), | ||
| cirq.GridQubit(5, 7))) |
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.
No terminal measurements? Would it be useful to have separate tests for both cases (with measurements and without)?
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.
Intentional.
cduck
left a comment
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.
For example, it decomposes this:
into this:
Obsoletes #488
Obsoletes #644
Obsoletes #645