-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added U1, U2 and U3 deprecation warnings into Circuit Library #8391
Added U1, U2 and U3 deprecation warnings into Circuit Library #8391
Conversation
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this: |
Pull Request Test Coverage Report for Build 2745528462
💛 - Coveralls |
Co-authored-by: Julien Gacon <gaconju@gmail.com>
…mo-Mijares-Vilarino/qiskit-terra into add-u1-u2-u3-deprecation
I don't quite understand what's happening with doc generation. Now, when running
Maybe it has something to do with a new version of |
I believe that problem is fixed in #8392 and is not due to your changes 🙂 |
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.
The overall changes LGTM. I think it would be very nice if the warning directly shows how to replace the gate usage -- at least that's what I would be most interested in! The other relations with more gates might be better kept in the Examples
section?
So it could look something like
.. warning::
... what you have ...
.. code-block:: python
circuit = QuantumCircuit(1)
circuit.p(lambda, 0) # or circuit.u(0, 0, lambda)
and then in the Examples
section add the formulas you added?
While I was moving the formulas to |
Co-authored-by: Julien Gacon <gaconju@gmail.com>
@@ -49,11 +61,24 @@ class U2Gate(Gate): | |||
|
|||
**Examples:** | |||
|
|||
.. math:: | |||
|
|||
U2(\phi,\lambda) = RZ(\phi) RY\left(\frac{\pi}{2}\right) RZ(\lambda) |
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 think this first equivalence with RZ RY RZ misses a global phase, doesn't it?
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 hadn't actually checked that one (trusted it to be correct but seems that was an error on my part 🤦♂️) but you are correct.
U3(\theta, \phi, \lambda) = e^{i \frac{\pi + \theta}{2}} P(\phi + \pi) \sqrt{X} | ||
P(\theta + \pi) \sqrt{X} P(\lambda) |
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.
Also here the global phase doesn't seem to match (or maybe I have a typo!)
>>> decomp = np.exp(0.5j * (np.pi + th)) * np.dot(PhaseGate(phi + np.pi), np.dot(SXGate(), np.dot(PhaseGate(th + np.pi), np.dot(SXGate(), PhaseGate(lam)))))
>>> decomp
array([[-0.53350621-0.71685923j, 0.22160969+0.39034999j],
[ 0.23851082-0.38025854j, 0.56442266-0.69277925j]])
>>> u3 = U3Gate(th, phi, lam).to_matrix()
>>> u3 # matrix doesn't match decomp
array([[ 0.89359724+0.j , -0.44545363-0.05527232j],
[ 0.1626514 +0.41836406j, 0.21878112+0.86640109j]])
>>> Operator(u3).equiv(decomp) # but it is equivalent -- hence a global phase difference exists
True
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.
That's because I forgot to add a minus sign to the global phase 😅. The correct phase is
…mo-Mijares-Vilarino/qiskit-terra into add-u1-u2-u3-deprecation
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.
Thank you for fixing the relations!
Summary
Added a deprecation warning in the circuit library pages of
U1Gate
,U2Gate
andU3Gate
.Details and comments
Along with the warning, I also included some equivalences, most of which are taken from the Summary of Quantum Operators tutorial from Qiskit-tutorials with some corrections.