Add phase property to Gate class#3930
Closed
chriseclectic wants to merge 9 commits into
Closed
Conversation
5 tasks
Contributor
|
This should address #3304 |
Closed
a19fd23 to
73de688
Compare
73de688 to
57aea60
Compare
phase property to Gate classphase property to Gate class
These gates current fail control gate tests if they are made to be phase correct since they should have a RZGate in their definition. To avoid these test failures I have reverted them to using a U1Gate in their definition, which gives an incorrect phase on decomposition, but passes the current tests. This should be addressed and fixed in a follow up PR.
jaygambetta
reviewed
May 12, 2020
| rule = [ | ||
| (U3Gate(theta, phi - pi / 2, -phi + pi / 2), [q[0]], []) | ||
| self.definition = [ | ||
| (U3Gate(theta, phi - pi / 2, -phi + pi / 2, phase=self.phase), [q[0]], []) |
Member
There was a problem hiding this comment.
i dont think it is a good idea to make phase change. For R it is defined with phase 0
jaygambetta
reviewed
May 12, 2020
| phase = self.phase - 0.5 * self.params[0] | ||
| self.definition = [ | ||
| (U1Gate(self.params[0], phase=phase), [q[0]], []) | ||
| ] |
Member
There was a problem hiding this comment.
here is where i would make it from a U1 but set it to be a phase that to make it Rz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3304
Summary
phaseproperties toGateclass for storing a gate phaseGate._matrix_definitionfunction to standard gates that returns canonical (phase=0) gateGate.to_matrixto return the matrix definition times the phaseOneQubitEulerDecomposerhave phase-correct synthesisDetails and comments
When constructing a gate a
phasecan be set usingphase=thetakwarg.thetawill be stored as a float[-2*pi, 2*pi]in the gate object, representing a complex coefficientexp(i theta)on the matrix definition of the gate.After construction a gate object can have its phase modified using
gate.phase = theta.When calling
to_matrixthe returned matrix will beexp(i theta) * U_defwhereU_defis the matrix definition of the gate.When unrolling any set phase parameter will be passed to one of the gates in the definition so that the unrolled circuit has the same global phase as the original gate.
Follow up PR work