Deployment & security
dlm serve is a plain HTTP server. In production, require a token, bind deliberately, and terminate TLS at a proxy in front of it.
Authentication
Pass --api-key to require a key on every route except the liveness probes (/, /health, /healthz). Requests without a matching Authorization: Bearer … (OpenAI) or x-api-key (Anthropic) header are rejected with a 401.
GET /metrics, which leaks request and token counts — so a Prometheus scrape needs the key too. Only the liveness probes stay open, which is what lets a load balancer health-check the server without holding a credential.dlm serve --model-path /path/to/model --api-key sk-secretcurl -H 'Authorization: Bearer sk-secret' http://127.0.0.1:8000/v1/modelscurl -H 'Authorization: Bearer sk-secret' http://127.0.0.1:8000/metricsBind address
--host 127.0.0.1(default) keeps the server local to the machine.--host 0.0.0.0exposes it on the network — only do this behind a firewall or proxy, and always with--api-key.- A browser UI on another origin needs
--cors-origin http://localhost:3000(or*for any). Without it the request succeeds and the browser discards the answer. It is off by default, so a server on a shared network does not hand its answers to any page that asks.
Built-in hardening
- The request body is size-capped to guard against a hostile
Content-Length. - When enabled, auth covers every endpoint —
/v1/*and/metricsalike — except the/,/healthand/healthzliveness probes. - In a cluster,
--cluster-secret(or theDLM_CLUSTER_SECRETenv var, which keeps it out of the process list) authenticates the master↔worker link — the same value on every node. Without it a worker runs shard compute for anyone who can reach its port; omit it only on a fully trusted network.
Load shedding
Up to --max-batch requests (default 8) decode at once; the rest wait in a queue (on the GPU, until the KV pool can hold a request’s prompt plus max_tokens). By default they wait as long as it takes. --queue-timeout SECS turns away a request that has waited that long with 503 and Retry-After — an HTTP error even for "stream": true, since a response starts only once the request is admitted. A request already decoding always runs to its end. A request’s priority field (OpenAI endpoints, default 0, lowest first) orders the queue; it does not preempt a running request.
dlm serve --model-path /path/to/model --api-key sk-secret --queue-timeout 30Monitoring
GET /metrics serves Prometheus counters (requests, prompt and completion tokens, and — when streaming — layer cache hits, misses, evictions and prefetches) and gauges, as of the scheduler’s latest step. The gauges are what to alert or scale on:
dlm_requests_running— requests decoding now.dlm_requests_waiting— requests queued for a slot.dlm_kv_free_tokens— free KV capacity, where the GPU pages its KV.
--telemetry adds GET /v1/telemetry, a Server-Sent Events stream of per-layer timings and byte counts — no prompt or completion text. Like /metrics, it sits behind --api-key.TLS via a reverse proxy
dlm serves plain HTTP — it has no built-in TLS. Terminate HTTPS at a reverse proxy (Caddy, nginx) and forward to dlm on localhost.
$ Caddyfile
api.example.com {
reverse_proxy 127.0.0.1:8000
}
Docker
The engine repo has a Dockerfile. Build it from a clone: the image carries the CUDA kernels for Turing to Blackwell (sm_75 to sm_120) with the CUDA runtime linked in, so it needs only the NVIDIA driver, and is 165 MB.
docker build -t dlm .docker run --gpus all -p 8000:8000 -v /path/to/models:/models dlm serve --model-path /models/Qwen2.5-0.5B-Instruct --host 0.0.0.0--gpus allneeds the NVIDIA Container Toolkit (or Docker Desktop on Windows). Without it the container runs on the CPU.--host 0.0.0.0makes the port reachable from outside the container; add--api-keybefore exposing it further.
Run it as a service
A minimal systemd unit keeps the server running and restarts it on failure:
$ /etc/systemd/system/dlm.service
[Service]
ExecStart=/home/USER/.local/bin/dlm serve \
--model-path /srv/models/model --api-key sk-secret
Restart=on-failure
[Install]
WantedBy=multi-user.target
On Unix, SIGTERM or SIGINT shuts down gracefully: dlm stops accepting connections and drains in-flight requests for up to 8 seconds — inside the 10-second grace period Docker and Kubernetes allow before SIGKILL — so a deploy or systemctl restart doesn’t cut live requests or leave an SSE stream without its final chunk.