Skip to content

Commit dfe1dd4

Browse files
committed
feat: Implement split batches concatenation
1 parent 01e80b1 commit dfe1dd4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

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

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22
from collections import defaultdict
3-
from functools import cached_property
3+
from functools import cached_property, reduce
44
from itertools import groupby
55
from typing import Optional, cast
66

@@ -58,13 +58,26 @@ def batch_shots(
5858
nfull, remainder = np.divmod(bins * samples, ACQUISITION_MEMORY)
5959
return (
6060
[ACQUISITION_MEMORY] * nfull + [remainder]
61-
if options.averaging_mode is not AveragingMode.SINGLESHOT
61+
if options.averaging_mode is AveragingMode.SINGLESHOT
6262
else [options.nshots]
6363
)
6464

6565

66-
def concat_shots(results: list[dict[int, Result]]) -> dict[int, Result]:
67-
return results[0]
66+
def concat_shots(
67+
results: list[dict[int, Result]], options: ExecutionParameters
68+
) -> dict[int, Result]:
69+
"""Concatenate shots batches.
70+
71+
It collects the measurements' batches resulting from the subdivision generated by
72+
the :func:`batch_shots` function.
73+
It assumes homogenuous batches, which are only joined over the single outermost
74+
dimension, and only for :obj:`AveragingMode.SINGLESHOT` acquisitions.
75+
"""
76+
return (
77+
reduce(lambda d, e: {k: np.vstack((v, e[k])) for k, v in d.items()}, results)
78+
if options.averaging_mode is AveragingMode.SINGLESHOT
79+
else results[0]
80+
)
6881

6982

7083
class Cluster(Controller):
@@ -218,7 +231,7 @@ def play(
218231
options.results_shape(sweepers),
219232
)
220233
)
221-
results |= concat_shots(psres)
234+
results |= concat_shots(psres, options)
222235
return results
223236

224237
def _configure(

0 commit comments

Comments
 (0)