Playbook · DGX Spark
What a CUDA graph records and replays, why it costs memory and start-up time, and how to cut that cost in vLLM and SGLang without guessing.
Do not turn graphs off in a setup that works. Try every change on a copy, and expect a restart.
Checked on 26 November 2026 against: NVIDIA's CUDA guide; PyTorch's notes; vLLM 0.34.0 and SGLang 0.5.23 documentation and source. Nothing was run or measured. We have not yet run this playbook start to finish on our own hardware.
Watch, or step through
Each part has a short video and its own slides, with each warning before the step it is about. Press Next step when you are ready. The page remembers your place.
How CUDA graphs work. Here's how CUDA graphs work on DGX Spark. Part two shows how to shrink what they cost.
The AI stack. Start at the bottom: the machine. Its GPU runs small programs called kernels.
Every launch costs time. Normally the processor sets up each kernel launch. Then it launches it on the GPU. And it pays that cost again for the next one.
Record once, replay often. Capture records the work instead of running it. New data goes into the same memory places. One launch then replays all of it. The main saving is launch work, not the maths.
What must stay fixed. Shapes are fixed. Another size needs another graph, or padding. The processor can't wait on the GPU, or make ordinary data decisions, inside. Processor work isn't recorded, so a replay skips it. And the memory addresses must stay put.
Memory and start-up time. Graphs keep memory, from the same pool as the model. Servers capture a set of sizes before serving, so starting takes longer. In vLLM, a batch with no graph big enough runs the normal way.
Record, then replay. Part two shows the settings, and how to shrink graphs without guessing.
9 steps
Shrink them, and measure. Part two: making CUDA graphs smaller, one measured change at a time. Work on a copy, when nobody needs the server.
Write down the baseline. Save the exact start command that works, and its versions. Note the time to ready, and the memory lines in the log. Time your own typical requests, quiet and busy.
See what you use. This vLLM option reports which graphs your requests really use. Adding it restarts the server.
One change at a time. First, allow only as many requests at once as you need. The cost: fewer run together. Next, capture fewer sizes. Bigger batches then run the normal way. Last, try a smaller graph mode. Decoding can be slower.
A shorter list. In vLLM 0.34, a decode cap looks like this. In SGLang, this limits the largest decode batch.
Turning graphs off. Turning graphs off only tests whether they're involved. It can cost speed. Never add enforce eager to a tuned recipe that works. Afterwards, go back to your saved command.
Measure, then keep. Keep a change only if your own numbers say it's worth it.
9 steps
The drawings in the videos and slides are our own illustrations, not the makers’ screens.
On this page
Written from NVIDIA, PyTorch, vLLM and SGLang documentation and their public source, read on 26 November 2026, with vLLM 0.34.0 and SGLang 0.5.23 in mind. Your version may differ. We have not run these steps or measured anything on a DGX Spark for this guide.
Part 1
Normally the processor prepares and launches GPU work one kernel at a time, and pays that cost for every launch. A CUDA graph describes many operations and the order between them. It is set up once and can then be launched many times with little overhead. NVIDIA’s guide calls the stages definition, instantiation and execution.
PyTorch builds graphs by capture: while a stream is being captured, GPU work is written down instead of run. A replay runs the same kernels with the same arguments, using the same memory addresses. New data goes into those same places before each replay.
The main saving is the processor’s launch work. It does not remove the maths: PyTorch says kernels also run slightly faster in a replay, but skipping processor overhead is the main benefit. How much that is worth depends on how much of your time was overhead.
| Rule | What it means for you |
|---|---|
| Shapes are fixed | A graph captured for one size serves that size. Other sizes need their own graph, padding to fit, or normal running. |
| No waiting for the GPU inside | A call such as .item() is not allowed during capture. |
| No ordinary Python decisions | A branch chosen from data cannot be replayed as Python. Special graph-aware control flow exists, with limits. |
| Processor work is not recorded | PyTorch warns it is skipped on replay. The result can be wrong without an error. |
| Memory must stay put | The captured addresses stay reserved. Freed or reused memory can cause illegal access or corrupted values. |
Warm the code up before capture. Changing only values or addresses can be done by updating a graph; a changed structure needs a new one (NVIDIA’s guide).
Part 2
A DGX Spark’s processor and GPU share one 128 GB pool. A captured graph keeps memory of its own. PyTorch gives captures a private pool, which graphs can share if they never run at the same time; it names vLLM as a server that does this.
Server software captures a set of sizes before it serves, so that requests do not wait for capture. vLLM says all its compiling finishes before it serves any request. The price is a longer start: each size is warmed up and captured.
In vLLM 0.34.0 there are two sets of graphs. Decode graphs, for batches where every request adds the same number of tokens, are chosen by the number of requests. Graphs for batches that include reading a prompt are chosen by the number of tokens. A batch uses the smallest suitable graph that is big enough. If none fits, it runs eager, the normal way without a graph. So a batch that falls back is slower to launch, and more or wider graphs take more memory and time (vLLM 0.34.0 settings source). Some attention methods support full graphs only for some batches, and vLLM then lowers the graph mode.
Part 3
Before you change anything, keep a copy of the start-up log of the setup that works. These are what we found in the vLLM 0.34.0 source; the wording changes between versions.
| Look for | What it tells you |
|---|---|
Progress bars Capturing CUDA graphs (PIECEWISE) and (FULL) | Which kinds are captured, how many, and how long it takes. |
CUDA graph pool memory: | Actual and estimated graph memory. It is printed when an estimate was made, so it may be absent. |
| The line giving the total start-up seconds, with compile seconds in brackets | How much of the start is profiling, cache creation and warm-up, and how much is compiling. |
| A warning that CUDA graph memory profiling is disabled | Graph memory is not being counted when the cache is sized. vLLM warns this can run out of memory. |
With VLLM_LOGGING_LEVEL=DEBUG, CG Capture: lines | Each captured mode and batch size. The log gets very long. |
See the capture code and the worker code. For a Docker container, docker logs CONTAINER shows the log.
While serving, --cudagraph-metrics adds figures at each logging interval: padded and unpadded tokens, and which graph modes ran and how often. This shows what your real requests use. Adding it means restarting the server.
Part 4
Leave a tuned recipe that works as it is. Try changes on a copy. Every change here needs a server restart, which ends service for its users.
vLLM 0.34.0 has one model runner, called V2. The settings go inside --compilation-config.
| Setting | What it controls |
|---|---|
cudagraph_mode | FULL_AND_PIECEWISE (vLLM’s usual default with piecewise compile; most memory, longest capture), FULL, FULL_DECODE_ONLY, PIECEWISE, NONE. |
max_decode_cudagraph_capture_requests | Largest decode graph, counted in requests. |
decode_cudagraph_capture_request_sizes | Your own list of decode sizes. An empty list captures none from this list. |
max_prefill_cudagraph_capture_tokens | Largest prompt-side graph, counted in tokens. |
prefill_cudagraph_capture_token_sizes | Your own list of those token sizes. |
cudagraph_capture_sizes, max_cudagraph_capture_size | The older names. vLLM marks them deprecated with V2. |
Set a list or a cap for each side. The two sides are separate. Draft models for speculative decoding have extra rules; read the setting descriptions. --enforce-eager is different: it turns off CUDA graphs and torch.compile.
Memory sizing. vLLM 0.34.0 turns on an extensible KV cache by default on CUDA, which it says sizes the cache from the memory free after capture and warm-up, and falls back to an estimate where the driver lacks support. We have not checked which a DGX Spark gets. vLLM also has an estimate pass, on by default; VLLM_MEMORY_PROFILER_ESTIMATE_CUDAGRAPHS=0 turns it off. We do not suggest turning it off.
SGLang sets graphs for two phases: decode and prefill (server arguments). Its online pages can be newer than your release, so check python3 -m sglang.launch_server --help.
| Flag | What it controls |
|---|---|
| --cuda-graph-backend-decode | full, breakable or disabled. |
| --cuda-graph-backend-prefill | full, breakable (its docs give this as the CUDA default) or disabled. |
| --cuda-graph-max-bs-decode, --cuda-graph-max-bs-prefill | Largest batch captured for each phase. |
| --cuda-graph-bs-decode, --cuda-graph-bs-prefill | Explicit lists of batch sizes. |
| --cuda-graph-max-seq-len-prefill | Longest prompt a prefill graph takes; longer ones run eager. |
A breakable graph is split into captured pieces with normal code between them (SGLang’s description). SGLang’s online docs also describe saving graphs to disk with an extra package. We did not find that setting in the 0.5.23 arguments we read, and the page describes its ready-made package as Linux x86_64, while DGX Spark is an Arm system. So we do not suggest it.
Compiling and capturing are two steps. Compiling builds faster code; a graph records launches. PyTorch’s compile mode reduce-overhead uses CUDA graph trees, which share one memory pool across captures. vLLM splits its compiled model around attention for piecewise graphs, and can include attention in full graphs where the attention method supports it. SGLang’s page marks its --enable-torch-compile as no longer maintained.
vLLM keeps compile results under ~/.cache/vllm (VLLM_CACHE_ROOT), which can shorten the next start. A change to the model, settings, related VLLM_* variables, PyTorch or GPU makes it compile again (vLLM optimization page). It stores compiled code; do not expect it to remove capture.
Our advice. With Docker, keep that folder on a mounted volume, or it goes when the container is removed.
To avoid capturing again and again, or falling back: capture once, after warm-up and outside your request loop; keep shapes fixed, padding to a few set sizes; hold on to the input and output tensors; copy new data into them, then replay. PyTorch calls its graph API beta. Follow its examples, which also show the stream rules.
Part 5
Change one thing, restart, measure, and keep or undo it. The numbers below only show the form of a setting. They are not advice for your model.
Work on a copy, when nobody needs the server. Each test restarts it. Fewer or smaller graphs can make busy periods slower.
Save the exact start command, versions, the log, the time to ready, any graph memory line, the KV cache size the log reports, and free -h. Time a few of your own typical requests, one at a time and as many together as you really get.
vllm --version
free -h
Add --cudagraph-metrics to the copy and run your normal load for long enough to see busy and quiet times.
--max-num-seqs sizes per-request buffers and graph capture, and vLLM’s memory page says limiting it and the context length saves memory. Cost: fewer requests run at once, or shorter conversations fit.
With vLLM 0.34.0, a cap or a short list on each side:
vllm serve MODEL --compilation-config '{"max_decode_cudagraph_capture_requests": 8}'
vllm serve MODEL --compilation-config '{"decode_cudagraph_capture_request_sizes": [1, 2, 4, 8]}'
Use one of these, not both, and keep your recipe’s other options. On older vLLM the form was:
vllm serve MODEL --compilation-config '{"cudagraph_capture_sizes": [1, 2, 4, 8]}'
Cost: a batch between two sizes is padded to the next; one above the largest suitable graph runs eager. vLLM notes that decode graphs no wider than the widest prompt-side graph mostly reuse its memory, so trimming those may save little memory.
These examples shrink the decode side only. The prompt side has its own settings, listed under Settings.
SGLang’s matching step is a lower largest batch:
python3 -m sglang.launch_server --model-path MODEL --cuda-graph-max-bs-decode 8
vllm serve MODEL --compilation-config '{"cudagraph_mode": "PIECEWISE"}'
vLLM says the two-kind default uses the most memory and takes longest to capture. Its -O1 level also uses piecewise graphs, with lighter compiling. Cost: decode can be slower. FULL_DECODE_ONLY saves the piecewise graphs’ memory but runs other batches without graphs. Not every attention method supports every mode.
Success: the server starts, memory or start-up time improved by an amount that matters to you, and your timed requests are still fast enough at both quiet and busy times. Otherwise go back to the saved command and restart.
In the code of our Mac app 1.0.59, the Launcher has a CUDA GRAPHS choice for SparkRun recipes. Keep Recipe default for a recipe that works. The other two add vLLM’s deprecated --cudagraph-capture-sizes after --; they are not SGLang settings, and we have not tested them. The command box shows what would be sent. See the SparkRun guide.
Part 6
| What you see | What it may mean, and what to try |
|---|---|
| Out of memory during capture or just after | Check what else holds memory. Then try a lower request limit, fewer sizes, or your server software’s memory share, one at a time. |
SGLang: Capture cuda graph failed | Its 0.5.23 message suggests, in turn, a smaller --mem-fraction-static, a smaller --cuda-graph-max-bs-decode, and last, turning decode graphs off, which it says costs a lot of speed. |
| Start-up is suddenly much slower | The compile cache may have missed after an update or settings change, or was inside a removed container. Compare logs. |
| Slower only when busy | Batches may be larger than any graph. Look at the graph metrics. |
| Wrong output or illegal memory access in your own code | Check for changed shapes, freed or moved tensors, and processor work inside the captured part. |
| A hang with SGLang across two machines | SGLang’s arguments page suggests trying both disable flags if you meet a deadlock. |
Never add --enforce-eager to a tuned recipe that works. It removes CUDA graphs and torch.compile, and vLLM says it costs steady decoding speed. Turning graphs off answers one question: are graphs involved? It is not the fix. Restarting ends service.
On a copy, this vLLM test turns off only the graphs. vLLM calls NONE good for debugging.
vllm serve MODEL --compilation-config '{"cudagraph_mode": "NONE"}'
This one also turns off compiling:
vllm serve MODEL --enforce-eager
In SGLang 0.5.23 the test is --disable-decode-cuda-graph and --disable-prefill-cuda-graph. If the problem stays, graphs were probably not the cause.
Remove the test setting, or go back to your saved start command, and restart. Then check the log and your timed requests against the baseline. More flags: our flag reference.
Next
Server AI Hub is our app for looking after a DGX Spark. You do not need it to follow this playbook. It is coming soon to the App Store and the Microsoft Store.
Sources
General guidance only, in our own words, read on 26 November 2026. You use these steps at your own risk. NVIDIA, CUDA and DGX Spark are trademarks of NVIDIA Corporation. PyTorch, vLLM, SGLang, Docker and other names belong to their owners. 6ixLabs is not affiliated with or endorsed by NVIDIA or these projects.