Skip to content
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

Deprecate QuantumCircuit.u1/2/3 #5083

Merged
merged 98 commits into from
Oct 14, 2020
Merged

Deprecate QuantumCircuit.u1/2/3 #5083

merged 98 commits into from
Oct 14, 2020

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Sep 17, 2020

Summary

Continues on #4106.

Deprecate the methods u1, u2 and u3 of the circuit class. These gates are specific to the IBM hardware and are more commonly known as U-gate, instead of U3, and Phase-gate, instead of U1. The U2 gate has no standard equivalent but is easily created as special case of the U-gate. See below for a list of equivalences.

While the circuit methods are being deprecated the gate objects remain such that it is still possible to transpile down to U1/U2/U3 and retrieve old jobs that use these gates.

Details and comments

Equivalences of the circuit methods:

u1(lam) = p(lam)
u2(phi, lam) = u(phi, lam, pi/2)
u3(theta, phi, lam) = u(theta, phi, lam)

cu1(lam) = cp(lam)
cu3(theta, phi, lam) = cu(theta, phi, lam, 0)  # cu has a 4th parameter for the global phase of the controlled u-gate

mcu1(lam) = mcp(lam)

WIP because the tests still use the methods and are still being updated.

@Cryoris Cryoris added this to the 0.16 milestone Sep 17, 2020
@Cryoris Cryoris requested a review from a team as a code owner September 17, 2020 16:51
@nkanazawa1989
Copy link
Contributor

Please keep a consistency with pulse builder module.
We can write pulse.u1 in the builder context (u2, u3 as well).
https://github.com/Qiskit/qiskit-terra/blob/56a42ce851d2f53cf88fec07d5460cd3c2a589e8/qiskit/pulse/builder.py#L1971-L2049

@ajavadia
Copy link
Member

The reason U1/U2/U3 existed was to have gates corresponding to 0-pulse, 1-pulse, and 2-pulse single-qubit gates. So you have some sense of the cost associated with your circuit.

Now we can do this explicitly with Phase, sqrt(X) and U. So the replacements are:

U1(theta) ---> Phase(theta)  [0 pulse]
U2(phi, lam) ---> Phase(pi/2 + phi) -- sqrt(X) -- Phase(pi/2 + lam)   [1 pulse]
U3(theta, phi, lam)  ---> U(theta, phi, lam)  --->  Phase(phi) -- sqrt(X) -- Phase(theta) -- sqrt(X) -- Phase(lam)  [2 pulse]

Can you make sure to include these decompositions so people know how to transition while keeping the pulse numbers as they were?

ajavadia
ajavadia previously approved these changes Oct 14, 2020
ajavadia
ajavadia previously approved these changes Oct 14, 2020
ajavadia
ajavadia previously approved these changes Oct 14, 2020
@mergify mergify bot merged commit 20c5e15 into Qiskit:master Oct 14, 2020
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Oct 15, 2020
While re-reviewing Qiskit#5083 to find the source of a performance regression
across the board on that commit I noticed that an empty file test.py was
accidently committed to the root of the repo. This commit fixes that
oversight and removes the file.
@mtreinish mtreinish mentioned this pull request Oct 15, 2020
mergify bot pushed a commit that referenced this pull request Oct 15, 2020
While re-reviewing #5083 to find the source of a performance regression
across the board on that commit I noticed that an empty file test.py was
accidently committed to the root of the repo. This commit fixes that
oversight and removes the file.
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Oct 16, 2020
This commit reverts a change made during Qiskit#5083 to use aqua from master
for the tutorials job. This was done to workaround an aqua bug with
a non-u1/u2/u3 basis that was occuring with the 0.7.x release of aqua.
We typically use the released versions of the libraries in these jobs to
catch potentially breaking changes for the biggest users of the terra
api (the other qiskit elements). This restores this coverage by
switching back to using the aqua release for the job.
Cryoris pushed a commit that referenced this pull request Oct 16, 2020
This commit reverts a change made during #5083 to use aqua from master
for the tutorials job. This was done to workaround an aqua bug with
a non-u1/u2/u3 basis that was occuring with the 0.7.x release of aqua.
We typically use the released versions of the libraries in these jobs to
catch potentially breaking changes for the biggest users of the terra
api (the other qiskit elements). This restores this coverage by
switching back to using the aqua release for the job.
mergify bot pushed a commit that referenced this pull request Oct 28, 2020
While re-reviewing #5083 to find the source of a performance regression
across the board on that commit I noticed that an empty file test.py was
accidently committed to the root of the repo. This commit fixes that
oversight and removes the file.

(cherry picked from commit 95ccac9)
mergify bot pushed a commit that referenced this pull request Oct 28, 2020
This commit reverts a change made during #5083 to use aqua from master
for the tutorials job. This was done to workaround an aqua bug with
a non-u1/u2/u3 basis that was occuring with the 0.7.x release of aqua.
We typically use the released versions of the libraries in these jobs to
catch potentially breaking changes for the biggest users of the terra
api (the other qiskit elements). This restores this coverage by
switching back to using the aqua release for the job.

(cherry picked from commit cac869d)
mergify bot added a commit that referenced this pull request Oct 28, 2020
While re-reviewing #5083 to find the source of a performance regression
across the board on that commit I noticed that an empty file test.py was
accidently committed to the root of the repo. This commit fixes that
oversight and removes the file.

(cherry picked from commit 95ccac9)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
mergify bot added a commit that referenced this pull request Oct 29, 2020
This commit reverts a change made during #5083 to use aqua from master
for the tutorials job. This was done to workaround an aqua bug with
a non-u1/u2/u3 basis that was occuring with the 0.7.x release of aqua.
We typically use the released versions of the libraries in these jobs to
catch potentially breaking changes for the biggest users of the terra
api (the other qiskit elements). This restores this coverage by
switching back to using the aqua release for the job.

(cherry picked from commit cac869d)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Deprecation Include in "Deprecated" section of changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants