Performance and Cost#

What CUDA-Q Pulse costs, for people who size a control stack or a workflow around it: how long a compile takes and what it grows with, what a second call costs, and what checking and exporting a program for a controller cost. Each part gives the command that measures it on your machine.

Measured numbers that the documentation and announcements quote come with the command that measures each one again. They come from one machine and one build, not a guarantee; times in particular move with the machine and its load. Where this page states how a cost grows but gives no number, none has been published yet, and the script named there measures it.

What a compile grows with#

A compile traces the kernel, builds the module, runs the passes and schedules. It grows with the operations the kernel holds, not with the operations a run executes:

  • a loop the compiler keeps rolled holds its body once, whatever its trip count; a loop unrolled while tracing holds its body once per iteration (Controller.max_instructions in Quantum system API describes the two);

  • scheduled.metrics gives each stage’s time for any program (trace_ms, ffi_ms, passes_ms, schedule_ms, total_ms; see “Inspecting a compilation” in Compile and Inspect a Program).

The next section measures one large program, stage by stage. benchmarks/compiler/compile_time.py compiles six smaller workloads and compares them with a stored baseline.

QEC-Scale Compilation#

benchmarks/simulation/qec_scaling.py compiles one syndrome-extraction cycle of a rotated surface code of odd distance d, on \(2d^2 - 1\) qudits, with the default passes and the default schedule. Each repeat compiles from scratch, and the script prints each stage’s median over the repeats: tracing the kernel, building the module, the passes and the schedule.

The cycle is the standard one (Fowler et al., Phys. Rev. A 86, 032324 (2012), with the step order of Tomita and Svore, Phys. Rev. A 90, 062320 (2014)):

  • \(d^2\) data qudits and \(d^2 - 1\) ancillas, one per stabilizer: weight 4 in the bulk, weight 2 on the boundary;

  • a Hadamard on every X-check ancilla;

  • four steps of CNOTs, every stabilizer in parallel: an X check’s ancilla controls its data qudits in the order NW, NE, SW, SE, and a Z check’s data qudits control its ancilla in the order NW, SW, NE, SE;

  • the second Hadamard on every X-check ancilla, and a readout of every ancilla.

A CNOT is an echoed cross-resonance sequence: two cross-resonance pulses on the control’s drive line at the target’s tone, around an X pulse, and two SX pulses on the target. A Hadamard is an SX pulse between two phase shifts of the tone. The cycle has no reset and no feedback, and its pulse amplitudes are fixed, uncalibrated values: the benchmark measures compilation and simulates nothing. tests/test_qec_scaling.py checks that the stabilizers are those of the code and that no qudit is in two CNOTs of one step.

python benchmarks/simulation/qec_scaling.py --distances 31 --repeats 5

Distance

Qudits

Stabilizers

CNOTs

Operations

Length of the cycle

Compile time, median of 5

Peak memory of the process

31

1,921

960

3,720

30,011

1,480 ns

289 ms

about 67 MB

Of the 289 ms, tracing the kernel takes 220 ms, building the module 13 ms, the passes 24 ms and scheduling 31 ms. The peak memory is the maximum resident set size of the whole Python process, imports included, as getrusage reports it.

Host: a 32-core x86-64 Linux workstation (Ubuntu 22.04), idle apart from the benchmark, with Python 3.12 and NumPy 2.5 in a virtual environment that holds the wheel built from source at commit d62f3ff72 (a development build of 0.1.1, compiler and CPU simulation), running this script as it is in the repository. Each run of the command above is a new process; in six runs the median compile time was 286 to 295 ms and the peak memory 67 to 68 MB. The table gives a middle run. The host’s 1-minute load average was 0.00 before the runs and 0.15 after them.

--code gross compiles a cycle of the [[144,12,12]] bivariate bicycle (“gross”) code instead (Bravyi et al., Nature 627, 778 (2024)): 144 data qudits, 72 X checks and 72 Z checks of weight 6, with any two qudits allowed to couple. Its CNOTs run in twelve steps, the six terms of the Z checks and then the six of the X checks, each step one CNOT per check in parallel. That order measures every stabilizer; it is not the paper’s interleaved order of depth 7.

python benchmarks/simulation/qec_scaling.py --code gross --repeats 5

Code

Qudits

Checks

CNOTs

Operations

Length of the cycle

Compile time, median of 5

Peak memory of the process

[[144,12,12]]

288

144

864

6,354

3,560 ns

62 ms

about 43 MB

Of the 62 ms, tracing the kernel takes 48 ms, building the module 2.8 ms, the passes 5.0 ms and scheduling 6.7 ms. These come from the same host, build and session as the distance-31 row; in six runs of the command the median compile time was 61 to 63 ms and the peak memory 43 to 44 MB.

Calling again with new values#

A kernel compiles on its first call with new arguments; later calls reuse the compilation. float parameters stay arguments of the scheduled module, so a call with a new value binds it and compiles nothing, and a sweep over an amplitude compiles once (“Arguments” in Compile and Inspect a Program).

No number is published for this yet. To measure it, benchmarks/compiler/specialize_bench.py prints the median time of a new float value on a compiled kernel against a fresh compile, for kernels of growing size.

python benchmarks/compiler/specialize_bench.py

Checking and exporting for a controller#

Compiling for a control system checks the scheduled program against every controller, and a backend then reads the program. What the guide states about their cost (“Cost” in Write and Validate a Backend):

  • a control system without controllers adds nothing to compilation;

  • the export and the limit checks are native code;

  • the default export takes time and memory linear in a program’s executions; the structured one, and the checks, cost as much for a loop whose iterations repeat as its first two iterations and its last, whatever its trip count.

benchmarks/compiler/controller_export.py measures it on a round of error-correction shape on 32 qudits: a drive and a phase change on every drive line, a sync, a readout of half of the qudits, a sync. The round runs in a loop the compiler keeps, for 10 to 100,000 rounds. Each row is five runs in fresh processes. Check is the controller check a compile makes, timed again on its own. Flat export is the program with every execution listed; the kept-loop form holds a loop once, with its trip count.

python benchmarks/compiler/controller_export.py --rounds 10 100 1000 10000 100000 --repeats 5
Compile, check and export against rounds on 32 qudits; times in ms, median of 5 (lowest to highest)#

Rounds

Events

Compile

Check

Flat export

Flat export size

Kept-loop form size

10

532

11.3 (11.2 to 11.4)

2.4 (2.3 to 2.4)

1.9 (1.8 to 1.9)

191 kB

21.5 kB

100

5,032

12.7 (12.7 to 25.9)

2.7 (2.7 to 2.8)

13.3 (12.2 to 13.4)

1.82 MB

21.6 kB

1,000

50,032

12.7 (12.4 to 12.8)

2.9 (2.8 to 2.9)

151.4 (149.6 to 153.7)

18.3 MB

21.6 kB

10,000

500,032

12.7 (12.6 to 12.8)

2.8 (2.8 to 2.9)

1,524 (1,486 to 1,545)

185 MB

21.7 kB

100,000

5,000,032

12.4 (12.3 to 12.7)

2.8 (2.8 to 3.1)

14,658 (14,503 to 14,965)

1.87 GB

21.8 kB

What the table shows:

  • the compile and the check do not grow with the rounds: about 12.7 ms and 2.8 ms from 100 rounds to 100,000, and the kept-loop form stays near 21.7 kB;

  • the flat export grows with the events: 14.7 s and 1.87 GB at 100,000 rounds;

  • the same rounds written out one after another, which the script also measures, are the same events and the same flat export, but the compile and the check then grow with the rounds: 322.5 s and 66.2 s at 100,000 rounds, and the other form, with no loop to hold once, is 807 MB.

Host: a Linux x86-64 workstation with a 32-core CPU, idle apart from the benchmark, Python 3.12, with cudaq-pulse built from source at commit 550184a63 (a development build of 0.1.1, compiler and CPU simulation). The script’s default run, without --rounds, compiles and exports three fixed programs and is what the continuous integration runs at small sizes (--small).

What is checked on every change#

The perf-gate job of the continuous integration counts the work of the cases in benchmarks/perf_gate/cases.py (compiles of small and large kernels, binding new values, the controller export, the setup of a simulation) and blocks a change that makes one slower; CONTRIBUTING.md at the repository root describes it.

Simulation#

Simulation has a section of its own, Simulation. “How large and how long” there holds the adaptive T1 estimation statistic.