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

Command/Inst refactor: Pulses and Play #3936

Merged
merged 49 commits into from
Mar 25, 2020

Conversation

lcapelluto
Copy link
Contributor

@lcapelluto lcapelluto commented Mar 6, 2020

Summary

Part 6/7 for issue #3750

Migrate commands to instructions, migrate waveforms to pulse_lib

Details and comments

Deprecate PulseCommands, create new Play Instruction-implementation. The Play instruction takes a Pulse and a PulseChannel. Pulse is a new class within the pulse library that is very close to the deprecated PulseCommand abstract class. The PulseCommand implementations (SamplePulse and the ParametricPulse subclasses) have been moved to the pulse library as well, subclassing from Pulse, and all valid arguments to Play.

TODO

  • pulses also need to have names
  • assemble_schedules needs to handle Play
  • pulse_instruction needs to handle Play
  • Playtests

…The Play instruction takes a Pulse and a PulseChannel. Pulse is a new class within the pulse library that is very close to the deprecated PulseCommand abstract class. The PulseCommand implementations (SamplePulse and the ParametricPulse subclasses) have been moved to the pulse library as well, subclassing from Pulse, and all valid arguments to Play.
@lcapelluto lcapelluto marked this pull request as ready for review March 13, 2020 20:42
Copy link
Contributor

@taalexander taalexander left a comment

Choose a reason for hiding this comment

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

A couple of comments.

qiskit/pulse/pulse_lib/parametric_pulses.py Show resolved Hide resolved
qiskit/pulse/pulse_lib/parametric_pulses.py Show resolved Hide resolved
qiskit/pulse/pulse_lib/parametric_pulses.py Show resolved Hide resolved
qiskit/pulse/pulse_lib/parametric_pulses.py Show resolved Hide resolved
from ..instructions.play import Play


class Pulse(ABC):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more akin to a Type, do you think it should live in a types module along with Kernel and Discriminator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's an interesting idea, I definitely like the idea of keeping simple, basic, "type-like" objects together and out of the way. For now, I think this does make the most sense. Once __call__ is removed (since it's sort of un-type-like) and this command->instruction thing is done, we should work on another organizational refactor, including this idea.

@lcapelluto lcapelluto changed the title Command/Inst refactor: Pulses Command/Inst refactor: Pulses and Play Mar 24, 2020
@lcapelluto lcapelluto closed this Mar 25, 2020
@lcapelluto
Copy link
Contributor Author

my mistake

@lcapelluto lcapelluto reopened this Mar 25, 2020
eggerdj
eggerdj previously approved these changes Mar 25, 2020
Copy link
Contributor

@eggerdj eggerdj left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

LGTM, just a quick question and a nit in the release notes

description must subclass from :py:class:`~qiskit.pulse.pulse_lib.Pulse`.
py:class:`~qiskit.pulse.pulse_lib.SamplePulse` and
py:class:`~qiskit.pulse.pulse_lib.ParametricPulse` s (e.g. ``Gaussian``)
now subclass from ``Pulse`` and have been moved to the ``pulse_lib``.
Copy link
Member

Choose a reason for hiding this comment

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

This was a bit hard to follow, Originally I thought this should have been the pulse description should either be Pulse, SamplePulse, or ParametricPulse. But then I realized what it was actually saying. Maybe we should split this into 2 release notes. One saying that SamplePulse and ParametricPulse are now subclasses of Pulse and have been moved to pulse_lib (maybe as an upgrade note?) and the other about Play.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good idea, thank you!

…a29d3.yaml

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the quick updates

Copy link
Contributor

@eggerdj eggerdj left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot merged commit 70c5249 into Qiskit:master Mar 25, 2020
@lcapelluto lcapelluto added API affects user-facing API change Changelog: API Change Include in the "Changed" section of the changelog and removed API affects user-facing API change labels Apr 1, 2020
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
* Deprecate PulseCommands, create new Play Instruction-implementation. The Play instruction takes a Pulse and a PulseChannel. Pulse is a new class within the pulse library that is very close to the deprecated PulseCommand abstract class. The PulseCommand implementations (SamplePulse and the ParametricPulse subclasses) have been moved to the pulse library as well, subclassing from Pulse, and all valid arguments to Play.

* Update import statements in Pulse

* Fill in the implementation of some IP work like __call__

* Fill in and update documentation, complete import paths

* fixup cyclic imports

* IP updates to assemble_schedules for supporting Play instruction

* Give all pulses a name arg and update reno note

* Continue pulse_instruction conversion support for Play

* Add support for Play in assemble schedules, fix style

* Attempt to fix build error

* Add missing name field to Constant pulse

* To support __call__ from Pulse, I need to import Play, which means I can't import Pulse from Play (for typehints) for the timebeing

* Fixup bugs introduced in SamplePulse

* Update tests with new API

* Add tests and fixup missing name passing

* Fixup tests, remove deprecation warning from assemble execution, add hash and eq methods to pulses

* Fixup docs

* Update functional_pulse import path and Instruction type ref

* try again with the type hints

* Was missing updates to PulseCommand that needed to be migrated with the new Pulse class

* Was missing docstring type documentation for unresolvable type

* Was missing removal of PulseStyle in parametric pulses

* The changes from the sphinx warrnings pass hadn't been moved with the migrated ParametricPulses module. Moved the drag pulse docstring over finally

* Fix spacing in drag pulse docstring

* The docs should finally build now

* Update qiskit/pulse/instructions/play.py

Co-Authored-By: eggerdj <38065505+eggerdj@users.noreply.github.com>

* Update qiskit/pulse/pulse_lib/sample_pulse.py

Co-Authored-By: eggerdj <38065505+eggerdj@users.noreply.github.com>

* Apply suggestions from code review

Co-Authored-By: eggerdj <38065505+eggerdj@users.noreply.github.com>

* Documentation improvements

* Test change because linux python35 is failing

* Update releasenotes/notes/unify-instructions-and-commands-aaa6d8724b8a29d3.yaml

Co-Authored-By: eggerdj <38065505+eggerdj@users.noreply.github.com>

* Fix plotting Play instruction

* style, line length

* Attempt to fix failing test by comparing names directly

* Handle all instruction types in add_instruction

* Remove unused import

* Update releasenotes/notes/unify-instructions-and-commands-aaa6d8724b8a29d3.yaml

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>

* Separate note about Play feature into two notes: Play feature and Pulse movement

Co-authored-by: eggerdj <38065505+eggerdj@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@1ucian0 1ucian0 added the mod: pulse Related to the Pulse module label Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the "Changed" section of the changelog mod: pulse Related to the Pulse module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants