Skip to content

Commit

Permalink
fix: Supplement channel filters for readout operations
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Feb 28, 2025
1 parent 0d514d3 commit 537378c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
16 changes: 6 additions & 10 deletions src/qibolab/_core/instruments/qblox/sequence/loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _experiment_end(relaxation_time: int) -> list[Line]:
"""


def _sweep_update(p: Param, channel: ChannelId, pulses: set[PulseId]) -> Block:
def _sweep_update(p: Param, channel: set[ChannelId], pulses: set[PulseId]) -> Block:
"""Sweeper update for a single parameter.
- increment the parameter register
Expand All @@ -146,16 +146,12 @@ def _sweep_update(p: Param, channel: ChannelId, pulses: set[PulseId]) -> Block:
if p.channel == channel or p.pulse in pulses
else ()
),
*(
update_instructions(p.kind, p.reg)
if p.description is not None and p.channel == channel
else ()
),
*(update_instructions(p.kind, p.reg) if p.channel in channel else ()),
)


def _sweep_updates(
lp: LoopSpec, params: IndexedParams, channel: ChannelId, pulses: set[PulseId]
lp: LoopSpec, params: IndexedParams, channel: set[ChannelId], pulses: set[PulseId]
) -> BlockIter:
"""Parallel sweeper updates.
Expand All @@ -179,7 +175,7 @@ def _sweep_iteration(
lp: LoopSpec,
params: IndexedParams,
shots: bool,
channel: ChannelId,
channel: set[ChannelId],
pulses: set[PulseId],
) -> BlockList:
"""Sweep loop.
Expand All @@ -203,7 +199,7 @@ def _loop_machinery(
loops: Sequence[LoopSpec],
params: IndexedParams,
singleshot: bool,
channel: ChannelId,
channel: set[ChannelId],
pulses: set[PulseId],
) -> BlockList:
"""Looping block.
Expand Down Expand Up @@ -232,7 +228,7 @@ def loop(
params: IndexedParams,
relaxation_time: int,
singleshot: bool,
channel: ChannelId,
channel: set[ChannelId],
pulses: set[PulseId],
) -> Block:
end = _experiment_end(relaxation_time)
Expand Down
8 changes: 4 additions & 4 deletions src/qibolab/_core/instruments/qblox/sequence/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
def setup(
loops: Sequence[LoopSpec],
params: list[Param],
channel: ChannelId,
channel: set[ChannelId],
pulses: set[PulseId],
) -> Block:
"""Build preparation phase. Ending with synchronization.
Expand Down Expand Up @@ -68,12 +68,12 @@ def setup(
comment=f"init {p.description}",
)
for p in params
if p.channel == channel or p.pulse in pulses
if p.channel in channel or p.pulse in pulses
]
+ [
inst
for p in params
if p.channel == channel
if p.channel in channel
for inst in update_instructions(p.kind, p.start)
]
+ [WaitSync(duration=4)]
Expand All @@ -94,7 +94,7 @@ def program(
acquisitions: dict[MeasureId, AcquisitionSpec],
options: ExecutionParameters,
sweepers: list[ParallelSweepers],
channel: ChannelId,
channel: set[ChannelId],
time_of_flight: Optional[float],
padding: int,
) -> Program:
Expand Down
17 changes: 15 additions & 2 deletions src/qibolab/_core/instruments/qblox/sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def from_pulses(
sweepers: list[ParallelSweepers],
options: ExecutionParameters,
sampling_rate: float,
channel: ChannelId,
channel: set[ChannelId],
lo: Optional[float],
time_of_flight: Optional[float],
duration: float,
Expand Down Expand Up @@ -147,6 +147,19 @@ def _lo_frequency(lo: Optional[OscillatorConfig]) -> Optional[float]:
return lo.frequency if lo is not None else None


def _effective_channels(ch: ChannelId, seq: Iterable[PulseLike]) -> set[ChannelId]:
"""Identify effective channels related to a subsequence.
The channel is the declared one, unless in presence of :class:`Readout` operations.
In which case the assumed *acquisition* channel is supplemented with a *probe* one.
"""
return (
{ch}
if not any(isinstance(e, Readout) for e in seq)
else {ch, f"{'/'.join(ch.split('/')[:-1])}/probe"}
)


def compile(
sequence: PulseSequence,
sweepers: list[ParallelSweepers],
Expand All @@ -162,7 +175,7 @@ def compile(
sweepers,
options,
sampling_rate,
ch,
_effective_channels(ch, seq),
_lo_frequency(los.get(ch)),
time_of_flights.get(ch),
duration,
Expand Down
2 changes: 1 addition & 1 deletion src/qibolab/_core/instruments/qblox/sequence/sweepers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Param(Model):
"""The target channel (if the sweeper targets channels)."""

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

0 comments on commit 537378c

Please sign in to comment.