Skip to content

add gaussian square echo pulse#9370

Merged
nkanazawa1989 merged 56 commits into
Qiskit:mainfrom
miamico:main
May 20, 2023
Merged

add gaussian square echo pulse#9370
nkanazawa1989 merged 56 commits into
Qiskit:mainfrom
miamico:main

Conversation

@miamico
Copy link
Copy Markdown
Contributor

@miamico miamico commented Jan 12, 2023

Summary

Add GaussianSquareEcho symbolic pulse. Similarly to what was done in #9329

Details and comments

The GaussianSquareEcho pulse is comprised of two tones driving the target qubit during the cross-resonance gate. The echoed pulse is a rotary tone while the Gaussian square pulse overlaid on it is a cancellation tone. The pulse shape was introduced in this paper and an example visualization can be found at the bottom panel of figure 7a of this paper (the red and orange curve of the DCX plot).

Open to suggestions for which tests to come up for it.

@miamico miamico requested review from a team, eggerdj and wshanks as code owners January 12, 2023 23:25
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jan 12, 2023
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 12, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@qiskit-bot
Copy link
Copy Markdown
Collaborator

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:

@mtreinish mtreinish added this to the 0.24.0 milestone Jan 13, 2023
@wshanks wshanks removed the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jan 13, 2023
Copy link
Copy Markdown
Contributor

@TsafrirA TsafrirA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @miamico ,
Looks like an interesting addition. While not strictly causing any breakdowns right now, the use of ScalableSymbolicPulse goes against the definition of the class - and might cause problems down the road.
I think there are two options here:

  • Use a general purpose SymbolicPulse instead of ScalableSymbolicPulse.
  • Force the envelope form of ScalableSymbolicPulse on your envelope.

The latter could be done by defining rel_active_amp instead of active_amp and defining the total envelope as: amp*(envelope_expr + rel_active_amp*envelope_expr_xy) (where amp and active_amp are removed from the original expressions).

@nkanazawa1989 could help out here.

Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
@ajavadia ajavadia added the mod: pulse Related to the Pulse module label Jan 20, 2023
@TsafrirA
Copy link
Copy Markdown
Contributor

@miamico
In addition to the stuff we discussed before, you need to make some Lynt corrections, so the CI tests will pass. Check out this page.

You also need to add release notes - check out here, and draw inspiration from @wshanks PR #9329 .

It will also be healthy to add some tests to make sure this pulse functions as expected (Doing this would have caught the incorrect instantiation we had, for example). Check out this test and maybe add to the QPY test here.

Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
@wshanks
Copy link
Copy Markdown
Contributor

wshanks commented Jan 26, 2023

Thanks, @miamico! This is looking good. I put a few comments in. Besides what Tsafrir mentioned, please fill out the CLA form here (linked from the CLAassistant comment above).

@coveralls
Copy link
Copy Markdown

coveralls commented Jan 31, 2023

Pull Request Test Coverage Report for Build 4823142933

  • 35 of 36 (97.22%) changed or added relevant lines in 2 files are covered.
  • 18 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.05%) to 85.85%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/pulse/library/symbolic_pulses.py 34 35 97.14%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 2 91.14%
crates/accelerate/src/sabre_swap/layer.rs 4 97.32%
crates/qasm2/src/parse.rs 12 96.65%
Totals Coverage Status
Change from base Build 4822671868: -0.05%
Covered Lines: 70791
Relevant Lines: 82459

💛 - Coveralls

Copy link
Copy Markdown
Contributor

@nkanazawa1989 nkanazawa1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @miamico this looks almost good to go. IIRC you are doing this because some deployed devices will report DCX pulse in this form. To let them use parametric form, you need to register this pulse name to this enum.
https://github.com/Qiskit/qiskit-terra/blob/d814ad43c81e2b285ea91db4f4bba2234bc2b7db/qiskit/qobj/converters/pulse_instruction.py#L41-L46

Also could you please add unittest in this class?
https://github.com/Qiskit/qiskit-terra/blob/d814ad43c81e2b285ea91db4f4bba2234bc2b7db/test/python/pulse/test_pulse_lib.py#L122
You can find several tests with GaussianSquareDrag for example.

I will approve and merge this PR with these updates.

Comment thread qiskit/pulse/library/symbolic_pulses.py
Comment thread qiskit/pulse/library/symbolic_pulses.py
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
@nkanazawa1989 nkanazawa1989 modified the milestones: 0.24.0, 0.25.0 Apr 12, 2023
@nkanazawa1989
Copy link
Copy Markdown
Contributor

This PR fails in the docs build. See the following Sphinx guide for the literal block formatting.
https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#literal-blocks

(the error message is not really friendly)

@wshanks
Copy link
Copy Markdown
Contributor

wshanks commented Apr 19, 2023

In case it is helpful, here is what I see when I build the docs locally:
image

Copy link
Copy Markdown
Contributor

@wshanks wshanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is some feedback on the doc string. Otherwise this PR looks good to me (except maybe the suggestion to rename amp and angle).

Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
docstring for more details.
width: The duration of the embedded square pulse.
angle: The angle in radians of the complex phase factor uniformly
scaling the pulse. Default value 0.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be clarified that this angle affects only the echoed part of the pulse, not the entire pulse. I would change to amp and angle to echo_amp and echo_angle to put the two parts on equal footing, but I don't feel too strongly about it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to be more specific in the docstring on what refers to what. I'd like to avoid changing variable names as amp and angle are the standard variable names used for other pulses (and one could define a GaussianSquareEcho just by defining these two).

Comment thread qiskit/pulse/library/symbolic_pulses.py
Comment thread qiskit/pulse/library/symbolic_pulses.py
Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
@miamico
Copy link
Copy Markdown
Contributor Author

miamico commented Apr 22, 2023

All checks are passing now

Copy link
Copy Markdown
Contributor

@wshanks wshanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me now. I just had one suggestion.

Comment thread qiskit/pulse/library/symbolic_pulses.py Outdated
Co-authored-by: Will Shanks <wshaos@posteo.net>
wshanks
wshanks previously approved these changes Apr 27, 2023
Copy link
Copy Markdown
Contributor

@wshanks wshanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but I will leave it to @TsafrirA and @nkanazawa1989 to approve and merge!

@miamico
Copy link
Copy Markdown
Contributor Author

miamico commented Apr 27, 2023

great! thanks :)

@wshanks
Copy link
Copy Markdown
Contributor

wshanks commented May 1, 2023

@miamico Sorry about this extra work, but we decided to move forward with the deprecation of the symbolic pulse classes (which are in pending status now) in favor of functions. Could you change all of the GaussianSquareEcho usage to gaussian_square_echo so that this pulse does not need to transition its name later?

Copy link
Copy Markdown
Contributor

@wshanks wshanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two tiny things to change. If those look right to you, we can merge.

Comment thread qiskit/qobj/converters/pulse_instruction.py Outdated
Comment thread releasenotes/notes/gaussian-square-echo-pulse-84306f1a02e2bb28.yaml Outdated
miamico and others added 2 commits May 19, 2023 14:19
Co-authored-by: Will Shanks <wshaos@posteo.net>
….yaml

Co-authored-by: Will Shanks <wshaos@posteo.net>
@miamico
Copy link
Copy Markdown
Contributor Author

miamico commented May 19, 2023

I found two tiny things to change. If those look right to you, we can merge.

Yes totally! I've committed those suggestions :)

Copy link
Copy Markdown
Contributor

@nkanazawa1989 nkanazawa1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This looks good to go. I'll add this to merge queue.

@nkanazawa1989 nkanazawa1989 added this pull request to the merge queue May 20, 2023
Merged via the queue into Qiskit:main with commit bedecbd May 20, 2023
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request May 22, 2023
* add gaussian square echo pulse

* address some PR comments

* fixed parameters of symbolicpulse

* adding math description and reference

* change variable names

* fix lint

* remove width_echo parameter

* fix lint

* add release notes

* fix conflicts

* address some PR comments

* fixed parameters of symbolicpulse

* adding math description and reference

* change variable names

* fix lint

* remove width_echo parameter

* fix lint

* add release notes

* Update first paragraph

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* Update amp param to float

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* Update angle def param to float

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* Update amp constrain

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* drafting tests

* update docstring

* finish up test

* fix missing pulses from init

* addding Cos

* missing sin

* fixed tests

* black formatting

* break string

* fixing strings

* reformatting

* fix lint

* fixing last things

* fix tests

* fix black

* fix another test

* fix amp validation

* fixing docstring

* Update qiskit/pulse/library/symbolic_pulses.py

Co-authored-by: Will Shanks <wshaos@posteo.net>

* rename to gaussian_square_echo

* fix lint

* Update qiskit/qobj/converters/pulse_instruction.py

Co-authored-by: Will Shanks <wshaos@posteo.net>

* Update releasenotes/notes/gaussian-square-echo-pulse-84306f1a02e2bb28.yaml

Co-authored-by: Will Shanks <wshaos@posteo.net>

---------

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
Co-authored-by: Will Shanks <wshaos@posteo.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod: pulse Related to the Pulse module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants