Skip to content

Commit 537378c

Browse files
committed
fix: Supplement channel filters for readout operations
1 parent 0d514d3 commit 537378c

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

src/qibolab/_core/instruments/qblox/sequence/loops.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _experiment_end(relaxation_time: int) -> list[Line]:
125125
"""
126126

127127

128-
def _sweep_update(p: Param, channel: ChannelId, pulses: set[PulseId]) -> Block:
128+
def _sweep_update(p: Param, channel: set[ChannelId], pulses: set[PulseId]) -> Block:
129129
"""Sweeper update for a single parameter.
130130
131131
- increment the parameter register
@@ -146,16 +146,12 @@ def _sweep_update(p: Param, channel: ChannelId, pulses: set[PulseId]) -> Block:
146146
if p.channel == channel or p.pulse in pulses
147147
else ()
148148
),
149-
*(
150-
update_instructions(p.kind, p.reg)
151-
if p.description is not None and p.channel == channel
152-
else ()
153-
),
149+
*(update_instructions(p.kind, p.reg) if p.channel in channel else ()),
154150
)
155151

156152

157153
def _sweep_updates(
158-
lp: LoopSpec, params: IndexedParams, channel: ChannelId, pulses: set[PulseId]
154+
lp: LoopSpec, params: IndexedParams, channel: set[ChannelId], pulses: set[PulseId]
159155
) -> BlockIter:
160156
"""Parallel sweeper updates.
161157
@@ -179,7 +175,7 @@ def _sweep_iteration(
179175
lp: LoopSpec,
180176
params: IndexedParams,
181177
shots: bool,
182-
channel: ChannelId,
178+
channel: set[ChannelId],
183179
pulses: set[PulseId],
184180
) -> BlockList:
185181
"""Sweep loop.
@@ -203,7 +199,7 @@ def _loop_machinery(
203199
loops: Sequence[LoopSpec],
204200
params: IndexedParams,
205201
singleshot: bool,
206-
channel: ChannelId,
202+
channel: set[ChannelId],
207203
pulses: set[PulseId],
208204
) -> BlockList:
209205
"""Looping block.
@@ -232,7 +228,7 @@ def loop(
232228
params: IndexedParams,
233229
relaxation_time: int,
234230
singleshot: bool,
235-
channel: ChannelId,
231+
channel: set[ChannelId],
236232
pulses: set[PulseId],
237233
) -> Block:
238234
end = _experiment_end(relaxation_time)

src/qibolab/_core/instruments/qblox/sequence/program.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
def setup(
3030
loops: Sequence[LoopSpec],
3131
params: list[Param],
32-
channel: ChannelId,
32+
channel: set[ChannelId],
3333
pulses: set[PulseId],
3434
) -> Block:
3535
"""Build preparation phase. Ending with synchronization.
@@ -68,12 +68,12 @@ def setup(
6868
comment=f"init {p.description}",
6969
)
7070
for p in params
71-
if p.channel == channel or p.pulse in pulses
71+
if p.channel in channel or p.pulse in pulses
7272
]
7373
+ [
7474
inst
7575
for p in params
76-
if p.channel == channel
76+
if p.channel in channel
7777
for inst in update_instructions(p.kind, p.start)
7878
]
7979
+ [WaitSync(duration=4)]
@@ -94,7 +94,7 @@ def program(
9494
acquisitions: dict[MeasureId, AcquisitionSpec],
9595
options: ExecutionParameters,
9696
sweepers: list[ParallelSweepers],
97-
channel: ChannelId,
97+
channel: set[ChannelId],
9898
time_of_flight: Optional[float],
9999
padding: int,
100100
) -> Program:

src/qibolab/_core/instruments/qblox/sequence/sequence.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def from_pulses(
7777
sweepers: list[ParallelSweepers],
7878
options: ExecutionParameters,
7979
sampling_rate: float,
80-
channel: ChannelId,
80+
channel: set[ChannelId],
8181
lo: Optional[float],
8282
time_of_flight: Optional[float],
8383
duration: float,
@@ -147,6 +147,19 @@ def _lo_frequency(lo: Optional[OscillatorConfig]) -> Optional[float]:
147147
return lo.frequency if lo is not None else None
148148

149149

150+
def _effective_channels(ch: ChannelId, seq: Iterable[PulseLike]) -> set[ChannelId]:
151+
"""Identify effective channels related to a subsequence.
152+
153+
The channel is the declared one, unless in presence of :class:`Readout` operations.
154+
In which case the assumed *acquisition* channel is supplemented with a *probe* one.
155+
"""
156+
return (
157+
{ch}
158+
if not any(isinstance(e, Readout) for e in seq)
159+
else {ch, f"{'/'.join(ch.split('/')[:-1])}/probe"}
160+
)
161+
162+
150163
def compile(
151164
sequence: PulseSequence,
152165
sweepers: list[ParallelSweepers],
@@ -162,7 +175,7 @@ def compile(
162175
sweepers,
163176
options,
164177
sampling_rate,
165-
ch,
178+
_effective_channels(ch, seq),
166179
_lo_frequency(los.get(ch)),
167180
time_of_flights.get(ch),
168181
duration,

src/qibolab/_core/instruments/qblox/sequence/sweepers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Param(Model):
4040
"""The target channel (if the sweeper targets channels)."""
4141

4242
@property
43-
def description(self):
43+
def description(self) -> str:
4444
"""Textual description, used in some accompanying comments."""
4545
return (
4646
f"sweeper (loop: {self.sweeper + 1}, "

0 commit comments

Comments
 (0)