Build & configuration
The GPU path is vendor-neutral behind a Cargo feature — everything above the backend (storage, profiler, pipeline) is identical across vendors. With no feature, the crate builds and runs a page-aligned host fallback, so it’s fully testable off-GPU on any machine.
Cargo features
| Feature | Vendor | Runtime | Env var |
|---|---|---|---|
cuda | NVIDIA | cudart (dynamic) | CUDA_PATH |
cuda-kernels | NVIDIA | dynamic cudart + compiled kernels.cu (nvcc) | CUDA_PATH |
cuda-static | NVIDIA | static cudart baked in — runs on the driver alone | CUDA_PATH |
rocm | AMD | amdhip64 — memory only (no compute kernels) | ROCM_PATH |
rocm-kernels | AMD | amdhip64 + compiled kernels.cu (hipcc) — compute, unverified on hardware | ROCM_PATH |
| (none) | — | host fallback | — |
NVIDIA (CUDA) is the only backend with working compute kernels — verified on real hardware against the CPU oracle (
tests/gpu_parity.rs). rocm-kernels compiles the same kernels.cu with hipcc for AMD; it type-checks and builds, but has not yet been parity-verified on a real AMD card, so validate with dlm doctor before trusting output. The plain rocm feature provides memory management only — VRAM query and pinned host memory — so with it inference runs on the CPU.cuda-kernelsadditionally compilessrc/gpu/kernels.cuwith nvcc and enables the devicerun_block. Building a binary that runs the kernels needs nvcc + a GPU.- The prebuilt release ships the
cuda-staticbuild (Linux and Windows x86-64). A static CUDA runtime means the toolkit is needed only at build time — the shipped binary runs on any machine with just the NVIDIA driver.cuda-staticis a strict superset ofcuda-kernels, so there is no separate dynamic release asset. - The two GPU features are mutually exclusive. With one enabled, buffers are genuine page-locked memory and
mem_get_inforeports the live device’s free VRAM.
cargo check --features cuda-kernels type-checks the Rust FFI without the toolkit; building a binary that runs the kernels needs nvcc + a GPU.Build commands
Type-checking works without either toolkit installed; building and linking require the corresponding runtime on the link path.
$
cargo check --features cuda # validates the CUDA FFI, no linking$
cargo check --features rocm # validates the ROCm/HIP FFI, no linking$
CUDA_PATH=/usr/local/cuda cargo build --features cuda-kernels$
ROCM_PATH=/opt/rocm cargo build --features rocmOn a CUDA machine,
cargo test --features cuda-kernels runs the GPU parity test — it decodes the same random model on both the CPU and GPU kernels and asserts the hidden states match. The CPU kernel is the correctness oracle for the device code.Environment variables
| Variable | Used by | Purpose |
|---|---|---|
CUDA_PATH | cuda / cuda-kernels | Locate the CUDA toolkit at build/link time. |
DLM_CUDA_ARCHS | cuda-kernels build | GPU architectures to compile for, comma-separated (default 75,80,86,89). Narrow it, e.g. 75, for a quicker local build. |
ROCM_PATH | rocm | Locate the ROCm/HIP runtime. |
HF_TOKEN | pull | Auth for gated/private Hugging Face repos. |
DLM_CLUSTER_SECRET | serve (distributed) | Shared master↔worker secret, in place of --cluster-secret — keeps it out of the process list. |
DLM_CPU | installer | Set to 1 to force the CPU build. |
DLM_INSTALL_DIR | installer | Change the binary install location. |
Device selection
- On a
cuda-kernelsbuild, generation and serving run on the GPU by default. --device cpuforces the CPU kernel.- When the GPU is selected —
--device gpu, or the default on acuda-kernelsbuild — and no GPU is usable, dlm warns and falls back to CPU on its own. - A CPU-only build defaults to CPU, and an explicit
--device gputhere errors with a clear message.
Distributed mode
Scale across GPUs and hosts. See Architecture & math for how each works.
| Flag | Effect |
|---|---|
--multi-gpu-ids 0,1,2 | Pipeline-parallel across local GPUs; only the hidden residual crosses the boundary. |
--distributed-mode worker | Serve a layer shard to a master over TCP (Protobuf-framed). |
--draft-model-path | Decode speculatively with a draft model. |