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

Support frames using signals #5977

Closed
wants to merge 119 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
23dbc67
* First implementation of Frame.
eggerdj Mar 5, 2021
13cd3be
* Added an implementation of Signal, i.e. a Pulse in a Frame.
eggerdj Mar 5, 2021
8f9fe8c
* Added trackers to help resolve frames.
eggerdj Mar 5, 2021
306ac10
* Added __init__ files.
eggerdj Mar 5, 2021
7990fdd
* Added ignore_frames argument to the right and left alignment contex…
eggerdj Mar 5, 2021
280669a
* Added frames configuration to the assembler.
eggerdj Mar 5, 2021
e0d2aac
* Added call to frame resolution methodology in the assembler.
eggerdj Mar 5, 2021
bb79fcb
* Added frame resolution methodology in transforms.
eggerdj Mar 5, 2021
70df612
* Added the frames function to the backend configuration.
eggerdj Mar 5, 2021
0db5c8d
* Added changes to instructions to support Frames and Signals.
eggerdj Mar 5, 2021
8163f39
* Fixed issue in the way non-frame Shift/Set instructions are handled…
eggerdj Mar 8, 2021
6e91e95
* Added code to serialize frames config in the assembler.
eggerdj Mar 8, 2021
a38eb73
* Lint fix.
eggerdj Mar 8, 2021
175d037
* Lint fixes.
eggerdj Mar 8, 2021
597181f
* Lint fix.
eggerdj Mar 8, 2021
e9512e7
Merge branch 'master' of github.com:Qiskit/qiskit-terra into support_…
eggerdj Mar 9, 2021
0a83f72
* Added methodology to track the phase accumulation.
eggerdj Mar 9, 2021
3506063
* Added type hint to builder.
eggerdj Mar 10, 2021
81da036
* Tests for frame resolving and phase advance calculations.
eggerdj Mar 10, 2021
0f35a0e
* Added a few more basic tests.
eggerdj Mar 10, 2021
c510dc4
* Fixed bug in transforms.resolve_frames.
eggerdj Mar 10, 2021
23ee452
* Lint fix.
eggerdj Mar 10, 2021
fc30007
* Fix lint.
eggerdj Mar 10, 2021
260fcbf
* Fix cyclic import.
eggerdj Mar 10, 2021
d452e27
* Lint fix.
eggerdj Mar 10, 2021
0f669c4
* Merge branch 'master' of github.com:Qiskit/qiskit-terra into suppor…
eggerdj Apr 2, 2021
2aa651c
* Fixed imports and refactored chan to the right location.
eggerdj Apr 5, 2021
f1bfede
* Added property to Signal.parameters
eggerdj Apr 5, 2021
5fab67e
* Made the handeling of parameters in ResolvedFrame consistent with t…
eggerdj Apr 5, 2021
1d34642
* Added ignore_frames back to alignments as it was lost during mergin…
eggerdj Apr 5, 2021
2c9e834
* Aligned Signal and Frame to the ParameterManager functionality of p…
eggerdj Apr 5, 2021
9843f88
* Fixed lint.
eggerdj Apr 5, 2021
9410ca4
* Fixed test.
eggerdj Apr 5, 2021
028e9df
* Added a warning to the builder.
eggerdj Apr 6, 2021
a38e029
* Removed is parameterized from Frame and self._parameters.
eggerdj Apr 7, 2021
2d39fe1
* Moved hash generation in Frame to constructor.
eggerdj Apr 7, 2021
cae1aff
* Moved validate_index from channels and frame to utils.
eggerdj Apr 7, 2021
a41148c
Update qiskit/pulse/library/signal.py
eggerdj Apr 7, 2021
fdf6852
* Fixed docstring.
eggerdj Apr 7, 2021
e419714
* Removed id from Signal.
eggerdj Apr 7, 2021
b392d1e
* Used validate_index in parameter manager.
eggerdj Apr 7, 2021
3e46388
* Improved validate_index usage in parameter manager.
eggerdj Apr 7, 2021
7ece5ae
Update qiskit/pulse/transforms/frames.py
eggerdj Apr 7, 2021
858e136
Update qiskit/pulse/builder.py
eggerdj Apr 7, 2021
7ec977d
Update qiskit/pulse/transforms/alignments.py
eggerdj Apr 7, 2021
b7bc92f
Update qiskit/pulse/resolved_frame.py
eggerdj Apr 7, 2021
dfc6971
* Moved resolved_frame.py to transforms.
eggerdj Apr 8, 2021
6297a24
Merge branch 'support_frames_signals' of github.com:eggerdj/qiskit-te…
eggerdj Apr 8, 2021
b66e192
* Removed parameters from ResolvedFrame.
eggerdj Apr 8, 2021
b365e30
* Renamed sample_duration to dt.
eggerdj Apr 8, 2021
46623d8
* Added numerical threshhold.
eggerdj Apr 8, 2021
b604ee1
* Added raise on unsupported instructions in frames resolution.
eggerdj Apr 8, 2021
eae9f3e
* Improved docstring.
eggerdj Apr 8, 2021
cf82c2b
* Changed frames_config to have the frame as key.
eggerdj Apr 8, 2021
46292e9
* Cleaned up index notation.
eggerdj Apr 8, 2021
6332748
* Fixed docstring.
eggerdj Apr 8, 2021
94a8cd7
* Fixed comment.
eggerdj Apr 8, 2021
fdb1792
* Removed _frequency and _phase from ChannelTracker.
eggerdj Apr 8, 2021
8f6d1fc
* Improved code efficient in resolved frame.
eggerdj Apr 8, 2021
a785b7c
* Cleaned-up transforms.frames.py.
eggerdj Apr 8, 2021
a1b160d
* Changed operands[0] -> pulse.
eggerdj Apr 8, 2021
b32ff06
* Improved documentation of tests.
eggerdj Apr 8, 2021
8c710ac
Update qiskit/pulse/transforms/resolved_frame.py
eggerdj Apr 9, 2021
399fce4
* Moved to assertTrue.
eggerdj Apr 9, 2021
16fa292
Merge branch 'main' of github.com:Qiskit/qiskit-terra into support_fr…
eggerdj May 31, 2021
4674648
* Fix issues from merging.
eggerdj May 31, 2021
27dc741
* Black.
eggerdj May 31, 2021
aff1c6b
Merge branch 'main' into support_frames_signals
eggerdj Jun 11, 2021
a7ae702
* Made frame take a string identifier and optional parameter.
eggerdj Jun 11, 2021
d8aa27f
* Changed the backend configuration.
eggerdj Jun 11, 2021
31c31c3
* Refactored the frames config.
eggerdj Jun 11, 2021
5814d37
* Refactored ResolvedFrame.
eggerdj Jun 11, 2021
92d40b9
* Improved parameter treatment in frame.
eggerdj Jun 11, 2021
f9c90e5
* Removed frame channels in transforms.
eggerdj Jun 11, 2021
b5641d3
* Amend assemble_schedule.
eggerdj Jun 11, 2021
5a9ccd3
* Align and refactor tests.
eggerdj Jun 14, 2021
75cfac7
* Black.
eggerdj Jun 14, 2021
edf2510
* Caught an edge case.
eggerdj Jun 14, 2021
b736a91
* Removed a bug that came from a merge issue.
eggerdj Jun 14, 2021
85f466a
Merge branch 'main' into support_frames_signals
eggerdj Jun 14, 2021
f3fbbd8
* Lint.
eggerdj Jun 14, 2021
8622353
Merge branch 'support_frames_signals' of github.com:eggerdj/qiskit-te…
eggerdj Jun 14, 2021
7b2b25f
* Removed unused variable in test.
eggerdj Jun 15, 2021
bff077f
* Added a data class in resolved_frame-py.
eggerdj Jun 22, 2021
d51d2d0
* Added property Signal to Play.
eggerdj Jun 22, 2021
31ef605
* Improved set_phase and set_frequency in resolved_frame.py.
eggerdj Jun 22, 2021
59d2d99
* Minor bug fix.
eggerdj Jun 22, 2021
b7e8b40
* Resolved frame now sorts in reversed order.
eggerdj Jun 22, 2021
252e1fb
* Added a FramesConfiguration class.
eggerdj Jun 22, 2021
c9afa47
* Tighter integration between FrameDefintion, FramesConfig, and Resol…
eggerdj Jun 22, 2021
ff44ff8
* Added a clear distinction between prefix and index in Frame.
eggerdj Jun 22, 2021
582fdaf
* Moved frame resolution to base_transforms.py.
eggerdj Jun 22, 2021
9927f80
* Made the tolerance in frames resolution configurable.
eggerdj Jun 22, 2021
14efefa
* Added a method to add dt to FramesConfiguration.
eggerdj Jun 25, 2021
e14fbca
* Made frames property mutable.
eggerdj Jun 25, 2021
ee161ee
* Changed location in assemble where dt is added.
eggerdj Jun 25, 2021
e849758
* Frame is no longer optional in signal.
eggerdj Jun 25, 2021
5ec2682
* Changed prefixes for pulse defautl frames.
eggerdj Jun 25, 2021
990eec5
* Refactored sample_duration.
eggerdj Jun 25, 2021
7fe2b3a
* Added method to simultaneously set frequency and phase in the Tracker.
eggerdj Jun 26, 2021
ba56563
* Fix tests.
eggerdj Jun 26, 2021
cf319f2
* Improved documentation for the frames config.
eggerdj Jun 26, 2021
b8aa3ba
* Pop the frames config from the qobj_config.
eggerdj Jun 27, 2021
282e4a5
* Added condition to see if frames need resolving.
eggerdj Jun 27, 2021
96d205c
* Added frames config to the common args.
eggerdj Jun 27, 2021
d98288c
* Added assembly tests.
eggerdj Jun 27, 2021
c9eee29
* Added frames config bug fix in transforms.
eggerdj Jun 27, 2021
f10a8ab
* Added condition to catch frame instructions in resolve.
eggerdj Jun 27, 2021
df7ac4e
* Shift and Set instructions now only use frames. Channels are still …
eggerdj Jun 27, 2021
d18ba34
* Frame of channel can no longet be set by user.
eggerdj Jun 29, 2021
121fcb7
* Instructions have a frames property.
eggerdj Jun 29, 2021
378a768
* Renamed resolve_frames to map_frames.
eggerdj Jun 29, 2021
2b738df
* Added raise for calibrations that require frame mapping.
eggerdj Jun 29, 2021
02a9f21
* Refactored set_frame_instructions.
eggerdj Jun 29, 2021
7f897fb
* Black.
eggerdj Jun 29, 2021
b639ba2
Merge branch 'main' into support_frames_signals
eggerdj Jun 29, 2021
7650f81
* Refactor of frames.
eggerdj Jul 2, 2021
71b51d3
* Simplified channel tracking by removing the initialization.
eggerdj Jul 2, 2021
7ce6add
* Made mapping cleaner.
eggerdj Jul 3, 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
11 changes: 11 additions & 0 deletions qiskit/assembler/assemble_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
QobjHeader,
)
from qiskit.tools.parallel import parallel_map
from qiskit.pulse.transforms.frames import requires_frame_mapping


PulseLibrary = Dict[str, List[complex]]
Expand Down Expand Up @@ -192,6 +193,12 @@ def _assemble_pulse_gates(
pulse_library = {}
for gate, cals in circuit.calibrations.items():
for (qubits, params), schedule in cals.items():

# This will require the backend to map frames once timings are known in order to
# compute the phase advances.
if requires_frame_mapping(schedule):
raise QiskitError("Calibrations with frames are not yet supported.")

qobj_instructions, _ = _assemble_schedule(
schedule,
converters.InstructionToQobjConverter(PulseQobjInstruction),
Expand Down Expand Up @@ -358,6 +365,10 @@ def assemble_circuits(
if m_los:
qobj_config_dict["meas_lo_freq"] = [freq / 1e9 for freq in m_los]

# Needed so that the backend can map the frames.
if "frames_config" in qobj_config_dict:
qobj_config_dict["frames_config"] = qobj_config_dict["frames_config"].to_dict()

qobj_config = QasmQobjConfig(**qobj_config_dict)

qubit_sizes = []
Expand Down
12 changes: 10 additions & 2 deletions qiskit/assembler/assemble_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def _assemble_experiments(
)
instruction_converter = instruction_converter(qobj.PulseQobjInstruction, **run_config.to_dict())

formatted_schedules = [transforms.target_qobj_transform(sched) for sched in schedules]
frames_config = getattr(run_config, "frames_config", None)
formatted_schedules = [
transforms.target_qobj_transform(sched, frames_config=frames_config) for sched in schedules
]

compressed_schedules = transforms.compress_pulses(formatted_schedules)

user_pulselib = {}
Expand Down Expand Up @@ -179,7 +183,9 @@ 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)
sched = transforms.target_qobj_transform(
sched, frames_config=getattr(run_config, "frames_config", None)
)

max_memory_slot = 0
qobj_instructions = []
Expand Down Expand Up @@ -328,4 +334,6 @@ def _assemble_config(
if m_los:
qobj_config["meas_lo_freq"] = [freq / 1e9 for freq in m_los]

qobj_config.pop("frames_config", None)

return qobj.PulseQobjConfig(**qobj_config)
27 changes: 26 additions & 1 deletion qiskit/compiler/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from qiskit.pulse import LoConfig, Instruction
from qiskit.pulse import Schedule, ScheduleBlock
from qiskit.pulse.channels import PulseChannel
from qiskit.pulse.frame import FramesConfiguration
from qiskit.qobj import QobjHeader, Qobj
from qiskit.qobj.utils import MeasLevel, MeasReturnType
from qiskit.validation.jsonschema import SchemaValidationError
Expand Down Expand Up @@ -75,6 +76,7 @@ def assemble(
parameter_binds: Optional[List[Dict[Parameter, float]]] = None,
parametric_pulses: Optional[List[str]] = None,
init_qubits: bool = True,
frames_config: FramesConfiguration = None,
**run_config: Dict,
) -> Qobj:
"""Assemble a list of circuits or pulse schedules into a ``Qobj``.
Expand Down Expand Up @@ -140,7 +142,9 @@ def assemble(

['gaussian', 'constant']
init_qubits: Whether to reset the qubits to the ground state for each shot.
Default: ``True``.
Default: ``True``.
frames_config: An instance of FramesConfiguration defining how the frames are configured
for the backend.
**run_config: Extra arguments used to configure the run (e.g., for Aer configurable
backends). Refer to the backend documentation for details on these
arguments.
Expand Down Expand Up @@ -169,6 +173,7 @@ def assemble(
qubit_lo_range,
meas_lo_range,
schedule_los,
frames_config,
**run_config,
)

Expand Down Expand Up @@ -236,6 +241,7 @@ def _parse_common_args(
qubit_lo_range,
meas_lo_range,
schedule_los,
frames_config,
**run_config,
):
"""Resolve the various types of args allowed to the assemble() function through
Expand Down Expand Up @@ -341,6 +347,21 @@ def _parse_common_args(
for lo_config in schedule_los
]

frames_config_ = FramesConfiguration()
if backend:
frames_config_ = getattr(backend.defaults(), "frames", FramesConfiguration())

if frames_config is None:
frames_config = frames_config_
else:
for frame, config in frames_config_.items():
# Do not override the frames provided by the user.
if frame not in frames_config:
frames_config[frame] = config

if backend:
frames_config.sample_duration = backend_config.dt

# create run configuration and populate
run_config_dict = dict(
shots=shots,
Expand All @@ -355,6 +376,7 @@ def _parse_common_args(
meas_lo_range=meas_lo_range,
schedule_los=schedule_los,
n_qubits=n_qubits,
frames_config=frames_config,
**run_config,
)

Expand Down Expand Up @@ -404,6 +426,7 @@ def _parse_pulse_args(
memory_slot_size,
rep_time,
parametric_pulses,
frames_config,
**run_config,
):
"""Build a pulse RunConfig replacing unset arguments with defaults derived from the `backend`.
Expand All @@ -428,6 +451,7 @@ def _parse_pulse_args(
)

meas_map = meas_map or getattr(backend_config, "meas_map", None)

dynamic_reprate_enabled = getattr(backend_config, "dynamic_reprate_enabled", False)

rep_time = rep_time or getattr(backend_config, "rep_times", None)
Expand All @@ -452,6 +476,7 @@ def _parse_pulse_args(
memory_slot_size=memory_slot_size,
rep_time=rep_time,
parametric_pulses=parametric_pulses,
frames_config=frames_config,
**run_config,
)
run_config = RunConfig(**{k: v for k, v in run_config_dict.items() if v is not None})
Expand Down
30 changes: 30 additions & 0 deletions qiskit/providers/models/pulsedefaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
from typing import Any, Dict, List

from qiskit.pulse.instruction_schedule_map import InstructionScheduleMap
from qiskit.pulse.channels import DriveChannel, MeasureChannel
from qiskit.pulse.schedule import Schedule
from qiskit.qobj import PulseLibraryItem, PulseQobjInstruction
from qiskit.qobj.converters import QobjToInstructionConverter
from qiskit.pulse.frame import Frame, FramesConfiguration


class MeasurementKernel:
Expand Down Expand Up @@ -213,6 +215,7 @@ def __init__(
self.discriminator = discriminator

self._data.update(kwargs)
self._frames_config = None

def __getattr__(self, name):
try:
Expand Down Expand Up @@ -277,6 +280,33 @@ def from_dict(cls, data):
in_data["discriminator"] = Discriminator.from_dict(in_data.pop("discriminator"))
return cls(**in_data)

@property
def frames(self) -> FramesConfiguration:
"""Get the frames supported by the backend.

Returns:
frames: A list of dicts, each dict defines a frame, its frequency, and its purpose.
"""
if self._frames_config is None:
frames = {}
for qubit, freq in enumerate(self.qubit_freq_est):
frames[Frame(DriveChannel.prefix, qubit)] = {
"frequency": freq,
"purpose": f"Frame of qubit {qubit}",
"has_physical_channel": True,
}

for meas, freq in enumerate(self.meas_freq_est):
frames[Frame(MeasureChannel.prefix, meas)] = {
"frequency": freq,
"purpose": f"Frame of meas {meas}",
"has_physical_channel": True,
}

self._frames_config = FramesConfiguration.from_dict(frames)

return self._frames_config

def __str__(self):
qubit_freqs = [freq / 1e9 for freq in self.qubit_freq_est]
meas_freqs = [freq / 1e9 for freq in self.meas_freq_est]
Expand Down
2 changes: 2 additions & 0 deletions qiskit/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,3 +470,5 @@
)
from qiskit.pulse.library.samplers.decorators import functional_pulse
from qiskit.pulse.schedule import Schedule, ScheduleBlock
from qiskit.pulse.library.signal import Signal
from qiskit.pulse.frame import Frame
Loading