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

Issue 3750 wrap up #4034

Merged
merged 34 commits into from
Apr 2, 2020
Merged

Issue 3750 wrap up #4034

merged 34 commits into from
Apr 2, 2020

Conversation

lcapelluto
Copy link
Contributor

@lcapelluto lcapelluto commented Mar 27, 2020

Summary

Closes #3750

Details and comments

Minor API changes

  • operands returns a tuple rather than a list (better type hints)
  • add id for insts and pulses and make default name None

Bug fix

  • fix __repr__ bug for Discriminator and Kernel config

Docs

  • Overall improved pulse documentation

Misc / implementation changes

  • clean up magic methods and their inheritance for Pulse+subclasses and Instruction+subclasses
  • PulseCommand class wasn't used anywhere so I removed the file :D

Tests

  • test_instructions.py: New instruction tests and migrate Acquire tests
  • new file test_pulse_lib.py: Move tests for ParametricPulses and SamplePulse to this since they are no longer Commands
  • update tests to migrate to new pattern or use self.assertWarns(DeprecationWarning) to catch test warnings
  • add a few tests throughout (e.g. test_assembler)

Clean up magic methods (move most into Instructions), operands returns a tuple rather than a list, fix bug in kernel and discriminator repr, general clean up of Instructions

Cannot deprecate commands attribute on Instructions directly, since it must be used in the assembler. It will be easy to deprecate and remove in a few months

Update documentation and fixup an operands test

fix indentation in instructions init
@DanPuzzuoli DanPuzzuoli self-assigned this Mar 30, 2020
@lcapelluto lcapelluto added this to the 0.13 milestone Mar 30, 2020
Remove deprecation warnings from schedule tests

Remove warnings from assembler

Remove or catch deprecation warnings from qobj tests

Fixup style in assembler tests

Migrate scheduler tests to new pulse style
Copy link
Contributor

@DanPuzzuoli DanPuzzuoli left a comment

Choose a reason for hiding this comment

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

Aside from the minor comments I made, looks good to me! I really like the changes.

qiskit/pulse/instructions/frequency.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/frequency.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/frequency.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/frequency.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/play.py Outdated Show resolved Hide resolved
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.

Almost ready!

qiskit/pulse/instruction_schedule_map.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/__init__.py Outdated Show resolved Hide resolved
"""Return a list of instruction operands."""
return [self.duration, self.channel,
self.mem_slot, self.reg_slot]
def operands(self) -> Tuple[int, AcquireChannel, MemorySlot, RegisterSlot]:
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be limited to one of MemorySlot or RegisterSlot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't seen that restriction anywhere else, what does that stem from? I've seen tests with acquire taking memslot and reg slot. No one uses register slots yet, so it's possible they're not handled correctly in a couple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can users not use readout results for fast feedback and also get that result?

Copy link
Contributor

@taalexander taalexander Apr 2, 2020

Choose a reason for hiding this comment

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

It will be a practical restriction in the hardware. In reality it would be something like

  1. acquire qubit into register
  2. store register into memory

Storing directly into a memory_slot is currently supported but is a convenience that masks hardware implementation. I would like to get away from multi-purpose instructions and I think this is a good first step that can be made while we are already changing the interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so Acquire should really only take a register slot. This seems like an implementation change that is out of scope for this PR. Maybe next sprint?

Copy link
Contributor

Choose a reason for hiding this comment

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

Will we be able to make the change before release?

qiskit/pulse/instructions/delay.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/frequency.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/pulse_lib/pulse.py Outdated Show resolved Hide resolved
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.

Please see my comment about names and operands as well.

qiskit/pulse/instructions/play.py Outdated Show resolved Hide resolved
Copy link
Contributor

@DanPuzzuoli DanPuzzuoli left a comment

Choose a reason for hiding this comment

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

One tiny comment.

qiskit/pulse/instructions/play.py Outdated Show resolved Hide resolved
DanPuzzuoli
DanPuzzuoli previously approved these changes Apr 1, 2020
taalexander
taalexander previously approved these changes Apr 2, 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.

Two minor suggestions. Not blocking!

qiskit/pulse/commands/acquire.py Outdated Show resolved Hide resolved
qiskit/pulse/instructions/instruction.py Outdated Show resolved Hide resolved
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

@mergify mergify bot merged commit d06f5bf into Qiskit:master Apr 2, 2020
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
* Clean up instructions and update documentation

Clean up magic methods (move most into Instructions), operands returns a tuple rather than a list, fix bug in kernel and discriminator repr, general clean up of Instructions

Cannot deprecate commands attribute on Instructions directly, since it must be used in the assembler. It will be easy to deprecate and remove in a few months

Update documentation and fixup an operands test

fix indentation in instructions init

* Documentation improvements, add 'name=' to Instruction repr

* Fixup description of operands (does not return a list now, returns a tuple)

* Clean up magic methods for Pulse and its subclasses

* Add more tests for instructions and move Pulse tests into a new pulse_lib testing file

* Give instructions an ID. Give instructions a simple default name if one isn't provided. Add tests

* Give pulses ids too

* fixup some documentation and style

* Fixup name printing of pulses: Display names are not auto generated. Test that deprecation warnings are printed for command tests

* Remove deprecation warnings from reschedule

Remove deprecation warnings from schedule tests

Remove warnings from assembler

Remove or catch deprecation warnings from qobj tests

Fixup style in assembler tests

Migrate scheduler tests to new pulse style

* Try to fix missing docs links

* Hide full path of module in autosum

* Add an autosummary to the pulse lib init file for api ref

* Apply suggestions from code review

Co-Authored-By: Thomas Alexander <thomasalexander2718@gmail.com>
Co-Authored-By: Daniel Puzzuoli <dan.puzzuoli@gmail.com>

* Fixup style errors that I introduced during review

* Cannot use 'Pulse' type hint from 'Play' due to cyclic import while deprecating __call__, so use docstring type hinting instead

* Respond to feedback: improve documentation about instruction operands

* Upgrade to threadsafe ids for Pulse and Instruction: no longer is the id the order that they were instantiated (which is not necessary for this purpose)

* Fixup style (ignore id is not a valid name)

* No display name if it is not provided by the user

* Update qiskit/pulse/instructions/play.py

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

* Update tests and instruction repr for None default name

* Style fix

* Update qiskit/pulse/instructions/play.py

Co-Authored-By: Daniel Puzzuoli <dan.puzzuoli@gmail.com>

* Remove danp's trailing whitespace :D

* PulseCommand is not used anywhere now and can be removed

* Improve deprecation messaging for pulses being called

* Include operands as the first argument to Instruction

* Fixup docs error

* Make Instruction  init arg take a tuple rather than a list

Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com>
Co-authored-by: Daniel Puzzuoli <dan.puzzuoli@gmail.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
mod: pulse Related to the Pulse module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify pulse Commands and Instructions
4 participants