Local LLM Deployment: How to Calculate VRAM, Bandwidth, and Parallelism
This article provides a practical guide to calculating VRAM capacity and decoding bandwidth for local large language model (LLM) deployment. It covers estimation formulas for VRAM, decoding bottlenecks in Mixture of Experts (MoE) architectures, parallelism strategies (TP, PP, EP), prefix caching design for hybrid attention, step-by-step deployment guidelines, and a comparison between self-hosting and using cloud services.
When deploying LLMs locally, the most easily underestimated aspects are how to calculate VRAM capacity and decoding bandwidth. Even if model files are downloaded and VRAM seems sufficient, inference speed can still be slow due to bandwidth and scheduling issues. This article provides ready-to-use estimation methods, ordered by VRAM capacity, decoding bandwidth, parallelism approaches, cache design, and deployment steps.
Model Architecture Determines Two Different Pressures
Current mainstream LLMs often use the Mixture of Experts (MoE) architecture. Since each token only passes through a few experts, the computational load is much lower than that of a dense model with the same total parameters. However, the weights of all experts must still reside in VRAM because routing is determined during inference. Thus, MoE models introduce two pressures simultaneously: VRAM capacity must accommodate all experts, while decoding bandwidth only needs to handle the reading of activated experts.
Take a certain series’ Flash version as an example. Public data indicates total parameters of about 284 billion and activated parameters of about 13 billion. Using FP4 quantization, the total weights are about 142GB, and the weights activated per token are about 6.5GB. This is estimated at 0.5 bytes per parameter, excluding the extra overhead of quantization scaling factors.
The model also uses hybrid sparse attention, fusing Sliding Window Attention (SWA) with a type of compressed attention in each layer. Original materials state that under a 1M context, the inference computation is about 27% of the previous generation, and KV Cache usage is about 10%. While hybrid attention reduces computation and cache size, the inference engine must simultaneously maintain multiple heterogeneous KV pools and compression state pools, which increases scheduling complexity.
FP4 saves VRAM but requires the accelerator to natively support the corresponding tensor core operations. If the hardware does not support it, weights will be de-quantized or fall back to higher precision, requiring VRAM and bandwidth estimates to be recalculated. Therefore, before selecting a GPU, confirm the compatibility between the quantization format and the hardware.
How to Calculate VRAM Capacity
You can estimate VRAM requirements before deployment using two formulas.
Weight VRAM ≈ Total Parameters (B) × Bytes per parameter. FP16 uses 2 bytes, FP8 uses 1 byte, and FP4 uses 0.5 bytes. In the example above, 284 billion parameters multiplied by 0.5 bytes equals approximately 142GB.
KV Cache VRAM ≈ 2 × Number of Layers × Number of KV Heads × Head Dimension × Context Length × Batch Size × Bytes per Element.
The coefficient 2 represents storing K and V separately. The number of KV heads should be the actual stored heads; for models using GQA or MQA, use the grouped KV head count, not the query head count. Batch size is the number of concurrent requests, which proportionally scales the KV Cache. For sliding window layers, the context length should be replaced by the window length, and for compression layers, it should be scaled by the compression ratio. If the engine uses other cache structures like MLA, this formula no longer applies directly; refer to the engine’s documentation.
The actual required VRAM roughly equals weights plus KV Cache, plus activation values and runtime overhead. Runtime overhead includes CUDA graphs, communication buffers, and VRAM fragmentation, which depends on the engine implementation. For initial estimates, reserve 10% to 20%, with final numbers verified through stress testing.
Based on the numbers above, 142GB of weights plus KV Cache and activation values will typically exceed 200GB. A single 96GB GPU might theoretically suffice with 3 GPUs, but parallel splitting requires attention heads and expert counts to be divisible by the parallel degree. In practice, this often requires 4 or 8 GPUs. If using 24GB consumer GPUs, the same requirement would need over 10 GPUs, significantly increasing inter-GPU communication overhead and impacting throughput.
Decoding Speed Depends on Bandwidth, Calculated by Activated Experts
In autoregressive decoding, generating each token requires reading the weights used in that step from VRAM to the compute unit. Therefore, single-step latency is often bottlenecked by VRAM bandwidth, while compute power usually has surplus.
If all 142GB of weights were treated as required reading per step, an A100 80GB with about 2TB/s bandwidth would take about 71ms per step, yielding a single-GPU ceiling of about 14 tokens/s. This figure only applies to dense models. The weights of the model discussed here cannot even fit into a single 80GB GPU, so it cannot be used for hardware selection.
For MoE models, only the experts activated by routing need to be read per step. Assuming a batch size of 1, FP4, and an ideal 4-way split across 4 A100s: each token activates about 6.5GB of weights, with each GPU handling about 1.6GB. At 2TB/s, single-step reading takes about 0.8ms. The theoretical ceiling is much higher than actual performance because this calculation ignores three things: All-to-All communication latency, reading of attention layers and KV Cache, and load imbalance caused by popular experts. This result only indicates a trend and should not be taken as a performance guarantee.
As batch size increases, the situation changes. Different requests route to different experts, expanding the set of activated experts in the same step. The expert weights read per step approach the full 142GB. Thus, while throughput increases with larger batches, single-step bandwidth pressure also rises, causing throughput growth to gradually plateau.
How to Choose TP, PP, and EP
There are three common parallelism methods.
Tensor Parallelism (TP) splits each layer’s weight matrix across multiple GPUs. After each layer computes, an All-Reduce communication is required, making it dependent on high-speed intra-node interconnects like NVLink. If inter-GPU bandwidth is insufficient, communication costs will offset the gains.
Pipeline Parallelism (PP) slices the model by layers into segments, placing each segment on a group of GPUs. Only activations are passed between segments, resulting in less communication, making it suitable for cross-node deployment. The trade-off is that requests must pass through each segment sequentially, increasing single-request latency. It also requires sufficient concurrency to fill the pipeline, or idle bubbles will occur.
Expert Parallelism (EP) distributes different experts across different GPUs. Each token only needs to be sent to the GPUs hosting the routed experts; other GPUs do not participate in that step’s computation. Its cost is the need for All-to-All communication and load imbalance from popular experts. EP requires the number of experts to be divisible by the parallel degree.
When selecting a strategy, consider these guidelines. MoE models often use a combination of TP and EP under single-node high-speed interconnect conditions. For cross-node deployments or weak inter-GPU interconnects, PP reduces cross-node communication but requires sufficient concurrency. For low concurrency and a focus on single-request latency, TP is usually more stable; for high concurrency and a focus on total throughput, EP yields more obvious benefits. Specific trade-offs should be confirmed through stress testing.
Using 4 GPUs as an example, a common practice is TP=2, EP=2: two GPUs form a TP group, and expert parallelism is performed between the two TP groups. The TP group requires All-Reduce within each layer, while EP requires All-to-All between groups. This scheme has clear boundary conditions: the two GPUs in the TP group need high-speed interconnects; the model’s attention head count and expert count must be divisible by the corresponding parallel degrees; and if routing is unbalanced, one group may become a bottleneck. Whether this layout is suitable depends on the model structure and engine implementation and should not be blindly applied to other models.
How to Design Prefix Caching under Hybrid Attention
Traditional prefix caching assumes that identical input prefixes can directly reuse the full KV. Hybrid attention breaks this assumption. Sliding window layers only retain the KV of the recent window, while compression layers store compressed states. The same prefix segment has different lifespans across different pools, so it cannot be simply reused or evicted as a whole.
A common industry approach is to use a radix tree to index “virtual full-token slots” and project these slots into physical pools: the sliding window pool and the compression pool. The compression state uses a ring buffer nested under the sliding window page index. The address calculation is swa_page * ring_size + pos % ring_size. When a sliding window page is released, the corresponding ring buffer address becomes invalid without additional tracking overhead.
Each node in the radix tree maintains two sets of counters. One set counts full-lock references, covering core tokens and the compression pool; the other only counts sliding window references. When the sliding window count drops to zero, only the corresponding slot is marked invalid, while the node and compression shadow remain on the tree for reuse by subsequent requests. This design supports prefix reuse under hybrid attention without adding extra memory management costs. Specific implementation details depend on the source code of the engine used.
When evaluating such caches, a unified metric should be used. Hit rate can be defined as the number of hit prefix tokens divided by the total prompt tokens of the request. Statistics should be based on real traffic replay, recording eviction counts and average prefix length, to avoid relying solely on single test results.
How to Implement Local Deployment
A reusable deployment process consists of five steps.
- Environment Preparation. Check the driver, GPU runtime in containers, and NCCL version, and confirm that the accelerator supports the quantization format. If FP4 is not supported, load using FP8 or BF16 instead, and recalculate the weight VRAM using the formula.
The table below lists common issues and items that need recalculation.
| Check Item | Action if Unmet | Items to Recalculate |
|---|---|---|
| Native FP4 support | Use FP8 or BF16 loading | Weight VRAM, GPU count |
| Inter-GPU interconnect | Reduce TP degree, minimize cross-GPU communication | Parallelism plan, throughput expectations |
| Driver and NCCL versions | Upgrade according to engine requirements | None |
| KV Cache reservation | Reduce context length or concurrency | KV Cache VRAM |
Weight Conversion and Loading. Convert the original checkpoint to the format required by the engine and unify the tensor naming rules. Inconsistent naming will cause errors during loading, which are costly to troubleshoot.
Parallelism Configuration. Start by running the process on 2 GPUs, then scale to 4 or more. Multi-node deployment requires configuring distributed communication addresses and confirming that RDMA or high-bandwidth networks between machines are available.
Inference Parameter Tuning. Set context length, maximum batch size, and speculative decoding length. New generation models often come with a single-layer MTP head for speculative decoding. Too many drafted tokens will incur validation overhead that offsets gains; too few will limit benefits. You can measure this using acceptance rate (accepted drafted tokens / total drafted tokens) and adjust the length accordingly. Long-context scenarios require reserving sufficient KV Cache VRAM and can enable paged KV management to reduce fragmentation.
Performance Verification. Measure Time To First Token (TTFT), decode throughput, and end-to-end latency, and plot throughput curves under different concurrency levels. When reporting results, specify the model version, quantization format, batch size, context length, and hardware interconnect conditions.
When to Self-Host vs. Use Cloud Services
The advantages of self-hosting include keeping data on-premises, customizable inference logic, and potentially lower unit costs when concurrency is stable. If you are only verifying model performance or have fluctuating concurrency, cloud inference APIs or on-demand GPU instances are usually more cost-effective.
Before purchasing hardware, it is recommended to verify performance and costs using cloud GPUs or inference APIs. Confirm the number of GPUs needed based on the formulas and stress testing results in this article, rather than relying on theoretical peak bandwidth for procurement. Hardware procurement should also factor in power, data center space, and operations and maintenance (O&M) personnel, as these costs are often a significant portion of the GPU cost itself.
