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
| --quant | Bytes/param | What happens |
|---|---|---|
| (omitted) | 2.0 / 4.0 | The checkpoint's own dtype — no conversion. |
int4 | 0.5 | Quantized at load — 4x smaller, coarsest (16 levels per group). |
int8 | 1.0 | Quantized at load — 2x smaller, 256 levels per group. |
fp16 / f32 | 2.0 / 4.0 | Accepted 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):
| Setting | Resident | Decode tok/s |
|---|---|---|
bf16, --stream | 27 / 28 | 21–27 |
--quant int8 | all 28 (no streaming) | 64–65 |
--quant int4 | all 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 int4Caveats
Both are lossy: group-affine rounding without the calibration GPTQ/AWQ use. Check your model’s output rather than assuming. Three things worth knowing:
- Quantizing costs load time — it runs over every weight, and reads the full 16-bit tensors from disk regardless. The win is in VRAM and on the bus, not in what is read.
--streamholds the quantized layers in a host-RAM cache by default, since re-quantizing a layer on every window miss measured 12x slower. The default applies only when every layer fits under a quarter of physical RAM (at least 4 GiB); a quantized model bigger than that re-quantizes on every miss, so raise--ram-cache-gb, pack it (below), or drop--stream— once quantized, the model often no longer needs it.- A quantized weight is still lossy even if it fits. A model that fits but answers worse is not obviously a win.
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-int4dlm serve --model-path models/Qwen3-1.7B-int4 --stream| Qwen3-1.7B int4, streamed, GTX 1650 | Original | Pack |
|---|---|---|
| Decode tok/s | 0.06–0.07 | 1.0–1.1 |
| Prefill tok/s | 4–5 | 48–65 |
| On disk | 4.1 GB | 2.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-gptqdlm serve --model-path models/qwen-gptq- GPTQ 4-bit,
desc_act: false(classicgptqformat) — validated end-to-end against a real export. Its codes are relabeled into dlm’s int4 layout, not dequantized and re-quantized, so the accuracy the export’s calibration bought survives: generally better than the same model through--quant int4. - Act-order GPTQ and AWQ — experimental, with a loud warning at load. They decode to f32 (~8x the VRAM of an int4 layer; pair with
--quant int4to re-shrink at some accuracy cost), and their conventions are checked only by dlm’s own round-trip, not against a real export. Verify output withdlm doctorand your own prompts. - Refused:
checkpoint_format: gptq_v2(no v2 fixture to check against) and anything not 4-bit. - GGUF files are already quantized too: dlm reads them at the precision they were saved in, and
--quantis refused for them. The 2- and 3-bit files (Q2_K,Q3_K_M,IQ2_*,IQ3_*) are for models that would not otherwise fit.
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.
autois the default: int8 on the GPU — a scale per 32 values, 56% of fp16’s memory, at fp16’s speed, within 0.005 nats per token of fp16 on the models measured. Heads not a multiple of 32 wide keep fp16; MLA models keep f32.f16keeps the previous fp16 GPU cache;f32is exact (noneis accepted as an alias). On the GPU,int4keeps a scale per 32 values and 4-bit codes, 31% of fp16’s memory, so the same VRAM holds 1.8x int8’s context. It costs real accuracy: Qwen2.5-0.5B scored 4.59 nats per token against 3.95 with fp16 or int8, so use it only when the extra context matters more than the output.- On the CPU kernels,
auto(andf16) keep f32;int8gives about half the memory andint4about a quarter, with more error.
See Performance tuning.
M_layer_weight feeds the resident-layer count, or try the VRAM calculator to see what a given --quant does to your card.