Skip to content

Commit

Permalink
feat: Validate waveform memory constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Feb 24, 2025
1 parent c2703e9 commit 776f89f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/qibolab/_core/instruments/qblox/mock/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def __init__(self, *args, **kwargs) -> None:
def reset(self) -> None:
self.resets += 1

def close(self) -> None:
pass

@property
def records(self) -> dict:
return {
Expand Down
15 changes: 15 additions & 0 deletions src/qibolab/_core/instruments/qblox/sequence/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ def _pulse(event: Union[Pulse, Readout]) -> Pulse:
return event.probe if isinstance(event, Readout) else event


WAVEFORM_MEMORY = 2**14
"""Maximum waveform memory available.
https://docs.qblox.com/en/main/cluster/q1_sequence_processor.html#waveform-memory
"""
WAVEFORM_NUMBER = 2**10
"""Maximum number of waveforms available.
https://docs.qblox.com/en/main/cluster/q1_sequence_processor.html#waveform-memory
"""


def waveforms(
sequence: Iterable[PulseLike],
sampling_rate: float,
Expand Down Expand Up @@ -85,6 +97,9 @@ def _waveform(
for k, v in d.items()
}

assert sum(len(w.waveform.data) for _, w in indexless.items()) <= WAVEFORM_MEMORY
assert len(indexless) <= WAVEFORM_NUMBER

return {
k: WaveformSpec(
waveform=Waveform(data=v.waveform.data, index=i), duration=v.duration
Expand Down

0 comments on commit 776f89f

Please sign in to comment.