Skip to content

Quantization

--quant is the first flag to reach for on a card that can’t hold the model. Quantizing the weights at load shrinks each layer 2–4x, which usually means more of the model stays resident and streaming shrinks or stops entirely — worth far more than any amount of making streaming itself faster.

There is no default

Omit --quant and dlm computes in the checkpoint’s own precision — it reads the dtype the file actually holds (bf16/f16 → 16-bit, f32 → 32-bit) and converts to f32 only in the register that consumes each weight. There is no default to get wrong, and nothing is upsized: an f32 copy of bf16 weights is lossless (every bf16 value is exactly an f32), so it would buy no precision while doubling VRAM, PCIe per streamed layer, and GEMV bandwidth.

Schemes

--quantBytes/paramWhat happens
(omitted)2.0 / 4.0The checkpoint's own dtype — no conversion.
int40.5Quantized at load — 4x smaller, coarsest (16 levels per group).
int81.0Quantized at load — 2x smaller, 256 levels per group.
fp16 / f322.0 / 4.0Accepted only if it matches the checkpoint — dlm does not convert between float widths.

Both quantized modes are group-affine in groups of 128 — w = (code − zero[g]) × scale[g] — decoded in-register by the same kernel that reads the float dtypes. A scheme dlm cannot actually deliver is an error, not a silent no-op: --quant never describes weights that don’t exist.

What it buys, measured

On a 4 GB GTX 1650 running Qwen2.5-1.5B — 3.3 GiB of bf16 weights against 3.2 GiB free, i.e. a model that does not fit. Decode tok/s at batch 1, prompt 256, context 1024; ranges span repeated runs (2026-11-11):

SettingResidentDecode tok/s
bf16, --stream27 / 2821–27
--quant int8all 28 (no streaming)64–65
--quant int4all 28 (no streaming)79–87

int4 is faster than int8 for the same reason it is smaller: the GEMV is bandwidth-bound, so halving the bytes read halves the work. Pick int8 when int4 costs too much accuracy — its 256 levels per group track a weight’s range ~17x finer than int4’s 16 — and pick int4 when you need the model to fit at all.

$dlm serve --model-path ./models/Qwen2.5-1.5B-Instruct --quant int4

Caveats

Both are lossy: group-affine rounding without the calibration GPTQ/AWQ use. Check your model’s output rather than assuming. Three things worth knowing:

Quantize once: dlm pack

A model streamed from disk at --quant pays for quantizing again every time a layer misses the RAM cache, and reads the full 16-bit weights to do it. dlm pack does that work once and writes a copy with the weights already quantized. The copy is an ordinary model directory that scores bit for bit what the original does at the same --quant, from about half the disk.

$dlm pack --model-path models/Qwen3-1.7B --quant int4 --out models/Qwen3-1.7B-int4
$dlm serve --model-path models/Qwen3-1.7B-int4 --stream
Qwen3-1.7B int4, streamed, GTX 1650OriginalPack
Decode tok/s0.06–0.071.0–1.1
Prefill tok/s4–548–65
On disk4.1 GB2.1 GB

Measured with four layers resident and no RAM cache, so every other layer is read again each token. A pack loads only at the precision it was made for. GGUF and GPTQ files need no pack, since they are already quantized. Weights the loader slices by rows (Phi-3’s fused QKV, Qwen3.5’s stacked experts) stay 16-bit in a pack and are quantized at load as before.

Already-quantized checkpoints (GPTQ / AWQ / GGUF)

--quant quantizes a float checkpoint at load. A checkpoint that is already quantized is a different thing, and dlm loads those directly — no --quant is needed, or accepted.

$dlm pull Qwen/Qwen2.5-0.5B-Instruct-GPTQ-Int4 --local-dir models/qwen-gptq
$dlm serve --model-path models/qwen-gptq

See Model support for the full list of formats and quantization types.

The LM head: --lm-head-int4

The vocabulary-wide LM head is a large share of a small model’s bytes per token (272 MB of Qwen2.5-0.5B bf16’s ~1 GB). --lm-head-int4 holds the GPU’s LM head in int4. It is opt-in, since it costs accuracy; without it the head stays at the checkpoint’s precision, or int8 for a model quantized with --quant. On a GTX 1650, Qwen2.5-0.5B bf16: batch-8 decode about 9% faster (batch 1 within noise), for mean NLL 2.841 → 2.865. It pays most on a bf16 head; a GGUF head is already 6–8 bits.

Quantizing the KV cache instead

--quant sizes the weights. --kv-quant {auto,f16,f32,int8,int4} is an independent knob that sizes the KV history. At long context the KV cache can exceed the weights, so a smaller one buys context or batch in the same budget.

See Performance tuning.

See the budget math for how M_layer_weight feeds the resident-layer count, or try the VRAM calculator to see what a given --quant does to your card.