Playback Emulator
Overview
The playback emulator is a software client for testing realtime decoding without a quantum processor (QPU). It sends measurements and correction requests according to a text schedule, which specifies when each call should run and what to send. You can replay recorded measurements or generate them from a simulated memory experiment, check the returned corrections, and inspect the time taken to receive each reply.
Decoders can run in the same process as the emulator or in a separate Decoding Server. Use the in-process mode to test a decoder configuration locally; use a server session to exercise communication as well as decoding. Both modes exercise the realtime request interface, even when the measurements were produced offline.
A run connects three pieces:
A schedule orders resets, measurement rounds, final readouts, and correction requests, with timing and optional dependencies between events.
Syndrome sources supply the measurements. A static source replays fixed rounds; memory-circuit sources generate measurements for the experiment.
Sessions connect each decoder ID in the schedule to an in-process decoder, a server endpoint, or a null backend for measuring emulator overhead.
The emulator records the scheduled deadline, actual dispatch and reply times, status, and correction bits. Compare these to distinguish late dispatch from time spent waiting for a decoder reply. Timing depends on the host and selected transport; software playback alone does not establish a hardware feedback-latency guarantee. This tool is separate from the FPGA playback described in Realtime Decoding from a Quantum Kernel or FPGA.
Note
The playback emulator is only built when CUDA-Q QEC is built against a
CUDA-Q install with cudaq-realtime enabled. The prebuilt decoding-server
image includes the command-line tool. The Python interface requires a
realtime-enabled CUDA-Q QEC Python installation, such as the combined
CUDA-Q/QEC image; it is not included in the 0.9.0 pip wheels.
Start with In-Process Repetition-Code Playback to check ten shots with alternating corrections, or Playback Against a Decoding Server to generate a surface-code configuration and replay a shot over UDP.
For an accuracy and runtime comparison, see Comparing Ising and Chromobius for Color-Code Decoding. It replays the same sampled measurements through Chromobius alone and an Ising predecoder followed by Chromobius, using both in-process and server sessions.
To make the next shot’s length depend on the previous correction’s arrival, see Measuring Streaming Interleaved Feed-forward Latency (SIFL). It uses completion signals and alternating in-process decoders to study feedback latency and decoder backlog as the measurement cadence changes.
Reference
Python and Command-Line Interfaces
A schedule is a text file, where each line is a single event representing a decoder call, or sequence of decoder calls. For example, the following schedule resets decoder 0, enqueues three rounds of syndromes, and asks for a one-bit correction. This illustrates the syntax; the required rounds and any final data-qubit readout depend on the decoder configuration:
# <trigger> <op> [key=value...]
0 reset session=0
1 stream session=0 source=0 rounds=3 every=2
- get_corrections session=0 return_size=1
The interfaces below assume that you have prepared a matching config.yaml,
schedule.txt, and syndrome source. For complete configurations and inputs,
use the examples linked above.
import cudaq_qec as qec
decoders = qec.multi_decoder_config.from_yaml_str(open("config.yaml").read())
result = qec.playback.run(open("schedule.txt").read(),
tick_ns=1000,
sources={0: {"type": "static",
"rounds": [[0, 1]] * 3}},
decoders=decoders)
print(result.write_csv())
# syndromes.txt holds one 0/1 bit string per round, one round per line.
playback-emulator --schedule=schedule.txt --config=config.yaml \
--source=0:syndromes.txt --tick=1us --out=result.csv
config.yaml is a decoder configuration, as described in
Getting Started with Realtime Decoding.
Both entry points produce the same result: one record per schedule line,
written as CSV by write_csv() (Python) or --out (command line); see
Output Format. Run playback-emulator --help for
all command-line options.
Schedule Format
Each line is <trigger> <op> [key=value...]. Blank lines are ignored, and
# starts a comment.
Timing is tracked in ticks, where one tick is defined by the tick_ns run option (default 1 µs). The trigger says when the line runs:
N(an integer): at tickNfrom the start of the run. One tick defaults to 1 µs (see Run Options).+N:Nticks after the previous line finished sending.-: same as+0, i.e. execute immediately.
Lines run in file order. Plain tick numbers must not decrease, and once a line
uses +N or -, every later line must too.
The operations are listed below. Arguments in [brackets] are optional.
Operation |
Description |
|---|---|
|
Resets the decoder. |
|
Sends syndromes from |
|
Shorthand for a one-round |
|
Like |
|
Requests corrections. |
source= sets the syndrome source by its integer ID (see below), or gives one
round of bits inline, e.g. enqueue source=0b0110.
Every operation also takes these optional keys:
[session=N]: the decoder ID to call (default0).[signal=NAME]: raise signalNAMEonce all of this line’s replies have arrived.[after=NAME]: wait for signalNAMEbefore running this line.
A signal must be raised by an earlier line than any line that waits on it. Signals let one decoder’s schedule react to another’s, e.g. stream syndromes to decoder 0 until decoder 1 has replied.
If a decoder reply reports an error other than 4 (not ready), the run
stops. Lines that never ran have status -1, and the reason is in
result.warnings.
Syndrome Sources
A syndrome source produces one round of syndrome bits at a time. Each source
has an integer ID, which source= refers to. Any source can be used with
until=; a stream whose source runs out first stops early with status
101.
Type |
Description |
How to create |
|---|---|---|
|
Replays fixed rounds in order. |
Python: CLI: |
|
Generates rounds on demand from a Stim memory circuit ( |
Python: CLI: |
|
Raw measurements from a CUDA-Q QEC |
Python only: |
Sessions
A session connects the emulator to one decoder, chosen by session=N in
the schedule.
Session |
Description |
How to select |
|---|---|---|
|
Runs the decoders from a decoder configuration in the same process. |
Python: CLI: |
|
Sends calls over UDP to a running decoding server. |
Python: CLI: |
|
Sends calls over RDMA (CPU RoCE) to a decoding server started with
|
Python: CLI: |
|
Discards every call. Measures the emulator’s own overhead. |
Python: CLI: |
Run Options
These options behave the same in Python and on the command line. Python takes
whole nanoseconds (_ns) or milliseconds (_ms). The command line takes a
duration with a unit (ns, us, ms, or s); timeouts must be a
whole number of milliseconds. The tick and every timeout must be positive.
Python |
Command line |
Default |
Description |
|---|---|---|---|
|
|
1 µs |
Length of one schedule tick. |
|
|
20 ms |
Setup time between starting the run and tick 0. |
|
|
200 ms |
How long a UDP request waits for its reply. |
|
|
200 ms |
How long a CPU RoCE request waits for its reply. |
|
|
5 s |
How long to wait for the connection to a CPU RoCE server. |
|
|
8, 256 |
CPU RoCE ring size, in slots and bytes per slot. Must match the
server’s |
A request with no reply within its timeout is an error, which stops the run.
Output Format
The output has one CSV row per schedule line, in schedule order. Times are in
nanoseconds from the start of the run. Columns that list one value per request
(one per round for stream) are space-separated.
Column |
Description |
|---|---|
|
The schedule line (0-based), the decoder it called, and its operation. |
|
When the line was due, when it started sending, and when its last reply arrived. |
|
|
|
Rounds actually sent ( |
|
|
|
Bits sent and bits received, as |
|
|
|
Each request’s ID, for matching against decoder server logs. |
|
|
|
When each request was sent, and when its reply arrived ( |
|
Each request’s status: the decoder status codes above ( |
In Python, result.records holds one dict per CSV row, keyed by the column
names above.