-
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
Create a transformer cancels the effect of Z-phases #6837
Create a transformer cancels the effect of Z-phases #6837
Conversation
*, | ||
context: Optional[transformer_api.TransformerContext] = None, | ||
) -> 'cirq.Circuit': | ||
"""Replace every occurance of a calibrated gate with a proper replacement. |
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.
Maybe a more descriptive docstring?
theta=self.target_as_fsim.theta - delta_theta, | ||
gamma=self.target_as_fsim.gamma - delta_gamma, | ||
phi=self.target_as_fsim.phi - delta_phi, |
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.
theta
and phi
are not z-phases. Can we directly insert the z-rotations that take care of cancelling the phases (just the other three angles)?
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.
theta
andphi
are not z-phases.
yes, but if they were calibrated then it makes sense to change them as well. if they were not calibrated then the delta would be
Can we directly insert the z-rotations that take care of cancelling the phases (just the other three angles)?
we can, I'm okay either way
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.
In order for this to be ready to run on hardware, it would be great if there were at least an option to only cancel the z-phases (not theta and phi) and for this to be implemented as z rotations rather than fSim gates. Thanks, Nour.
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.
ptal
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, thanks, Nour!
Tested in this colab.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6837 +/- ##
==========================================
- Coverage 97.86% 97.86% -0.01%
==========================================
Files 1084 1084
Lines 94013 94093 +80
==========================================
+ Hits 92004 92082 +78
- Misses 2009 2011 +2 ☔ View full report in Codecov by Sentry. |
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, but please see the comments.
angles = np.array(_z_angles(self.target_as_fsim, gate)) / np.pi | ||
angles = -angles # Take the negative to cancel the effect. |
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.
Nit - consider returning pi-normalized np.array tuple from the _z_angles
and perhaps renaming it to _z_powers
.
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 prefer to leave it as it's now ... the contructor of PhasedFSimGate does the normalization
No description provided.