From 7c968bd5b1efe64cb34f7c220c9877730cf27916 Mon Sep 17 00:00:00 2001 From: Alessandro Candido Date: Fri, 7 Feb 2025 13:44:41 +0100 Subject: [PATCH] fix: Ensure probe channels exclusion --- src/qibolab/_core/instruments/qblox/cluster.py | 6 ++++-- src/qibolab/_core/instruments/qblox/config.py | 6 ++++-- src/qibolab/_core/instruments/qblox/validate.py | 16 ++++++++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/qibolab/_core/instruments/qblox/cluster.py b/src/qibolab/_core/instruments/qblox/cluster.py index c2c7f8d7c..cf8417785 100644 --- a/src/qibolab/_core/instruments/qblox/cluster.py +++ b/src/qibolab/_core/instruments/qblox/cluster.py @@ -22,7 +22,7 @@ from .log import Logger from .results import AcquiredData, extract, integration_lenghts from .sequence import Q1Sequence, compile -from .validate import _assert_no_probe +from .validate import assert_channels_exclusion __all__ = ["Cluster"] @@ -30,6 +30,8 @@ class Cluster(Controller): + """Controller object for Qblox cluster.""" + name: str """Device name. @@ -109,7 +111,7 @@ def play( log = Logger(configs) for ps in sequences: - _assert_no_probe(ps, self._probes) + assert_channels_exclusion(ps, self._probes) sequences_ = compile(ps, sweepers, options, self.sampling_rate) log.sequences(sequences_) sequencers = self._configure(sequences_, configs, options.acquisition_type) diff --git a/src/qibolab/_core/instruments/qblox/config.py b/src/qibolab/_core/instruments/qblox/config.py index 410bd0e0a..983b419ee 100644 --- a/src/qibolab/_core/instruments/qblox/config.py +++ b/src/qibolab/_core/instruments/qblox/config.py @@ -96,11 +96,11 @@ def _los( """ return { (iq, lo) - for iq, lo in { + for iq, lo in ( (iq, cast(IqChannel, channels[iq]).lo) for iq in (_iqout(ch, channels[ch]) for ch in mod_channels) if iq is not None - } + ) if lo is not None } @@ -111,6 +111,7 @@ def module( channels: dict[ChannelId, Channel], configs: Configs, ): + """Configure module-wide settings.""" # map sequencers to specific outputs (but first disable all sequencer connections) mod.disconnect_outputs() @@ -134,6 +135,7 @@ def sequencer( configs: Configs, acquisition: AcquisitionType, ): + """Configure sequencer-wide settings.""" # upload sequence # - ensure JSON compatibility of the sent dictionary seq.sequence(json.loads(sequence.model_dump_json())) diff --git a/src/qibolab/_core/instruments/qblox/validate.py b/src/qibolab/_core/instruments/qblox/validate.py index 28ca7e382..5aea9cfae 100644 --- a/src/qibolab/_core/instruments/qblox/validate.py +++ b/src/qibolab/_core/instruments/qblox/validate.py @@ -1,6 +1,18 @@ from qibolab._core.identifier import ChannelId from qibolab._core.sequence import PulseSequence +__all__ = [] -def _assert_no_probe(ps: PulseSequence, probes: set[ChannelId]): - return + +def assert_channels_exclusion(ps: PulseSequence, excluded: set[ChannelId]): + """Deny group of channels. + + Mainly used to deny probe channels, since probe events are currently required to be + bundled with acquisitions, cf. :class:`qibolab.Readout`. + + An extended discussion about the probe-acquisition merge is found at: + https://github.com/qiboteam/qibolab/pull/1088#issuecomment-2637800857 + """ + assert not any( + ch in excluded for ch, _ in ps + ), "Probe channels can not be controlled independently, please use Readout events."