Local LLM Deployment: VRAM Estimation Beyond Model Weights
Local LLM deployment has moved from experimentation to everyday productivity, but the common practice of estimating VRAM needs by model weight file size alone is incomplete and often leads to deployment failures. This article breaks VRAM usage down into model weights, KV cache, and runtime overhead, shows how to read the key cache parameters from a model's config.json, and provides reproducible formulas for estimating cache size by context length and concurrency. It also explains why quantization helps with weights but not cache, outlines the practical limitations of local deployment, and offers more reliable adoption recommendations.
Local LLM Deployment: VRAM Estimation Beyond Model Weights
Local LLM deployment has moved from experimentation to everyday productivity. But before getting started, almost everyone asks the same question: can my GPU actually run it? The estimation methods circulating online usually focus on a single factor—how large the weight files are. That view is incomplete and can directly lead to deployment failure: the model loads successfully, then crashes as soon as a long conversation or multiple concurrent users come in. Starting from the underlying logic of VRAM composition, this article presents a reproducible and verifiable estimation method and systematically reviews the practical limitations of local deployment.
1. VRAM Is Not a Single Variable: Weights, Cache, and Runtime Overhead
To understand VRAM requirements, you first need to break VRAM usage into three categories:
- Model weights: the parameters themselves loaded into VRAM, with a largely fixed size;
- KV cache: space allocated during inference to preserve attention states, growing linearly with context length;
- Runtime overhead: the framework’s own buffers, operator workspaces, VRAM fragmentation, and reserved space.
Most tutorials only account for the first category, which is the root of the problem. What really determines “how long a context you can run and how many concurrent streams you can serve” is often the second.
2. Reading the Key Cache Parameters from the Config File
A model directory usually contains a core configuration file describing its structure (commonly named config.json). Estimating the cache requires only three numbers:
- the number of network layers (hidden layers);
- the number of key-value heads (KV heads; in some models this equals the number of attention heads, while grouped-query structures use fewer);
- the dimension width of each head.
The formula can be written as:
Bytes per token per layer = KV heads × head width × 2 (one copy each for key and value) × bytes per precisionTotal bytes per token = bytes per token per layer × number of layersTotal cache size = total bytes per token × context tokens × concurrent streams
Taking half precision (two bytes) as an example, for a model with 32 layers, 4 KV heads, and a head width of 128:
4 × 128 × 2 × 2 = 2048 bytes / token / layer2048 × 32 = 65536 bytes ≈ 64 KiB / token8K context ≈ 0.5 GiB32K context ≈ 2 GiB
These numbers explain a common phenomenon: on the same GPU, some people can run a 32K context while others overflow at 8K. The difference lies not in the weights but in the cache. If you further factor in quantization, framework reservations, and fragmentation, the actually available space shrinks even more, so it is advisable to leave a 20%–30% margin on top of the above results.
3. Concurrency Is the Most Easily Overlooked Multiplier
For single-user use, the cache is counted once; once you serve external users, the situation changes significantly. Each additional concurrent slot allocates another copy of the cache. One misconception needs special clarification: the total length is not a shared public pool, but is divided by the number of concurrent streams.
For example, a total length of 64K with four concurrent streams is equivalent to only a 16K usable window per stream, not the full 64K for each. If you want every stream to retain a 32K context, the cache portion in VRAM must be calculated as four copies of 32K, and the requirement instantly quadruples. When planning capacity, it is recommended to write down this equation explicitly:
Usable context per stream = total context budget ÷ number of concurrent streams
4. Precision and Quantization: Saving VRAM, but Not Without Cost
Lowering precision is the most direct way to compress weights. Half precision is a common baseline, and lower bit widths (such as 8-bit or 4-bit) can noticeably reduce weight usage, bringing models that previously could not run into a runnable range. But note three points:
- Quantization mainly compresses weights and has limited impact on the cache, which is still calculated at the chosen precision;
- Lower bit widths may cause fluctuations in output quality, and long-text inference and structured-output scenarios are more sensitive;
- Different inference frameworks support quantization formats to varying degrees, so compatibility must be verified before deployment.
5. Practical Limitations of Local Deployment
Beyond estimation errors, local deployment has several unavoidable shortcomings:
- Hardware threshold and bandwidth bottleneck: VRAM capacity determines whether a model can load, while VRAM bandwidth determines generation speed; both are required;
- Context and concurrency cannot both be maximized: constrained by the linear growth of the cache, long context and high concurrency are often an either-or choice;
- Underestimated operational cost: environment setup, dependency management, version upgrades, and troubleshooting all require ongoing investment;
- Insufficient elasticity: fixed hardware struggles to handle peaks and troughs, and scaling takes a long time;
- Clear capability boundaries: local small-parameter models have an objective gap compared with cloud-based large models on tasks such as complex reasoning and long-document understanding.
6. More Reliable Adoption Recommendations
- First use the config file to do a two-part “weights + cache” estimate, then add runtime margin;
- Define the business profile clearly: single-user long text or multi-user short conversations, and allocate context and concurrency accordingly;
- Prefer inference frameworks that support efficient cache management and continuous batching to improve VRAM utilization per unit;
- For businesses with high elasticity requirements and uncertain peaks, a hybrid local-and-cloud architecture can be adopted, offloading heavy workloads to general-purpose cloud compute while the local setup handles low-latency and data-sensitive scenarios;
- Set up monitoring and alerting to continuously track VRAM usage, time to first token, and throughput metrics, and drive capacity adjustments with data.
Conclusion
The core of local deployment is not “whether it can load,” but “whether it can serve stably under real context lengths and concurrency pressure.” Only by incorporating the cache and concurrency into the estimation model can you avoid the awkwardness of “loads successfully, crashes in use.” If the business has higher requirements for elasticity and long context, you can build a hybrid solution combining general-purpose cloud compute with foundational capabilities such as container platforms, object storage, log services, and monitoring and alerting; the general-purpose compute and supporting services offered by cloud vendors such as Baidu AI Cloud can also serve as an alternative path for elastic scaling.
