Akashic Computer
Memory budgetNot set

Or a total budget

A total budget does not describe device topology or confirm runtime fit.

All Docs

Deployment · 10 min read · Updated 2026-07-24

Model memory, KV cache, and context

A practical memory model that separates weight payload from cache, temporary buffers, concurrency, and runtime headroom.

Key idea

Weight memory answers whether loading is plausible; context and concurrency determine how much memory remains while serving.

Start with the weight payload

The simplest lower bound is parameter count multiplied by effective bits per parameter. Convert bytes to GiB carefully: model names use decimal billions, while memory tools often report binary GiB.

This estimate is most useful for rejecting impossible configurations. It is not enough to certify a runnable setup because scales, tensor exceptions, allocator behavior, and runtime workspaces add memory.

billion

A block-scaled 4-bit floating-point representation designed for supported NVIDIA hardware.

Raw weight estimate16.8 GiBparameters × effective bits, converted to GiB
Planning floor19.3 GiBraw estimate + 15% loading headroom

This is a weight-capacity estimate, not a runnable guarantee. KV cache, context, batching, temporary buffers, higher-precision tensors, and runtime behavior require additional memory. The estimate includes block scales but not higher-precision exceptions or runtime state.

Loading creates more than weights

A runtime may allocate temporary buffers, compiled graphs, communication workspaces, logits, sampling state, and duplicated structures. Some loaders briefly require extra host or device memory while converting or materializing tensors.

Planning headroom protects against these costs, but no single percentage is universal. The estimator above uses a visible 15 percent loading floor so the assumption is explicit rather than hidden inside a fit badge.

KV cache grows with tokens and requests

Autoregressive decoding stores attention keys and values for tokens that have already been processed. This KV cache avoids recomputing the entire prefix for every new token, but its memory grows with context length, layer structure, cache precision, batch size, and concurrent sequences.

Grouped-query and multi-query attention can reduce cache size by using fewer key-value heads. Some runtimes can quantize the cache. Those architecture and runtime choices are why two models with similar parameter counts can support very different serving shapes.

Advertised context is not a free allocation

A model may be trained or configured for a long context window, but allocating the maximum can leave too little memory for concurrency or even prevent startup. Practical context is a serving decision constrained by the workload.

For interactive use, one long sequence may be acceptable. For an API, several shorter concurrent requests can consume more total cache. The correct setting comes from expected prompt length, output length, concurrency, and latency goals.

A capacity-planning procedure

Choose the exact artifact and runtime first. Estimate the weight floor, reserve runtime headroom, then select an initial context and concurrency below the advertised maximum. Measure peak memory during prefill and decode rather than relying only on idle usage.

Increase one dimension at a time. When a run fails, record whether it failed during loading, prefill, or decoding. Those stages point to different causes and prevent a generic out-of-memory label from erasing useful evidence.

  • Weights: mostly fixed after loading.
  • KV cache: grows with tokens and live sequences.
  • Workspaces: depend on runtime and kernels.
  • Concurrency: multiplies request state.
  • Headroom: protects against peaks and allocator fragmentation.

Primary sources

Continue reading