Skip to content
← Blog
Jul 7, 20266 min

Layer streaming: running a 70B model on 16 GB of VRAM

A 70-billion-parameter model in 4-bit weights wants about 40 GB of memory. A consumer card has 16. For years that arithmetic kept the best open models off the hardware most people own — because everyone assumed the same thing: the whole model has to be in VRAM at once.

dlm drops that assumption. A layer only needs to be present the instant it computes. So instead of loading the model, dlm streams it — keeping a small window of transformer blocks resident and pulling the next window in over PCIe while the GPU works. Here’s the whole machine.

The hardware wall

Resident loading is simple and fast: every weight sits in VRAM, the GPU reads it directly, done. The catch is capacity. Weights scale with parameters; VRAM doesn’t scale with your budget. A 70B model at Q4 needs roughly 40 GB just for weights, before the KV cache and activations. On a 16 GB card, it simply won’t load.

The usual escapes — smaller models, aggressive quantization, or spilling to CPU and eating the latency — all trade away the thing you wanted. Streaming is a different bet.

Three zones

dlm carves VRAM into three regions, each with one job:

The overlap is the trick

The window is an LRU. A layer the window already holds computes straight away; a miss uploads it on a dedicated copy stream — DMA-ing over PCIe while the default stream keeps computing — and evicts the least-recently-used layer to make room. A background prefetch worker (--prefetch-depth, or --auto-prefetch to tune it from measured load-vs-compute time) runs ahead of the pointer so the upload has already started by the time the layer is wanted.

Calling it a cache flatters it. With a window smaller than the model, layers are touched in order and each one is evicted long before it comes round again — the hit rate is near zero by construction. The window isn’t there to avoid the transfer. It’s there to hide it under the compute.

Each streamed layer travels a tiered path: mmap (NVMe) → CPU-RAM cache → pinned staging → VRAM → compute. Memory-mapping skips the OS read-buffer copy; the hot-layer cache skips the disk read on repeat token steps; and the page-locked host buffer lets the PCIe controller DMA straight to VRAM asynchronously.

The budget decides the window

How many layers stay resident? One formula, run before any weights load:

LayersToLoad = ⌊(M_free − M_safety − M_kv − M_pinned) / M_layer_weight⌋, clamped to [1, N]. For a 70B model on 16 GB with an 8k context, that lands at 29 of 80 layers resident — the other 51 stream through the window.

Everything after the fixed costs — a safety cushion, the KV cache for the whole context, the pinned zone — is spent on as many streamed layers as fit. See the full breakdown for each term.

What it costs

Streaming isn’t free. The more a model has to stream, the more the token rate leans on how fast the bus and NVMe can feed the window. The win isn’t peak throughput — it’s that the model runs at all, on hardware that could never hold it resident. Overlap hides the transfer; it doesn’t shorten it, and the only way to pay less bandwidth is to send fewer bytes. So the first lever is --quant int4|int8, which shrinks every layer 2–4x and often removes the need to stream at all; then --ram-cache-gb to keep materialized layers in host RAM, and a wider --resident-layers window if the budget allows. (--stream and speculative decoding don’t combine yet — dlm rejects the pair at startup.) See Performance tuning.

Try it

The profiler does this math for your exact card, no GPU required — dlm profile. Point it at a model, read the plan, and watch a 70B fit where it shouldn’t. Start with Get started.