Skip to content

Latest commit

 

History

History
108 lines (87 loc) · 5.67 KB

interpose.md

File metadata and controls

108 lines (87 loc) · 5.67 KB

Cross-process CUDA memory

cuda-checkpoint checkpoints one process at a time and refuses memory another process maps: legacy IPC (cudaIpcGetMemHandle), VMM exported as POSIX file descriptors, multicast objects. vLLM's fast collectives (custom all-reduce, symmetric memory, FlashInfer, NCCL NVLS) and model-private workspaces (MiniMax, DeepSeek-V4.1, …) all live there. warmctl solves this once, below vLLM, with NVIDIA's cuInterpose:

  • libcuinterpose.so is preloaded into the engine. It records every cross-process object when it is created; cudaMalloc becomes a tracked VMM allocation, so legacy IPC can be re-created later.
  • Before the CUDA checkpoint, cuinterpose-coordinator --prepare saves the bytes of every shared allocation to host memory, which CRIU dumps, and releases the sharing while keeping every virtual address reserved. Its record goes into the snapshot as ipc/cuinterpose.state.
  • After the CUDA restore, --restore re-creates the allocations, imports and multicast objects at the same addresses and loads the bytes back. CUDA graphs, NCCL communicators and Lamport flags come back unchanged.

Nothing in warmctl knows which library shared what. A snapshot that holds cross-process memory without the interposer fails at the CUDA checkpoint.

When it is used

The profile's ipc decides:

ipc Engine Use
auto (default) interpose when the engine has more than one GPU process and every GPU supports VMM with POSIX handles, else native every profile
interpose under cuInterpose; the bake fails if a GPU lacks VMM with POSIX handles profiles whose fast collectives must not fall back
native stock: no preload opting out

Only an engine with more than one GPU process can share memory, so a TP1 engine never changes. The VMM check is a driver attribute read inside the donor before the engine starts (cuDeviceGetAttribute through libcuda.so.1, which the agent loads at run time), not a GPU name: an L40S TP2 engine, whose custom all-reduce shares memory over PCIe, is interposed like an H100 one; a vGPU without VMM runs native. The choice is recorded in the manifest and the restore follows it.

Packaging

make cuinterpose builds the pinned release in Docker (CUINTERPOSE_REF, CUDA headers from Docker Hub). make release puts the four files next to the binary under cuinterpose/. A bake copies them into the snapshot's adapter tree, so a restore runs the exact libraries the dumped processes have loaded and the coordinator that wrote their state.

Steps

Snapshot: sleep → checkpoint_prepare → ipc (--prepare) → cuda → freeze → dump → fs. Restore: install-fs → criu → thaw → cuda → ipc (--restore) → wake. After --prepare no process maps another's memory, so every CUDA owner restores in parallel.

Only processes with a cuInterpose control socket take part. A process opens it on its first intercepted CUDA call; one that only loaded the driver (an API server) holds no shared memory and takes the plain CUDA checkpoint.

The libraries are mounted read-only and with the store's file mode in donor and receiver: CRIU maps a library back only onto a file of the same path, size and mode.

Under the dmtcp backend nothing is mounted: the engine maps the runtime image's own build, and the snapshot's copy is its record (dmtcp.md).

Driver requirement for multicast

A restored process re-creates its multicast objects (NVLS, symmetric memory, DeepGEMM mega-MoE buffers) with cuMulticastAddDevice. On the r580 user-mode driver that call returns CUDA_ERROR_INVALID_DEVICE in any process restored by cuda-checkpoint, and the restore stops at RestoreMulticastDevices (ai-dynamo/snapshot#510). r595 and newer do not have the bug; the kernel driver may stay on 580. A DEP8 DeepSeek-V4.1-Flash engine with mega-MoE multicast buffers restores on 615.71.10 in 83 s.

The user-mode driver is the libcuda the engine loads: the host's, or a forward-compatible one the image ships (/usr/local/cuda*/compat), which the NVIDIA container runtime prefers when it is newer than the host's. vLLM's CUDA 13.4 images carry libcuda 615; its CUDA 13.0 images carry 580 and on a 580 host do not restore multicast; deploy/images/vllm-cu13compat615 puts 615 into one of the latter. cuda-checkpoint runs inside the container, so it loads the same libcuda as the engine. For multi-GPU engines on a 595+ host warmctl puts the host's libcuda first (LD_LIBRARY_PATH), so the engine and the host tools agree.

NCCL buffer registration in CUDA graphs

NCCL registers the user buffers of the collectives it captures into CUDA graphs so the kernels can read peers' buffers directly. The registration retains and exports the buffers' allocations, which under cuInterpose are the adapter's VMM mappings of the engine's cudaMalloc. On the r615 user-mode driver the first replay of a decode graph of 96 tokens or more then spins forever in every rank at idle power, with nothing waiting on the host; the same engine without CUDA graphs, and with graphs but without the registration, runs and restores. profiles/_defaults.yaml sets NCCL_GRAPH_REGISTER=0; the registration only matters for large buffers, and the collectives in a decode step are small. The 580 user-mode driver does not show the hang.

Cost

The interposer only sees allocation and mapping calls, never kernel launches. cudaMalloc through VMM is slower to allocate and rounds up to the 2 MiB granularity; PyTorch's caching allocator keeps that out of steady state. Measured on GLM-5.3-Flash prod TP8 against stock vLLM with the same flags: throughput and inter-token latency equal, restore 37 s. Preparing and restoring the shared memory takes 0.1–1.1 s.