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
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
5ae572a
Deprecate PulseCommands, create new Play Instruction-implementation. …
lcapelluto Feb 20, 2020
3433240
Update import statements in Pulse
lcapelluto Mar 9, 2020
a007339
Merge remote-tracking branch 'upstream/master' into issue-3750-pulses
lcapelluto Mar 11, 2020
2a71ffa
Fill in the implementation of some IP work like __call__
lcapelluto Mar 11, 2020
ba918a6
Merge remote-tracking branch 'upstream/master' into issue-3750-pulses
lcapelluto Mar 13, 2020
9bbc01f
Fill in and update documentation, complete import paths
lcapelluto Mar 13, 2020
c5b0741
fixup cyclic imports
lcapelluto Mar 13, 2020
780e5f8
IP updates to assemble_schedules for supporting Play instruction
lcapelluto Mar 16, 2020
d4418e3
Give all pulses a name arg and update reno note
lcapelluto Mar 16, 2020
66d2a25
Continue pulse_instruction conversion support for Play
lcapelluto Mar 16, 2020
646529c
Add support for Play in assemble schedules, fix style
lcapelluto Mar 16, 2020
4bfe424
Merge remote-tracking branch 'upstream/master' into issue-3750-pulses
lcapelluto Mar 16, 2020
6104e88
Attempt to fix build error
lcapelluto Mar 17, 2020
67ab1b4
Add missing name field to Constant pulse
lcapelluto Mar 17, 2020
36134c2
To support __call__ from Pulse, I need to import Play, which means I …
lcapelluto Mar 17, 2020
b8f73e6
Merge remote-tracking branch 'upstream/master' into issue-3750-pulses
lcapelluto Mar 18, 2020
efbbd17
Fixup bugs introduced in SamplePulse
lcapelluto Mar 18, 2020
33c8da4
Update tests with new API
lcapelluto Mar 18, 2020
8739997
Add tests and fixup missing name passing
lcapelluto Mar 19, 2020
f1ed9ed
Merge remote-tracking branch 'upstream/master' into issue-3750-pulses
lcapelluto Mar 19, 2020
0bed2c2
Fixup tests, remove deprecation warning from assemble execution, add …
lcapelluto Mar 19, 2020
dc1d42d
Fixup docs
lcapelluto Mar 19, 2020
e7facb3
Update functional_pulse import path and Instruction type ref
lcapelluto Mar 19, 2020
f719a86
Merge remote-tracking branch 'upstream/master' into issue-3750-pulses
lcapelluto Mar 19, 2020
cbefe8a
try again with the type hints
lcapelluto Mar 19, 2020
98169f3
Was missing updates to PulseCommand that needed to be migrated with t…
lcapelluto Mar 19, 2020
74ada9b
Was missing docstring type documentation for unresolvable type
lcapelluto Mar 19, 2020
a889e47
Was missing removal of PulseStyle in parametric pulses
lcapelluto Mar 19, 2020
16278c0
The changes from the sphinx warrnings pass hadn't been moved with the…
lcapelluto Mar 19, 2020
14fc973
Fix spacing in drag pulse docstring
lcapelluto Mar 19, 2020
3d9efd8
The docs should finally build now
lcapelluto Mar 20, 2020
d753a45
Update qiskit/pulse/instructions/play.py
lcapelluto Mar 23, 2020
e05c937
Update qiskit/pulse/pulse_lib/sample_pulse.py
lcapelluto Mar 23, 2020
30a517d
Apply suggestions from code review
lcapelluto Mar 23, 2020
c2ecd3d
Documentation improvements
lcapelluto Mar 23, 2020
4fe635d
Merge remote-tracking branch 'upstream/master' into issue-3750-pulses
lcapelluto Mar 23, 2020
8430aec
Test change because linux python35 is failing
lcapelluto Mar 23, 2020
c1c64a3
Update releasenotes/notes/unify-instructions-and-commands-aaa6d8724b8…
lcapelluto Mar 24, 2020
1abc77c
Merge branch 'master' into issue-3750-pulses
lcapelluto Mar 24, 2020
85988f2
Fix plotting Play instruction
lcapelluto Mar 24, 2020
dcc4c90
style, line length
lcapelluto Mar 24, 2020
5d1fb84
Attempt to fix failing test by comparing names directly
lcapelluto Mar 24, 2020
873e5a1
Handle all instruction types in add_instruction
lcapelluto Mar 25, 2020
2c73613
Remove unused import
lcapelluto Mar 25, 2020
e53f42e
Merge branch 'master' into issue-3750-pulses
lcapelluto Mar 25, 2020
e41082a
Update releasenotes/notes/unify-instructions-and-commands-aaa6d8724b8…
lcapelluto Mar 25, 2020
0e0c142
Separate note about Play feature into two notes: Play feature and Pul…
lcapelluto Mar 25, 2020
8de5dfb
Merge branch 'issue-3750-pulses' of github.com:lcapelluto/qiskit-terr…
lcapelluto Mar 25, 2020
c654bd3
Merge branch 'master' into issue-3750-pulses
mergify[bot] Mar 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions qiskit/assembler/assemble_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from typing import Any, Dict, List, Tuple

from qiskit.exceptions import QiskitError
from qiskit.pulse import Schedule, Delay
from qiskit.pulse import Schedule, Delay, Play
from qiskit.pulse.pulse_lib import ParametricPulse
from qiskit.pulse.commands import (Command, PulseInstruction, Acquire, AcquireInstruction,
DelayInstruction, SamplePulse, ParametricInstruction)
from qiskit.qobj import (PulseQobj, QobjHeader, QobjExperimentHeader,
Expand Down Expand Up @@ -170,15 +171,31 @@ def _assemble_instructions(
acquire_instruction_map = defaultdict(list)
for time, instruction in schedule.instructions:

if isinstance(instruction, ParametricInstruction):
if isinstance(instruction, Play) and isinstance(instruction.pulse, ParametricPulse):
pulse_shape = ParametricPulseShapes(type(instruction.pulse)).name
if pulse_shape not in run_config.parametric_pulses:
instruction = Play(instruction.pulse.get_sample_pulse(),
instruction.channel,
name=instruction.name)

if isinstance(instruction, ParametricInstruction): # deprecated
pulse_shape = ParametricPulseShapes(type(instruction.command)).name
if pulse_shape not in run_config.parametric_pulses:
# Convert to SamplePulse if the backend does not support it
instruction = PulseInstruction(instruction.command.get_sample_pulse(),
instruction.channels[0],
name=instruction.name)

if isinstance(instruction, PulseInstruction):
if isinstance(instruction, Play) and isinstance(instruction.pulse, SamplePulse):
name = instruction.pulse.name
if instruction.pulse != user_pulselib.get(name):
lcapelluto marked this conversation as resolved.
Show resolved Hide resolved
name = "{0}-{1:x}".format(name, hash(instruction.pulse.samples.tostring()))
instruction = Play(SamplePulse(name=name, samples=instruction.pulse.samples),
channel=instruction.channel,
name=instruction.name)
user_pulselib[name] = instruction.pulse

if isinstance(instruction, PulseInstruction): # deprecated
name = instruction.command.name
if name in user_pulselib and instruction.command != user_pulselib[name]:
name = "{0}-{1:x}".format(name, hash(instruction.command.samples.tostring()))
Expand Down
11 changes: 4 additions & 7 deletions qiskit/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,12 @@
from .channels import (DriveChannel, MeasureChannel, AcquireChannel,
ControlChannel, RegisterSlot, MemorySlot)
from .cmd_def import CmdDef
from .commands import (Acquire, AcquireInstruction, FrameChange,
PersistentValue, SamplePulse, Kernel,
Discriminator, ParametricPulse,
ParametricInstruction, Gaussian,
GaussianSquare, Drag, ConstantPulse, functional_pulse)
from .commands import (Acquire, AcquireInstruction, FrameChange, PersistentValue, Kernel,
Discriminator, functional_pulse)
from .configuration import LoConfig, LoRange
from .exceptions import PulseError
from .instruction_schedule_map import InstructionScheduleMap

from .instructions import Instruction, Delay, ShiftPhase, Snapshot, SetFrequency
from .instructions import Instruction, Delay, Play, ShiftPhase, Snapshot, SetFrequency
from .interfaces import ScheduleComponent
from .pulse_lib import SamplePulse, Gaussian, GaussianSquare, Drag, ConstantPulse, ParametricPulse
from .schedule import Schedule
3 changes: 2 additions & 1 deletion qiskit/pulse/commands/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"""Delay instruction. Deprecated path."""
import warnings

from ..channels import Channel
from ..instructions import Delay
from ..instructions import Instruction


class DelayInstruction(Instruction):
"""Deprecated."""

def __init__(self, command: Delay, channel: Delay, name: str = None):
def __init__(self, command: Delay, channel: Channel, name: str = None):
"""Create a delay instruction from a delay command.

Args:
Expand Down
Loading