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/Instruction unification #3862

Merged

Conversation

lcapelluto
Copy link
Contributor

@lcapelluto lcapelluto commented Feb 18, 2020

Summary

First part of #3750

Begin command and instruction unification within Pulse. Instructions will migrate into the new instructions submodule of pulse. This begins by moving only the Instruction class. The Instruction command attribute is deprecated in favor of operands, and references to commands are updated.

This is the first of a series of 7 (anticipated) PRs to implement this migration. All other PRs depend on this one.

TODO:

  • Get details from Thomas about operands
  • Release notes

Details and comments

https://github.com/Qiskit/rfcs/pull/12/files?short_path=990963a#diff-990963ad1ab66f8d85311258e904239a

For the reviewer: I made comments near the functions in instructions.py that are altered from the original file.

…will migrate into the new instructions submodule of pulse. This begins by moving only the Instruction class. The Instruction ``command`` attribute is deprecated in favor of ``operands``, and references to commands are updated.
@lcapelluto lcapelluto force-pushed the issue-3750-unify-commands-and-instructions branch from ebccc75 to 409d94b Compare February 18, 2020 21:39
@lcapelluto lcapelluto assigned ajavadia and unassigned ajavadia Feb 19, 2020
… now just 'duration', and any other operands only exist for an instruction instance
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.

This is looking good! I've noted a couple of things I might change, but I am of course open to discussion 😄 .

qiskit/pulse/instructions/__init__.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/__init__.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/__init__.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/instruction.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/instruction.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/instruction.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/instruction.py Show resolved Hide resolved
qiskit/pulse/instructions/instruction.py Outdated Show resolved Hide resolved
lcapelluto and others added 2 commits February 20, 2020 09:02
Co-Authored-By: Thomas Alexander <thomasalexander2718@gmail.com>
taalexander
taalexander previously approved these changes Feb 25, 2020
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.

LGTM! A good start! Looking forward to seeing the rest.

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 some comments from a quick skimming of the release notes

@@ -0,0 +1,22 @@
---
prelude: >
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be either feature or upgrade (probably feature)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My idea was this one prelude message and then the following 6 PRs would be a list of upgrades with specific details, for example DelayInstruction(Delay(time), channel) => Delay(time, channel)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I'll defer to your opinion

There has been a significant simplification to the style in which Pulse
instructions are built.

With the previous style, ``Command`` s were called with channels to make
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to use:

Suggested change
With the previous style, ``Command`` s were called with channels to make
With the previous style, :class:`qiskit.pulse.Command`s were called with channels to make

here and in other places were you reference a class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not for Command because it wants to disappear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instruction should though

mtreinish
mtreinish previously approved these changes Feb 25, 2020
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 updating the release note

taalexander
taalexander previously approved these changes Feb 25, 2020
@taalexander taalexander added this to To do in Pulse via automation Feb 25, 2020
…om:lcapelluto/qiskit-terra into issue-3750-unify-commands-and-instructions
@mergify mergify bot merged commit 12b07bc into Qiskit:master Feb 26, 2020
Pulse automation moved this from To do to Done Feb 26, 2020
@lcapelluto lcapelluto added the Changelog: API Change Include in the "Changed" section of the changelog label Apr 1, 2020
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
* Begin command and instruction unification within Pulse. Instructions will migrate into the new instructions submodule of pulse. This begins by moving only the Instruction class. The Instruction ``command`` attribute is deprecated in favor of ``operands``, and references to commands are updated.

* Remove deprecation warning from commands/instruction.py because the commands/__init__ can have a deprecation warning after the rest is implemented

* Revert commands/__init__ because changes there are not necessary.

* Fill in first positional argument in instruction. What was command is now just 'duration', and any other operands only exist for an instruction instance

* Continue adding documentation and notes

Fix up hash function

* Fix type hint from List[Channel] to Channel

* Update repr to match new init signature

* Update qiskit/pulse/instructions/__init__.py

Co-Authored-By: Thomas Alexander <thomasalexander2718@gmail.com>

* Update init file for the instruction module to be more clear about the operands

* Make Instruction an ABC

* update instruction comment

* Update docs

* Update year in copyright header

* Revert Instruction as ABC because the Instructions which haven't been migrated yet do not support the abstractmethods

* Update __eq__ to support both styles until migration is complete

* Update __hash__ to support both styles until migration is complete

* Fixup style

* Update TODO comment

* Use self.command instead of init arg  if the first arg is a command, for readability

* Make repr unchanged for nonmigrated commands

* Small bugfix

* Update instructions documentation

* Relax requirement for channel operand

* API reference to Instruction in release notes

* Fix releasenote

* Silly reno style

Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com>
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
No open projects
Pulse
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants