Skip to content
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

Complete implementation of the permit_mixed_moments option #4342

Merged
merged 5 commits into from Jul 23, 2021

Conversation

mrwojtek
Copy link
Collaborator

This change allows to mix single-qubit and two-qubit operations during calibration. This might be especially useful for creating circuits with spin-echo for example.

@mrwojtek mrwojtek requested review from cduck, vtomole, wcourtney and a team as code owners July 21, 2021 12:10
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Jul 21, 2021
@mrwojtek mrwojtek requested a review from mpharrigan July 21, 2021 12:33
@@ -1022,16 +1049,32 @@ def _make_zeta_chi_gamma_compensation(
new_moment_moment_to_calibration == corrections.moment_to_calibration
), f'Inconsistent decompositions with a moment {moment}'

if other and decompositions:
raise IncompatibleMomentError(f'Moment {moment} contains mixed operations')
if decompositions:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this function is getting rather huge and this logic is rather hairy. Clean up ideas

  1. refactor line 1003--1050 into a helper function so it's clear what the inputs and outputs for this segment is and you can give it a helpful name. Then you can document the meaning of "decompositions" and "other"
  2. otherwise, at least add line comments saying what decompositions and other are
  3. This may result in some duplicated code, but can you factor the four possible values of (bool(decompositions), bool(other)) into four cases or helper functions? the fall-thru logic going on now makes it pretty hard to follow. Once again, helper functions could go a long way to documenting implicitly and explicitly what variables are being set by each block of code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did slightly different which I think makes more sense: I extracted the entire loop into a separate method. WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, this looks nicer. Although Github's diff is having a hard time with it :)

@mrwojtek mrwojtek merged commit 0209c65 into quantumlib:master Jul 23, 2021
@mrwojtek mrwojtek deleted the iswap_with_single_qubit branch July 23, 2021 06:55
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…b#4342)

* Complete implementation of the permit_mixed_moments option

* Fix mypy issues

* Refactor _make_zeta_chi_gamma_compensation

* Fix typing
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.

None yet

2 participants