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

Fix duration interpolated sweeper for QM #1115

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
22 changes: 17 additions & 5 deletions src/qibolab/_core/instruments/qm/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def register_duration_sweeper_pulses(
):
"""Register pulse with many different durations.

Needed when sweeping duration.
Needed when sweeping duration. When interpolation is used, only
a single pulse with the minimum duration is used.
"""
for pulse in sweeper.pulses:
if isinstance(pulse, (Align, Delay)):
Expand All @@ -359,10 +360,19 @@ def register_duration_sweeper_pulses(
original_pulse = (
pulse if params.amplitude_pulse is None else params.amplitude_pulse
)
for value in sweeper.values.astype(int):
sweep_pulse = original_pulse.model_copy(update={"duration": value})
sweep_op = self.register_pulse(ids[0], configs[ids[0]], sweep_pulse)
params.duration_ops.append((value, sweep_op))
values = sweeper.values.astype(int)
if sweeper.parameter is Parameter.duration_interpolated:
sweep_pulse = original_pulse.model_copy(
update={"duration": min(values)}
)
params.interpolated_op = self.register_pulse(
ids[0], configs[ids[0]], sweep_pulse
)
else:
for value in values:
sweep_pulse = original_pulse.model_copy(update={"duration": value})
sweep_op = self.register_pulse(ids[0], configs[ids[0]], sweep_pulse)
params.duration_ops.append((value, sweep_op))

def register_amplitude_sweeper_pulses(
self, args: ExecutionArguments, configs: dict[str, Config], sweeper: Sweeper
Expand Down Expand Up @@ -448,6 +458,8 @@ def preprocess_sweeps(
self.register_amplitude_sweeper_pulses(args, configs, sweeper)
for sweeper in find_sweepers(sweepers, Parameter.duration):
self.register_duration_sweeper_pulses(args, configs, sweeper)
for sweeper in find_sweepers(sweepers, Parameter.duration_interpolated):
self.register_duration_sweeper_pulses(args, configs, sweeper)

def execute_program(self, program):
"""Executes an arbitrary program written in QUA language."""
Expand Down
1 change: 1 addition & 0 deletions src/qibolab/_core/instruments/qm/program/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Parameters:
duration: Optional[_Variable] = None
duration_ops: list[tuple[float, str]] = field(default_factory=list)
interpolated: bool = False
interpolated_op: Optional[str] = None

element: Optional[str] = None
lo_frequency: Optional[int] = None
Expand Down
5 changes: 4 additions & 1 deletion src/qibolab/_core/instruments/qm/program/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def _play_single_waveform(
if acquisition is not None:
acquisition.measure(op)
else:
qua.play(op, element, duration=parameters.duration)
if parameters.duration is not None:
qua.play(parameters.interpolated_op, element, duration=parameters.duration)
alecandido marked this conversation as resolved.
Show resolved Hide resolved
else:
qua.play(op, element)


def _play(
Expand Down
Loading