Skip to content

Commit

Permalink
ScheduleBlock 4/4 - add ScheduleBlock (#6158)
Browse files Browse the repository at this point in the history
* replace builder output
- update builder logic
  - deprecate call_schedule
  - deprecate pad context
- remove auto padding of align_equispaced and align_func
- move pad from alignment to canonicalization
- add temp transform pass
- unittest fix

* clean up the builder logic and fix lint errors

* fix warning

* update jupyter execute (remove builder syntax)

* update jupyter execute (remove builder syntax)

* remove freq offset warning

* update jupyter execute (rewrite transforms)

* review feedbacks

* fix error

* lint

* update docstring

* fix doscstring

* remove jupyter execute for deprecated function

* add reno

* add reno

* Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml

Co-authored-by: Lauren Capelluto <[email protected]>

* Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml

Co-authored-by: Lauren Capelluto <[email protected]>

* review feedback
- rename transform
- add get_context
- support blocks in the instmap
- misc

* Update qiskit/pulse/builder.py

Co-authored-by: Thomas Alexander <[email protected]>

* Update qiskit/pulse/builder.py

Co-authored-by: Thomas Alexander <[email protected]>

* Update qiskit/pulse/builder.py

Co-authored-by: Thomas Alexander <[email protected]>

* Update qiskit/pulse/transforms/canonicalization.py

Co-authored-by: Thomas Alexander <[email protected]>

* Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml

Co-authored-by: Thomas Alexander <[email protected]>

* Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml

Co-authored-by: Thomas Alexander <[email protected]>

* Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml

Co-authored-by: Thomas Alexander <[email protected]>

* Update releasenotes/notes/replace-builder-program-ecfc438b1cb19339.yaml

Co-authored-by: Thomas Alexander <[email protected]>

* warning update

* fix lint

* update old transform function in jupyter execute

* temp fix for instmap

* add test

* fix parameter name: lint

Co-authored-by: Lauren Capelluto <[email protected]>
Co-authored-by: Thomas Alexander <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 24, 2021
1 parent bb21d85 commit c65b41f
Show file tree
Hide file tree
Showing 25 changed files with 737 additions and 558 deletions.
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

0 comments on commit c65b41f

Please sign in to comment.