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

ScheduleBlock 2/4 - add Call instruction #5781

Merged
merged 84 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
09fc52f
remove timeslot dependency from instruction
nkanazawa1989 Jan 22, 2021
09fed68
update type hint
nkanazawa1989 Jan 22, 2021
01b7e3e
update unittest
nkanazawa1989 Jan 22, 2021
609481c
update validation logic
nkanazawa1989 Jan 22, 2021
e838c7d
fix lint and test
nkanazawa1989 Jan 22, 2021
50a3fb7
Update qiskit/pulse/utils.py
nkanazawa1989 Jan 28, 2021
1c7c3fd
Update qiskit/pulse/instructions/instruction.py
nkanazawa1989 Jan 28, 2021
73ff507
Update qiskit/pulse/schedule.py
nkanazawa1989 Jan 28, 2021
85b79e8
minor updates
nkanazawa1989 Jan 28, 2021
cb8d11c
Merge branch 'issue-5679-1_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Jan 28, 2021
e888cea
add reno
nkanazawa1989 Jan 28, 2021
ceefcb4
Merge branch 'issue-5679-1_schedule_block' into issue-5679-2_schedule…
nkanazawa1989 Jan 28, 2021
42cb633
wip add call instruction
nkanazawa1989 Jan 28, 2021
20b2548
update flatten method
nkanazawa1989 Jan 28, 2021
8939e25
wip
nkanazawa1989 Jan 29, 2021
15e302f
deprecate flatten method
nkanazawa1989 Jan 29, 2021
cb53c12
cyclic import fix
nkanazawa1989 Feb 1, 2021
df858fb
fix recursion bug
nkanazawa1989 Feb 2, 2021
33d68b2
split subroutine removal function
nkanazawa1989 Feb 2, 2021
7cf36b8
update parameter table for call
nkanazawa1989 Feb 2, 2021
e7fa08c
update builder logic and relevant unittests
nkanazawa1989 Feb 3, 2021
bd17f6e
add reno
nkanazawa1989 Feb 3, 2021
5d63b7d
update docstring
nkanazawa1989 Feb 3, 2021
64ee355
Merge branch 'master' of github.com:Qiskit/qiskit-terra into issue-56…
nkanazawa1989 Feb 3, 2021
d1cdd5c
update docstring
nkanazawa1989 Feb 3, 2021
e1bfdc6
revert unittest
nkanazawa1989 Feb 3, 2021
c67fb64
update reno for deprecation
nkanazawa1989 Feb 3, 2021
d7936cd
fix empty subroutine bug
nkanazawa1989 Feb 3, 2021
7e63c0a
update docstring
nkanazawa1989 Feb 3, 2021
00d062b
update docstring
nkanazawa1989 Feb 3, 2021
35285ca
remove whitespace
nkanazawa1989 Feb 4, 2021
312a4c4
feedback from Lauren
nkanazawa1989 Feb 4, 2021
88654ff
lint
nkanazawa1989 Feb 4, 2021
da3d039
Update qiskit/pulse/builder.py
nkanazawa1989 Feb 8, 2021
a29857e
Update qiskit/pulse/builder.py
nkanazawa1989 Feb 8, 2021
2b2cded
Update releasenotes/notes/add-call-instruction-6f4fc37994090c2f.yaml
nkanazawa1989 Feb 8, 2021
fe90614
Update releasenotes/notes/add-call-instruction-6f4fc37994090c2f.yaml
nkanazawa1989 Feb 8, 2021
7817f27
Update qiskit/pulse/transforms.py
nkanazawa1989 Feb 8, 2021
3a28c91
update function name
nkanazawa1989 Feb 8, 2021
450971e
update Call instruction
nkanazawa1989 Feb 8, 2021
0c71ce2
update logic of inline function
nkanazawa1989 Feb 8, 2021
28f8f1e
update call function
nkanazawa1989 Feb 8, 2021
a6d7901
update test and fix bugs
nkanazawa1989 Feb 8, 2021
9430307
add test for call instruction
nkanazawa1989 Feb 8, 2021
3f21951
fix unittest name overlap
nkanazawa1989 Feb 8, 2021
bab92c4
update table initialization
nkanazawa1989 Feb 8, 2021
e3257d1
lint
nkanazawa1989 Feb 8, 2021
a99ebfc
update docstring
nkanazawa1989 Feb 8, 2021
6a9d86f
Merge branch 'master' into issue-5679-2_schedule_block
nkanazawa1989 Feb 9, 2021
ff11ba3
name update and type update
nkanazawa1989 Feb 9, 2021
a4c5c8a
update type hints
nkanazawa1989 Feb 9, 2021
4b035c6
Merge branch 'issue-5679-2_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Feb 9, 2021
e582a4b
Merge branch 'master' into issue-5679-2_schedule_block
nkanazawa1989 Feb 10, 2021
9897c80
feedback from Thomas
nkanazawa1989 Feb 14, 2021
4b601fd
Update qiskit/pulse/instructions/call.py
nkanazawa1989 Feb 14, 2021
fae10af
Update qiskit/pulse/instructions/call.py
nkanazawa1989 Feb 14, 2021
28d1497
Update qiskit/pulse/instructions/call.py
nkanazawa1989 Feb 14, 2021
e933698
Update qiskit/pulse/instructions/call.py
nkanazawa1989 Feb 14, 2021
d97eb2e
Update qiskit/pulse/transforms.py
nkanazawa1989 Feb 14, 2021
c7a45df
Merge branch 'issue-5679-2_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Feb 14, 2021
644dfff
Update qiskit/pulse/builder.py
nkanazawa1989 Feb 14, 2021
90df0d0
feedback from Daniel
nkanazawa1989 Feb 14, 2021
3816f25
Merge branch 'issue-5679-2_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Feb 14, 2021
d7e98af
Merge branch 'master' of github.com:Qiskit/qiskit-terra into issue-56…
nkanazawa1989 Feb 14, 2021
9954dcd
update test
nkanazawa1989 Feb 14, 2021
c582067
add value dict to call constructor
nkanazawa1989 Feb 14, 2021
abdaaa2
more test
nkanazawa1989 Feb 14, 2021
a8cae98
support calling subroutine with new parameters
nkanazawa1989 Feb 14, 2021
bfc706a
fix parameter assign bug
nkanazawa1989 Feb 14, 2021
31e2152
lint
nkanazawa1989 Feb 14, 2021
6289969
fix type hint
nkanazawa1989 Feb 14, 2021
8de880c
lint
nkanazawa1989 Feb 14, 2021
22eb83f
forward reference
nkanazawa1989 Feb 14, 2021
7886cb3
ignore lint
nkanazawa1989 Feb 14, 2021
6fe8cf5
Merge branch 'master' into issue-5679-2_schedule_block
nkanazawa1989 Feb 15, 2021
2c63fa2
expose call instruction to end user
nkanazawa1989 Feb 17, 2021
f148645
Merge branch 'issue-5679-2_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Feb 17, 2021
5d903d3
update parameter assignment logic
nkanazawa1989 Feb 18, 2021
71f66d9
Merge branch 'master' into issue-5679-2_schedule_block
nkanazawa1989 Feb 18, 2021
6f29db9
fix test
nkanazawa1989 Feb 18, 2021
894adb7
Merge branch 'issue-5679-2_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Feb 18, 2021
91315dd
test lint
nkanazawa1989 Feb 18, 2021
0ddb56d
Merge branch 'master' into issue-5679-2_schedule_block
nkanazawa1989 Feb 18, 2021
4f3b1ba
Merge branch 'master' into issue-5679-2_schedule_block
mergify[bot] Feb 25, 2021
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
39 changes: 24 additions & 15 deletions qiskit/assembler/assemble_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=unused-import

"""Assemble function for converting a list of circuits into a qobj."""
import hashlib
from collections import defaultdict

from typing import Any, Dict, List, Tuple, Union

from qiskit import qobj, pulse
from qiskit.assembler.run_config import RunConfig
from qiskit.exceptions import QiskitError
from qiskit.pulse import instructions, transforms, library
from qiskit.pulse import instructions, transforms, library, schedule
from qiskit.qobj import utils as qobj_utils, converters
from qiskit.qobj.converters.pulse_instruction import ParametricPulseShapes


def assemble_schedules(
schedules: List[Union[pulse.ScheduleComponent, Tuple[int, pulse.ScheduleComponent]]],
schedules: List[Union['schedule.ScheduleComponent',
Tuple[int, 'schedule.ScheduleComponent']]],
qobj_id: int,
qobj_header: qobj.QobjHeader,
run_config: RunConfig) -> qobj.PulseQobj:
Expand Down Expand Up @@ -62,7 +64,8 @@ def assemble_schedules(


def _assemble_experiments(
schedules: List[Union[pulse.ScheduleComponent, Tuple[int, pulse.ScheduleComponent]]],
schedules: List[Union['schedule.ScheduleComponent',
Tuple[int, 'schedule.ScheduleComponent']]],
lo_converter: converters.LoConfigConverter,
run_config: RunConfig
) -> Tuple[List[qobj.PulseQobjExperiment], Dict[str, Any]]:
Expand Down Expand Up @@ -94,27 +97,33 @@ def _assemble_experiments(
instruction_converter = instruction_converter(qobj.PulseQobjInstruction,
**run_config.to_dict())

schedules = [
sched if isinstance(sched, pulse.Schedule) else pulse.Schedule(sched) for sched in schedules
]
compressed_schedules = transforms.compress_pulses(schedules)
formatted_schedules = []
for sched in schedules:
if isinstance(sched, pulse.Schedule):
sched = transforms.inline_subroutines(sched)
sched = transforms.flatten(sched)
formatted_schedules.append(sched)
else:
formatted_schedules.append(pulse.Schedule(sched))

compressed_schedules = transforms.compress_pulses(formatted_schedules)

user_pulselib = {}
experiments = []
for idx, schedule in enumerate(compressed_schedules):
for idx, sched in enumerate(compressed_schedules):
qobj_instructions, max_memory_slot = _assemble_instructions(
schedule,
sched,
instruction_converter,
run_config,
user_pulselib)

metadata = schedule.metadata
metadata = sched.metadata
if metadata is None:
metadata = {}
# TODO: add other experimental header items (see circuit assembler)
qobj_experiment_header = qobj.QobjExperimentHeader(
memory_slots=max_memory_slot + 1, # Memory slots are 0 indexed
name=schedule.name or 'Experiment-%d' % idx,
name=sched.name or 'Experiment-%d' % idx,
metadata=metadata)

experiment = qobj.PulseQobjExperiment(
Expand Down Expand Up @@ -149,7 +158,7 @@ def _assemble_experiments(


def _assemble_instructions(
schedule: pulse.Schedule,
sched: pulse.Schedule,
instruction_converter: converters.InstructionToQobjConverter,
run_config: RunConfig,
user_pulselib: Dict[str, List[complex]]
Expand All @@ -161,7 +170,7 @@ def _assemble_instructions(
The dictionary is not returned to avoid redundancy.

Args:
schedule: Schedule to assemble.
sched: Schedule to assemble.
instruction_converter: A converter instance which can convert PulseInstructions to
PulseQobjInstructions.
run_config: Configuration of the runtime environment.
Expand All @@ -175,7 +184,7 @@ def _assemble_instructions(
qobj_instructions = []

acquire_instruction_map = defaultdict(list)
for time, instruction in schedule.instructions:
for time, instruction in sched.instructions:

if (isinstance(instruction, instructions.Play) and
isinstance(instruction.pulse, library.ParametricPulse)):
Expand Down
3 changes: 2 additions & 1 deletion qiskit/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
~qiskit.pulse.instructions

Acquire
Call
Delay
Play
SetFrequency
Expand Down Expand Up @@ -448,6 +449,7 @@
from qiskit.pulse.instruction_schedule_map import InstructionScheduleMap
from qiskit.pulse.instructions import (
Acquire,
Call,
Delay,
Instruction,
Play,
Expand All @@ -457,7 +459,6 @@
ShiftPhase,
Snapshot,
)
from qiskit.pulse.interfaces import ScheduleComponent
from qiskit.pulse.library import (
Constant,
Drag,
Expand Down
Loading