-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix conjugated_by of PauliString. #7065
Conversation
def _has_stabilizer_effect_(self) -> Optional[bool]: | ||
if self._is_parameterized_(): | ||
return None | ||
return self.exponent % 1 == 0 |
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.
ISwapPow gate need to have _has_stabilizer_effect_
method just like SwapPowGate, fix it here, otherwise, unit tests would fail in pauli_string_test.py.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7065 +/- ##
==========================================
- Coverage 98.17% 98.15% -0.02%
==========================================
Files 1089 1089
Lines 95177 95253 +76
==========================================
+ Hits 93438 93494 +56
- Misses 1739 1759 +20 ☔ View full report in Codecov by Sentry. |
77f1722
to
a39e761
Compare
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.
@babacry overall looks good%nits
@@ -377,7 +377,10 @@ def __init__(self, *, _clifford_tableau: qis.CliffordTableau) -> None: | |||
# ZI [ 0 0 | 1 0 | 1 ] | |||
# IZ [ 1 0 | 1 1 | 0 ] | |||
# Take the third row as example: this means the ZI gate after the this gate, | |||
# more precisely the conjugate transformation of ZI by this gate, becomes -ZI. | |||
# more precisely the conjugate transformation of ZI by this gate, becomes -ZI: |
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 this needed?
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.
Conjugation definitions are not uniform in Cirq, it turns out the conjugation definition here is opposite with the conjugation definition in PauliString.conjugated_by.
Here, in CliffordGate, in terms of matrix conjugation it is ---C^{-1}----P-----C
.
In PauliString, the definition in terms of matrix conjugation is -----C----P------C^{-1}
.
Thus I added comments here to clarify the difference.
Thanks Nour for the inputs! Updated. PTAL. |
Rewrite PauliString.conjugated_by.
Context: previous conjugated_by relies on decompose_into_cliffords which crashes in for some cliffords: #6946.
Followup: note
pass_operations_over()
andinplace_after()
still rely on_decompose_into_cliffords_
and_pass_operation_over_
, I will clean them up in the followup PRs. (tried to clean them up in the same pr, but too many nit updates are needed in both the class itself and the tests)