How to Estimate VRAM and Hardware Configuration for Local LLM Deployment
This article explains how to estimate VRAM requirements and select hardware for deploying large MoE-based LLMs locally. It separates standard inference needs from hard long-context requirements, shows why activated parameters cannot be used directly to calculate VRAM, and breaks the memory budget into weights, runtime overhead, KV Cache, communication buffers, and safety margin. It also covers how context length, concurrency, and request types affect capacity planning, offers a practical evaluation framework, and summarizes common sizing mistakes.
1. The Bottom Line: Reference Single-Node Routes vs. Hard Requirements
When planning a local deployment of a large mixture-of-experts (MoE) language model, the most common opening question is whether a given number of a certain accelerator card is enough. A more practical approach is to separate two categories of requirements first.
The first category is standard inference serving. If you deploy with lower-bit quantization of single-precision floating-point weights (for example, the low-bit weight formats common in the industry), a single server with multiple high-VRAM accelerator cards usually supports a fairly clear single-node reference route. This route can cover most business scenarios with medium context lengths and medium concurrency.
The second category is when ultra-long context is a hard requirement. If the business needs to process close to a million tokens in a single input, pressure on both VRAM and bandwidth rises sharply. A standard single-node configuration is often stretched thin, and you need a newer generation of accelerator cards with higher per-card VRAM and higher bandwidth.
In real deployments, however, it is not advisable to reduce the question to “how many cards are enough.” Context length, concurrency, request type (long-document summarization, code completion, multi-turn dialogue, structured extraction), and response latency targets often determine the final configuration more than card count does. In other words, card count is a result, not an input variable.
2. Why You Cannot Estimate VRAM from Activated Parameters Directly
The defining characteristic of MoE models is the separation between total parameter count and the amount activated in a single inference pass. Activated parameters refer to the subset of expert parameters that are routed to and actually participate in matrix computation during one forward pass. They determine the compute requirement of a single calculation, but they are not equivalent to the VRAM residency requirement.
The reason is that routing is dynamic, and different tokens may hit different experts. If you place only the currently activated expert weights in VRAM, the next request that hits a different set of experts would require reloading them, which is an unacceptable cost. Therefore, engineering implementations typically require the full set of expert weights to stay resident in VRAM (or at least resident in high-bandwidth media), plus runtime overhead.
A rough VRAM budget can be abstracted as:
Total VRAM ≈ weight footprint + runtime/framework overhead + KV Cache + communication and temporary buffers + safety marginWeight footprint ≈ parameter count × bytes per parameter × (1 + small alignment/metadata factor)KV Cache ≈ 2 × number of layers × number of KV heads × head dimension × bytes per element × context length × concurrency
Each line here corresponds to an adjustable item: the quantization bit width determines bytes per parameter; tensor parallelism and expert parallelism determine how weights are split across cards; context length and concurrency scale KV Cache linearly; and communication buffers cannot be ignored under cross-card parallelism. Ignore any one of these, and you get the “it fits in theory but overflows on startup” situation.
3. Context Length: From “Fits” to “Runs”
Context length affects VRAM linearly, but its impact on latency is often steeper. Attention computation grows with sequence length, and in long-context scenarios the compute cost of a single request can be one to two orders of magnitude higher than that of a short request.
In practice, it helps to plan context in three tiers:
- Short context (thousands of tokens): The main pressure is on weights, the configuration is relatively relaxed, and the focus is on throughput and concurrency.
- Medium context (tens of thousands of tokens): KV Cache begins to become the main VRAM increment, and you need to evaluate whether to enable general optimizations such as chunked prefill and prefix reuse.
- Ultra-long context (hundreds of thousands to a million tokens): VRAM and bandwidth are tight at the same time, a standard single-node configuration easily hits its limit, and you typically need accelerator cards with higher per-card VRAM, together with strategies such as context parallelism and tiered caching.
It is important to emphasize that nominally supporting a certain length does not mean the business latency target can be met at that length. A capacity assessment must deliver two conclusions: “it fits” and “it finishes within the target latency.”
4. Concurrency and Request Type: The Real Variables in Capacity Planning
The same model on the same number of cards can perform very differently under different traffic patterns. It is recommended to classify traffic with a request profile first:
- Interactive short requests: Focus on time to first token and output tokens per second, and reserve headroom for burst concurrency.
- Batch long documents: Focus on total throughput and unit cost, and use larger batches to improve utilization.
- Multi-turn conversations: High prefix repetition makes them suitable for prefix cache reuse, which can significantly reduce repeated computation.
- Structured extraction/code tasks: Output length fluctuates widely, so reserve decoding space for the worst case.
Concurrency multiplies directly onto KV Cache and is the item most easily underestimated. A practical checklist is to define peak concurrency, average and P95 input/output lengths, acceptable time to first token, and acceptable overall completion latency, then work backward to the required VRAM and card count.
5. A Practical Framework for Configuration Trade-offs
Organizing the above variables into an evaluation process helps avoid guesswork:
- Determine the deployment form: low-bit quantized weights resident, or higher precision; whether cross-node deployment is allowed.
- Estimate the weight and runtime baseline: calculate the “floor price” first, which is independent of context.
- Add context and concurrency: calculate KV Cache based on business P95 rather than the average.
- Validate latency targets: run one set of short-request and one set of long-request load tests to confirm whether targets are met.
- Leave headroom: reserve resources for traffic fluctuations, version upgrades, and always-on components such as monitoring and log collection.
- Design an elasticity strategy: prioritize horizontal scaling of stateless gateways and scheduling layers, and scale model replicas at whole-card VRAM granularity.
For cloud deployment, you can combine container platforms for replica orchestration, object storage for hosting model files, and logging services with monitoring and alerting systems to observe latency and VRAM levels. These general capabilities turn capacity assessment from a one-time calculation into a continuous calibration process. General cloud product categories on platforms such as Baidu AI Cloud typically cover these basic capabilities as well.
6. Summary of Common Mistakes
- Mistake 1: Calculating VRAM from activated parameters. This ignores full weight residency and routing dynamics.
- Mistake 2: Estimating only by average input length. Long-tail requests will break the KV Cache budget.
- Mistake 3: Treating “supported length” as “usable length.” This ignores latency and bandwidth constraints.
- Mistake 4: Fixing the card count first and then tuning parameters. The correct order is to define the business profile first, then the parallelism and quantization strategy, and finally arrive at the card count.
In summary, when deploying a new-generation large MoE model locally, first clarify the context and concurrency profile, then account for the three parts of VRAM (weights, runtime, and cache), and finally validate against the latency target. Only then can you reach a robust and reusable configuration conclusion.
