Capacity and Cost Planning for LLM Inference Amid Memory Price Volatility
With memory and VRAM prices fluctuating, hardware costs now weigh heavily on self-hosted LLM inference. This article breaks down the three components of inference memory usage—model weights, KV cache, and runtime overhead—provides the core sizing formulas, and discusses trade-offs around quantization precision and continuous batching to help teams plan capacity before launch and calibrate with measured data afterward.
1. Background: Why Memory Costs Matter for Inference Deployment
Memory component prices have fluctuated noticeably in recent periods, with some electronics markets seeing both concentrated shipments and wait-and-see behavior. For teams running self-hosted inference services, system memory and VRAM account for a large share of hardware costs. Price swings directly affect the procurement cost of each server and, in turn, the resource cost amortized across every request.
At the same time, LLM applications are moving from experimentation to large-scale production, with request volume, context length, and concurrency all growing. Together, these two trends make the old approach—“buy the highest-spec hardware upfront and scale out if problems arise”—increasingly unsustainable. Estimating resource requirements before launch and continuously calibrating with measured data after launch has become a baseline engineering capability.
2. What Makes Up Memory Usage During Inference
When deploying a language model for inference, memory is primarily consumed by three categories of data.
- Model weights: The model parameters themselves, which reside in memory once loaded. Their size depends only on the parameter count and the storage precision of each parameter.
- KV cache: During autoregressive generation, the Key and Value vectors required for attention computation must be stored for every processed token. This grows linearly with sequence length and concurrent request count, and is the most commonly underestimated component in long-context scenarios.
- Runtime overhead: This includes intermediate computation results, the inference framework’s memory pools, and communication buffers. There is no universal formula for this part; it is typically reserved as an empirical proportion and corrected with measured data.
The two core formulas are:
Weight footprint = parameter count × bytes per parameter
KV cache per token = 2 × number of layers × number of KV heads × head dimension × bytes per element
The factor of 2 in the formula accounts for the two separate caches, Key and Value. Note that this uses the number of KV heads, not query heads. In models that use grouped-query attention, the two can differ by several times; mistakenly using the query head count will significantly overestimate the cache size.
Total KV cache = per-token footprint × average sequence length × concurrent request count
3. Trade-offs in Precision and Quantization
Reducing storage precision is the most direct way to shrink the weight footprint. Common precisions and their corresponding byte counts are:
| Storage Precision | Bytes per Parameter | Suitable Scenarios |
|---|---|---|
| FP16 / BF16 | 2 | Quality baseline; preferred when resources are sufficient |
| INT8 | 1 | Halves the weight footprint with minimal quality loss on most tasks |
| INT4 | ~0.5 (slightly higher including quantization metadata) | Resource-constrained scenarios; requires careful quality evaluation |
Quantization is not free. Quality degradation may only become apparent on specific tasks such as mathematical reasoning or long-document extraction, so it should be validated against your own business evaluation set rather than relying solely on general benchmarks. In addition, weight quantization and KV cache quantization are two separate things. Whether to quantize the KV cache requires independent evaluation, because it directly affects generation quality in long-context scenarios.
4. Trade-offs Between Batching and Concurrency
Static batching requires all requests in a batch to start and finish together, so short requests must wait for long ones, resulting in low GPU utilization. Continuous batching allows requests to be dynamically added to or removed from a batch after each generation step, which significantly improves throughput. However, the higher the concurrency, the more KV cache is occupied at any given moment. Peak memory must therefore be designed for the worst case, not just the average.
In practice, teams typically need to balance three metrics:
