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 4/4 - add ScheduleBlock #6158

Merged
merged 43 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8382c96
replace builder output
nkanazawa1989 Mar 31, 2021
9c8c970
clean up the builder logic and fix lint errors
nkanazawa1989 Apr 5, 2021
53cd6bb
fix warning
nkanazawa1989 Apr 5, 2021
be0d8e7
update jupyter execute (remove builder syntax)
nkanazawa1989 Apr 6, 2021
03b3011
update jupyter execute (remove builder syntax)
nkanazawa1989 Apr 6, 2021
7469b40
remove freq offset warning
nkanazawa1989 Apr 6, 2021
c8b4109
Merge branch 'master' into issue-5679-4_schedule_block
nkanazawa1989 Apr 6, 2021
6f81b7d
update jupyter execute (rewrite transforms)
nkanazawa1989 Apr 7, 2021
3a15033
Merge branch 'issue-5679-4_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Apr 7, 2021
4e01519
review feedbacks
nkanazawa1989 Apr 12, 2021
a23516b
fix error
nkanazawa1989 Apr 12, 2021
c17a969
lint
nkanazawa1989 Apr 12, 2021
76494a8
update docstring
nkanazawa1989 Apr 15, 2021
828f61d
fix doscstring
nkanazawa1989 Apr 17, 2021
65e6b32
remove jupyter execute for deprecated function
nkanazawa1989 Apr 17, 2021
df7b266
add reno
nkanazawa1989 Apr 17, 2021
970df7b
Merge branch 'master' into issue-5679-4_schedule_block
nkanazawa1989 Apr 17, 2021
2ec9d03
add reno
nkanazawa1989 Apr 17, 2021
7507f36
Merge branch 'issue-5679-4_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Apr 17, 2021
21d01da
Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml
nkanazawa1989 Apr 19, 2021
9046343
Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml
nkanazawa1989 Apr 19, 2021
19ca2ff
review feedback
nkanazawa1989 Apr 22, 2021
f707ee7
Update qiskit/pulse/builder.py
nkanazawa1989 Apr 22, 2021
821e2eb
Update qiskit/pulse/builder.py
nkanazawa1989 Apr 22, 2021
2bb0955
Update qiskit/pulse/builder.py
nkanazawa1989 Apr 22, 2021
09ed6b2
Update qiskit/pulse/transforms/canonicalization.py
nkanazawa1989 Apr 22, 2021
53057c9
Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml
nkanazawa1989 Apr 22, 2021
cacf9a3
Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml
nkanazawa1989 Apr 22, 2021
6d56430
Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml
nkanazawa1989 Apr 22, 2021
d6a0db3
Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml
nkanazawa1989 Apr 22, 2021
24a03e2
Merge branch 'issue-5679-4_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Apr 22, 2021
c1845aa
warning update
nkanazawa1989 Apr 22, 2021
35d1092
fix lint
nkanazawa1989 Apr 22, 2021
cb40ced
Merge branch 'main' into issue-5679-4_schedule_block
nkanazawa1989 Apr 22, 2021
a7af2c3
update old transform function in jupyter execute
nkanazawa1989 Apr 22, 2021
4f72e01
Merge branch 'issue-5679-4_schedule_block' of github.com:nkanazawa198…
nkanazawa1989 Apr 22, 2021
4e66265
temp fix for instmap
nkanazawa1989 Apr 22, 2021
38b134c
add test
nkanazawa1989 Apr 22, 2021
f444dae
fix parameter name: lint
nkanazawa1989 Apr 23, 2021
299666f
Merge branch 'main' into issue-5679-4_schedule_block
mergify[bot] Apr 23, 2021
c4d57e7
Merge branch 'main' into issue-5679-4_schedule_block
nkanazawa1989 Apr 24, 2021
dcc06d2
Merge branch 'main' into issue-5679-4_schedule_block
mergify[bot] Apr 24, 2021
1ab014b
Merge branch 'main' into issue-5679-4_schedule_block
mergify[bot] Apr 24, 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
17 changes: 6 additions & 11 deletions qiskit/assembler/assemble_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@


def assemble_schedules(
schedules: List[Union['schedule.ScheduleComponent',
schedules: List[Union['schedule.ScheduleBlock',
'schedule.ScheduleComponent',
Tuple[int, 'schedule.ScheduleComponent']]],
qobj_id: int,
qobj_header: qobj.QobjHeader,
Expand Down Expand Up @@ -97,15 +98,7 @@ def _assemble_experiments(
instruction_converter = instruction_converter(qobj.PulseQobjInstruction,
**run_config.to_dict())

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))

formatted_schedules = [transforms.target_qobj_transform(sched) for sched in schedules]
compressed_schedules = transforms.compress_pulses(formatted_schedules)

user_pulselib = {}
Expand Down Expand Up @@ -158,7 +151,7 @@ def _assemble_experiments(


def _assemble_instructions(
sched: pulse.Schedule,
sched: Union[pulse.Schedule, pulse.ScheduleBlock],
instruction_converter: converters.InstructionToQobjConverter,
run_config: RunConfig,
user_pulselib: Dict[str, List[complex]]
Expand All @@ -180,6 +173,8 @@ def _assemble_instructions(
A list of converted instructions, the user pulse library dictionary (from pulse name to
pulse samples), and the maximum number of readout memory slots used by this Schedule.
"""
sched = transforms.target_qobj_transform(sched)

max_memory_slot = 0
qobj_instructions = []

Expand Down
21 changes: 12 additions & 9 deletions qiskit/compiler/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@
# that they have been altered from the originals.

"""Assemble function for converting a list of circuits into a qobj"""
import uuid
import copy
import logging
import uuid
import warnings
from time import time
from typing import Union, List, Dict, Optional

from qiskit.assembler import assemble_circuits, assemble_schedules
from qiskit.assembler.run_config import RunConfig
from qiskit.circuit import QuantumCircuit, Qubit, Parameter
from qiskit.exceptions import QiskitError
from qiskit.providers import BaseBackend
from qiskit.providers.backend import Backend
from qiskit.pulse import LoConfig, Instruction
from qiskit.assembler.run_config import RunConfig
from qiskit.assembler import assemble_circuits, assemble_schedules
from qiskit.pulse import Schedule, ScheduleBlock
from qiskit.pulse.channels import PulseChannel
from qiskit.qobj import QobjHeader, Qobj
from qiskit.qobj.utils import MeasLevel, MeasReturnType
from qiskit.validation.jsonschema import SchemaValidationError
from qiskit.providers import BaseBackend
from qiskit.providers.backend import Backend
from qiskit.pulse.channels import PulseChannel
from qiskit.pulse import Schedule

logger = logging.getLogger(__name__)

Expand All @@ -39,7 +40,9 @@ def _log_assembly_time(start_time, end_time):


# TODO: parallelize over the experiments (serialize each separately, then add global header/config)
def assemble(experiments: Union[QuantumCircuit, List[QuantumCircuit], Schedule, List[Schedule]],
def assemble(experiments: Union[QuantumCircuit, List[QuantumCircuit],
Schedule, List[Schedule],
ScheduleBlock, Union[ScheduleBlock]],
backend: Optional[Union[Backend, BaseBackend]] = None,
qobj_id: Optional[str] = None,
qobj_header: Optional[Union[QobjHeader, Dict]] = None,
Expand Down Expand Up @@ -154,7 +157,7 @@ def assemble(experiments: Union[QuantumCircuit, List[QuantumCircuit], Schedule,
return assemble_circuits(circuits=bound_experiments, qobj_id=qobj_id,
qobj_header=qobj_header, run_config=run_config)

elif all(isinstance(exp, (Schedule, Instruction)) for exp in experiments):
elif all(isinstance(exp, (ScheduleBlock, Schedule, Instruction)) for exp in experiments):
run_config = _parse_pulse_args(backend, qubit_lo_freq, meas_lo_freq,
qubit_lo_range, meas_lo_range,
schedule_los, meas_level, meas_return,
Expand Down
Loading