Skip to content

serve configuration

Every flag on dlm serve, grouped by concern. Run dlm serve --help for the authoritative list on your build.

Model & network

FlagDefaultPurpose
--model-path—Directory with config.json + *.safetensors, or a .gguf file.
--host127.0.0.1Bind address.
--port8000TCP port.
--context-length8192KV 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

FlagDefaultPurpose
--quant int4 | int8checkpoint dtypeThe 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-gblive queryManual upper VRAM cap in gigabytes. Overrides the live device query.
--safety-margin-gbVRAM ÷ 10, 0.25–1.5VRAM 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-gbauto with --streamHost-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-quantautoKV 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-int4offHold 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-gbVRAM leftVRAM 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

FlagPurpose
--streamHold 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 NHold 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 NSize of the streaming window. Defaults to the VRAM plan's layers_to_load.
--prefetch-depth NCPU 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-prefetchCPU streaming only: auto-tune the prefetch depth at runtime from measured load-vs-compute time, instead of a fixed depth.
--device gpu | cpuSelect 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

FlagPurpose
--chat-templateauto (default) detects the format from the checkpoint’s tokenizer_config.json; or name one: plain, chatml, llama3, llama2, mistral, gemma, phi3, deepseek.
--eos-tokenStop 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

FlagPurpose
--api-keyRequire 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-originAllow 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-secretShared 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

FlagPurpose
--max-batch NRequests 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 SECSTurn 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 | mtpPropose 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-pathA 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 NTokens proposed per speculative round, by the draft model or n-gram lookup (default 4).
--prefix-cache-size NCache 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 DIRAlso 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.
--multi-gpu-ids 0,1,2Pipeline-parallel across local GPUs.
--distributed-mode master --worker-nodes host:port,…Coordinate layer shards across worker nodes and serve the OpenAI endpoint.
--distributed-mode workerServe a layer shard to a master over TCP.
--worker-timeout-secs SECSWorker mode: per-connection read/write timeout (default 30). A peer quiet this long is dropped; raise it for slow links.

Telemetry

FlagPurpose
--telemetryExpose 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.

Full example

$dlm serve --model-path /srv/models/llama-70b --quant int4 --context-length 8192 --stream --resident-layers 29 --device gpu --api-key sk-secret --host 0.0.0.0 --port 8000
Environment variables (CUDA_PATH, HF_TOKEN, …) are documented on Build & features.