Local Deployment of Large Models: How to Calculate VRAM and Concurrency

    This article explains how to size GPU resources for deploying large-scale MoE models locally. It shows why activated parameter counts do not determine VRAM requirements, breaks down the key components of memory demand, and identifies four decision variables—context length, concurrency, request type, and response targets. A practical evaluation workflow and common sizing mistakes are also covered to help teams avoid both under-provisioning and over-provisioning.

    1. Reference Configurations for a Single Node

    When a new generation of large-scale MoE model is released, many teams immediately ask whether eight GPUs are enough. A more rigorous answer depends on the scenario:

    • With native low-precision weights (such as FP8) and standard context requirements, eight high-memory, high-bandwidth compute cards are a clear reference starting point for a single node.
    • If full million-token context is a hard requirement, prioritize a newer generation of accelerator cards with higher per-card memory, higher bandwidth, and stronger interconnect capabilities.
    • If concurrency is low and the workload is mainly offline batch processing, you can reduce the card count or scale out across multiple nodes.
    • For online interaction with stable time-to-first-token and token output speed, “can it run” is not enough. You also need to verify that performance targets are consistently met at the target concurrency.

    What truly determines the configuration is not the number of cards, but the combination of context length, concurrency scale, request type, and response targets.

    2. Why VRAM Cannot Be Calculated from Activated Parameters

    The defining characteristic of large-scale MoE (Mixture of Experts) models is that total parameter count is decoupled from the amount activated in a single inference pass. The so-called activated parameter size describes the subset of experts that actually participate in matrix computation during one forward pass. It affects compute consumption and memory access patterns, not the requirement for resident weights.

    The reasons are:

    1. Weights must be resident in full or in shards: Routing is dynamic, and any request may hit different experts. In engineering practice, it is impossible to predict and load only “the part used this time,” so the complete weights (or the complete set after sharding across nodes) all need space.
    2. Runtime overhead is not negligible: Framework runtime, communication buffers, operator workspaces, and CUDA/driver contexts all consume a considerable amount of VRAM.
    3. KV Cache grows linearly with context and concurrency: This is the part most likely to spiral out of control in long-context scenarios.
    4. A safety margin is required: Filling VRAM to capacity triggers allocation failures or frequent paging, and tail latency deteriorates sharply. It is generally recommended to reserve a certain percentage of headroom.

    A practical estimation sequence is:

    1. Total demand ≈ weight shard usage + runtime and communication overhead + KV Cache + safety margin
    2. KV Cache ≈ num_layers × 2 (K/V) × sequence length × concurrency × bytes per element × hidden dimension correlation factor

    The sequence length should be the maximum expected value of “input + output,” and the concurrency should be the peak value, not the average.

    3. Four More Critical Decision Variables

    1. Context Length

    When context expands from thousands to hundreds of thousands or even millions of tokens, KV Cache becomes the dominant term, and the memory access pressure of attention computation rises significantly. The bottleneck often shifts from compute to VRAM capacity and bandwidth.

    2. Concurrency and Batching Strategy

    At low concurrency, the card count requirement is determined by weights; at high concurrency, it is determined by KV Cache and scheduling efficiency. General optimization techniques such as continuous batching, chunked prefill, and prefix reuse can significantly improve throughput, but they change the distribution of peak VRAM usage.

    3. Request Type

    Long-document summarization and repository-level code understanding are “long input, short output.” Multi-turn tool calling by agents is “short input, accumulated over multiple turns.” Generative writing is “long output.” The three have completely different VRAM curves and latency targets, and cannot be covered by the same configuration.

    4. Response Targets

    Time-to-first-token, inter-token output interval, end-to-end duration, and availability targets must be defined. Online services should reserve redundancy for peaks, while offline tasks can maximize throughput.

    1. Define SLAs: express latency and throughput as measurable metrics.
    2. Build a stress-test set with real corpus data, covering the longest inputs and highest concurrency.
    3. Run small-scale validation on a single card or single node first, observing peak VRAM usage and allocation failure rate.
    4. Gradually increase the load and record the inflection point of the throughput-latency curve.
    5. Based on the inflection point, determine the card count, parallel partitioning method (tensor parallelism / pipeline parallelism / expert parallelism), and whether multiple nodes are needed.
    6. After launch, integrate logging services and monitoring alerts to continuously track VRAM levels, queue duration, and error rates.

    5. Common Mistakes

    • Estimating VRAM based only on parameter count or activated parameter count.
    • Using average concurrency rather than peak concurrency for capacity planning.
    • Ignoring the impact of output length on total sequence length.
    • Failing to reserve a safety margin, leading to tail latency jitter.
    • Procuring hardware before defining metrics, resulting in resource mismatch.

    6. Conclusion

    Local deployment of large-scale MoE models is essentially a joint optimization problem of capacity and latency. Defining context, concurrency, request type, and response targets first, and then working backward to VRAM and card count, avoids two types of waste: “enough cards but the service fails to meet targets” and “over-provisioned configuration.” In practice at Baidu AI Cloud, this type of assessment is often combined with general capabilities such as container platforms, object storage, and monitoring alerts to form a reproducible and observable deployment loop.