Every flag on dlm serve, grouped by concern. Run dlm serve --help for the authoritative list on your build.
Model & network
Flag
Default
Purpose
--model-path
—
Directory with config.json + *.safetensors, or a .gguf file.
--host
127.0.0.1
Bind address.
--port
8000
TCP port.
--context-length
8192
KV context window in tokens.
--lora DIR
—
A PEFT LoRA adapter (adapter_config.json + adapter_model.safetensors) merged into the weights as they load, so the adapted model runs at the base model's speed and size. Plain LoRA on a decoder layer's projections of a safetensors checkpoint; anything else is refused.
Memory & precision
Flag
Default
Purpose
--quant int4 | int8
checkpoint dtype
The primary memory lever. Quantizes the weights at load — int4 is 4x smaller, int8 2x — so more of the model stays resident and streaming shrinks or stops. Omit it and dlm computes in the checkpoint’s own precision. See Quantization.
--vram-budget-gb
live query
Manual upper VRAM cap in gigabytes. Overrides the live device query.
--safety-margin-gb
VRAM ÷ 10, 0.25–1.5
VRAM cushion (GiB) held back for transient allocations: a tenth of the card's VRAM, between 0.25 and 1.5 (1.5 without a GPU). Lower it to keep more layers resident; raise it if you hit OOM.
--ram-cache-gb
auto with --stream
Host-RAM budget (GiB) for the tiered layer cache between NVMe and GPU, so an evicted layer is not re-read from the checkpoint — roughly 2x on the streamed path. On with --stream when the whole layer set fits in a quarter of physical RAM (at least 4 GiB), off otherwise, since a smaller cache never hits on a cyclic scan. 0 disables it.
--kv-quant
auto
KV cache precision: auto | f16 | f32 | int8 | int4. On the GPU, auto is int8 — 56% of fp16’s memory, within 0.005 nats per token of fp16 on the models measured (fp16 for heads not a multiple of 32 wide); f16 is near-exact, f32 exact, and int4 is stored as int8. On the CPU kernels, auto and f16 give f32; int8 is about half the memory and int4 a quarter, with more error. none is accepted as an alias for f32.
--lm-head-int4
off
Hold the GPU's LM head in int4. On Qwen2.5-0.5B bf16, batched decode about 9% faster (batch 1 within noise) for +0.025 nats of mean NLL. Off, the head stays as the checkpoint holds it, or int8 for a model quantized with --quant.
--expert-cache-gb
VRAM left
VRAM budget for the routed-expert cache when a Mixture-of-Experts model streams on the GPU. Defaults to the VRAM left after the resident layer window; ignored for dense models.
Compute & streaming
Flag
Purpose
--stream
Hold only a bounded window of layers in memory — VRAM on --device gpu, host RAM on --device cpu — and materialize the rest on demand, evicting the most recently used layer (layers come round in a cycle, so LRU would evict the one needed next). Lets a model exceed the resident budget. On the GPU, a model whose weights don't fit streams without the flag; the startup banner's placement line says so.
--gpu-layers N
Hold only the first N layers in VRAM and run the rest on the CPU, where their weights already sit (llama.cpp's -ngl). An alternative to --stream for a model too big for the card — measure both with dlm bench. GPU only; not with --stream or --multi-gpu-ids.
--resident-layers N
Size of the streaming window. Defaults to the VRAM plan's layers_to_load.
--prefetch-depth N
CPU streaming only: layers to prefetch ahead (default 1; 0 disables). Clamped to the window minus one. On the GPU the worker always loads the next layer the pass is missing.
--auto-prefetch
CPU streaming only: auto-tune the prefetch depth at runtime from measured load-vs-compute time, instead of a fixed depth.
--device gpu | cpu
Select the compute kernel. GPU is the default on a cuda-kernels build; cpu forces the host kernel. If gpu is chosen but no device is usable, dlm warns and falls back to CPU.
Tokenization
Flag
Purpose
--chat-template
auto (default) detects the format from the checkpoint’s tokenizer_config.json; or name one: plain, chatml, llama3, llama2, mistral, gemma, phi3, deepseek.
--eos-token
Stop generation on this token id. Overrides the eos_token_id auto-detected from config.json; omit to use that.
Tokenizers load automatically from the model directory. See Model support for what’s detected.
Security
Flag
Purpose
--api-key
Require a key on every route except the /, /health and /healthz liveness probes — /metrics included. Accepts Authorization: Bearer or x-api-key. See Deployment & security.
--cors-origin
Allow browsers on this origin (e.g. http://localhost:3000, or * for any) to call the API. Off by default: without it a page on another origin cannot read dlm's replies.
--cluster-secret
Shared secret authenticating the master↔worker link. Set the same value on the master and every worker; workers reject peers that don't present it. Falls back to the DLM_CLUSTER_SECRET env var, which keeps it out of the process list. Omit only on a fully trusted network.
Batching & scaling
Flag
Purpose
--max-batch N
Requests decoded concurrently (default 8). Each holds its own KV, so on the GPU KV VRAM scales with it — raise it for throughput on a big card, lower it if a batch would exceed VRAM.
--queue-timeout SECS
Turn away a request that has waited this long to be admitted, with 503 and Retry-After, instead of letting a backlog grow without bound. A request already decoding runs to its end. Off (wait forever) unless set.
--speculative auto | off | ngram | draft | mtp
Propose several tokens and verify them in one pass; output is unchanged (greedy is exactly greedy, sampling follows the model's distribution). auto (default) uses the draft model if --draft-model-path is given, else n-gram lookup on the GPU or on a CPU model streamed from disk, else nothing. ngram proposes from the request's own context, with no second model. mtp proposes with the model's own multi-token-prediction head (Qwen3.5/3.6), run on the CPU beside the target. Hybrid models (Qwen3.6) speculate too: their recurrent state is checkpointed and rolled back on a rejected guess.
--draft-model-path
A small draft model for speculative decoding, or an EAGLE-3 head (its config.json names an *Eagle3 architecture; resident GPU only, convert a pytorch_model.bin head to model.safetensors first). Not with --stream or --gpu-layers.
--draft-gamma N
Tokens proposed per speculative round, by the draft model or n-gram lookup (default 4).
--prefix-cache-size N
Cache up to N prompt prefixes so a request that starts like an earlier one skips re-prefilling that part (0 = off). On by default on the GPU (64), where a cached prefix shares its KV blocks; off on the CPU unless set, where each entry is a RAM copy. No effect with a draft model.
--prefix-cache-dir DIR
Also write cached prefixes to DIR so they survive a restart: a long system prompt is prefilled once, not once per start. Each model and setting (weights, --quant, --kv-quant, device, LoRA, dlm version) gets its own subdirectory; at start-up the newest entries load, up to --prefix-cache-size and 1 GiB. Needs the prefix cache on.
Coordinate layer shards across worker nodes and serve the OpenAI endpoint.
--distributed-mode worker
Serve a layer shard to a master over TCP.
--worker-timeout-secs SECS
Worker mode: per-connection read/write timeout (default 30). A peer quiet this long is dropped; raise it for slow links.
Telemetry
Flag
Purpose
--telemetry
Expose GET /v1/telemetry, a Server-Sent Events stream of per-layer flow events — what each layer cost at each stage of disk read → RAM cache → pinned staging → VRAM → compute, in bytes and durations. Off by default. Collection runs only while something subscribes; events carry no prompt or completion text. Behind --api-key like /metrics.
Sampling defaults
Sampling is set per request on the HTTP API (temperature, top_p, top_k, min_p, repetition_penalty, seed, stop), not as serve flags. Temperature 0 is deterministic greedy. See the HTTP API reference.