Learn / DGX Spark CUDA Graphs

CUDA graphs, part 1: how they work

Here's how CUDA graphs work on DGX Spark. Part two shows how to shrink what they cost.

Chapters

  1. 0:00Introduction
  2. 0:07Where this fits: The AI stack
  3. 0:14The problem: Every launch costs time
  4. 0:23The idea: Record once, replay often
  5. 0:35The rules: What must stay fixed
  6. 0:52The price: Memory and start-up time
  7. 1:05Wrap up
Read the transcript

Introduction

Here's how CUDA graphs work on DGX Spark. Part two shows how to shrink what they cost.

Where this fits: The AI stack

Start at the bottom: the machine. Its GPU runs small programs called kernels.

The problem: 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.

The idea: 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.

The rules: 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.

The price: 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.

Wrap up

Part two shows the settings, and how to shrink graphs without guessing.

Sources

More lessons