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
Conversation
@@ -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: |
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.
this function is getting rather huge and this logic is rather hairy. Clean up ideas
- 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"
- otherwise, at least add line comments saying what decompositions and other are
- 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.
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.
I did slightly different which I think makes more sense: I extracted the entire loop into a separate method. WDYT?
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, this looks nicer. Although Github's diff is having a hard time with it :)
…b#4342) * Complete implementation of the permit_mixed_moments option * Fix mypy issues * Refactor _make_zeta_chi_gamma_compensation * Fix typing
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.