Skip to content

Conversation

@Strilanc
Copy link
Contributor

@Strilanc Strilanc commented Jul 12, 2018

  • This is an all-in-one method for producing xmon-optimized circuits.

For example, it decomposes this:

0: ───iSwap───────────iSwap───M───
      │               │       │
1: ───iSwap───iSwap───iSwap───M───
              │               │
2: ───iSwap───iSwap───iSwap───M───
      │               │       │
3: ───iSwap───────────iSwap───M───

into this:

0: ───W(0.25)^-0.5───@───W(0.25)^0.5────@───W(0.75)^0.5──────────────────────────────────────────@───W(0.25)^-0.5───@───W(0.25)^0.5────M───
                     │                  │                                                        │                  │                  │
1: ───W(0.25)^0.5────@───W(0.25)^-0.5───@───W(0.75)^0.5────@───W(0.25)^0.5────@───W(0.75)^-0.5───@───W(0.25)^-0.5───@───W(0.25)^0.5────M───
                                                           │                  │                                                        │
2: ───W(0.25)^-0.5───@───W(0.25)^0.5────@───W(0.75)^-0.5───@───W(0.25)^-0.5───@───W(0.75)^0.5────@───W(0.25)^0.5────@───W(0.25)^-0.5───M───
                     │                  │                                                        │                  │                  │
3: ───W(0.25)^0.5────@───W(0.25)^-0.5───@───W(0.75)^-0.5─────────────────────────────────────────@───W(0.25)^0.5────@───W(0.25)^-0.5───M───

Obsoletes #488
Obsoletes #644
Obsoletes #645

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.
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Jul 12, 2018
Strilanc added 28 commits July 14, 2018 19:42
- 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
Strilanc added 5 commits July 17, 2018 01:50
# Conflicts:
#	cirq/google/eject_full_w_test.py
#	cirq/google/eject_z_test.py
# Conflicts:
#	cirq/google/merge_rotations_test.py
@Strilanc Strilanc changed the title [WIP] optimization playground [AFTER #699, #696, #695, #691] Add cirq.google.optimized_for_xmon() Jul 17, 2018
@Strilanc Strilanc changed the title [AFTER #699, #696, #695, #691] Add cirq.google.optimized_for_xmon() [AFTER #700, #699, #696, #695, #691] Add cirq.google.optimized_for_xmon() Jul 17, 2018
@Strilanc Strilanc requested review from cduck and dabacon July 17, 2018 17:51
@Strilanc Strilanc changed the title [AFTER #700, #699, #696, #695, #691] Add cirq.google.optimized_for_xmon() [AFTER #696] Add cirq.google.optimized_for_xmon() Jul 17, 2018
Strilanc added 2 commits July 17, 2018 16:15
…_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
@Strilanc Strilanc changed the title [AFTER #696] Add cirq.google.optimized_for_xmon() Add cirq.google.optimized_for_xmon() Jul 18, 2018

after = cg.optimized_for_xmon(before)

assert len(after) <= 22
Copy link
Collaborator

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?

Copy link
Contributor Author

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)))
Copy link
Collaborator

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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intentional.

Copy link
Collaborator

@cduck cduck left a comment

Choose a reason for hiding this comment

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

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Makes googlebot stop complaining.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants