Create a transformer that cancels the effect of Z-phases#6837
Create a transformer that cancels the effect of Z-phases#6837NoureldinYosri merged 15 commits intoquantumlib:mainfrom
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.
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.
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.
thetaandphiare 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.
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.
eliottrosenberg
left a comment
There was a problem hiding this comment.
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. |
pavoljuhas
left a comment
There was a problem hiding this comment.
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.
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.
I prefer to leave it as it's now ... the contructor of PhasedFSimGate does the normalization
No description provided.