Local LLM Deployment: Balancing VRAM, Context Length, and Concurrency

    This article explains how to plan local deployment of large language models, with a focus on sparse Mixture-of-Experts (MoE) models that have hundreds of billions of total parameters but activate only tens of billions per inference. Instead of starting from how many accelerators are enough, it shows how to work backward from four business facts: context length, concurrency, workload type, and acceptance criteria. It covers why activated parameters cannot be divided directly into VRAM, a practical VRAM budget formula that accounts for full weights, runtime overhead, KV Cache, and safety margin, and why context length and concurrency multiply KV Cache demand. It also outlines two abstract single-node reference routes, explains how inference framework performance depends on prompt distribution, lists four common pitfalls, and provides a deployment checklist for moving from a service that merely starts to one that is operationally reliable.

    1. Ask the Right Question First: Do Not Start With “How Many Cards Are Enough?”

    After ultra-large sparse models (hundreds of billions of total parameters, with only tens of billions activated per inference) move into a local data center, the most common question is “How many accelerators do I need to run it?” The question itself is reasonable, but it puts the decision at the wrong starting point. What really determines whether an inference service can go into production is four business facts:

    • Context length: Is the daily requirement 32K or 128K, or is there a genuine need for long documents of 256K or even million-token scale?
    • Concurrency: Is it single-user validation, shared use by several people in a lab, or sustained traffic for an enterprise-grade API?
    • Workload type: General chat, intelligent coding, AI Agent tool calls, retrieval-augmented generation (RAG), and long-document summarization have very different request patterns.
    • Acceptance criteria: Does the process only need to start, or are there explicit targets for time to first token, sustained output throughput, and long-term stability?

    Write these four items into a one-page “deployment requirements document,” then work backward to the server and accelerator configuration. This is the core methodology of this article. Configuration should not be mapped from hardware models to business needs; it should be derived backward from business constraints.

    2. Why You Cannot Divide VRAM Directly by Activated Parameters

    The defining feature of a sparse Mixture-of-Experts (MoE) architecture is that the activated parameter count describes the scale of experts routed to in a single forward pass. It determines compute and memory-access pressure, not the requirement for resident weights. What an inference service must hold in VRAM is the full set of weights (including all expert shards) plus runtime overhead.

    A simple VRAM budgeting framework:

    1. Total VRAM ≈ Full weights (by precision)
    2. + Framework and runtime overhead (CUDA context, communication buffers, temporary tensors)
    3. + KV Cache (grows linearly with context length × concurrency)
    4. + Safety margin (fragmentation, burst peaks; 10%~20% recommended)

    Taking FP8 precision as an example, the full weights are roughly “parameter count × 1 byte,” plus the KV Cache. The KV Cache can be roughly estimated as:

    1. KV_bytes ≈ 2 × num_layers × num_kv_heads × head_dim × context_length × concurrency × bytes_per_element

    This formula highlights something often overlooked: context length and concurrency are multiplicative. Increasing the window from 32K to 128K quadruples the KV Cache; increasing concurrency from 4 to 16 quadruples it again. In many cases where a service “starts and then crashes,” the problem is not that the weights do not fit, but that the KV Cache has consumed the entire margin.

    3. Single-Node Reference Routes and Long-Context Scenarios

    Without discussing general capability or tying the discussion to specific models, two abstract routes can be outlined:

    1. A single node of accelerators with moderate VRAM and a high bandwidth ratio: Suitable for team-internal use with 128K-level context and limited concurrency, usually offering the best cost-performance ratio.
    2. A single node of next-generation accelerators with large VRAM and high bandwidth: When million-level context is a hard requirement, larger per-card VRAM can significantly reduce the communication and scheduling complexity introduced by cross-card partitioning.

    It is important to emphasize that neither route means “buy it and the requirements are met.” They only get the service past the VRAM threshold first.

    4. Inference Framework Differences: Do Not Pick a Side Too Early

    With the same hardware and the same precision, different inference frameworks show clear workload dependence:

    • For short requests with low input length, one class of frameworks has an advantage in time to first token and output throughput.
    • As the input prompt grows longer, another class of frameworks has lower prefill-stage latency, but its sustained output throughput may be slightly lower.

    The conclusion is not “which one is stronger,” but: framework selection must be determined by your own prompt distribution. It is recommended to run a small-scale A/B test: fix the model weights and precision, fix the concurrency gradient (for example 1/4/8/16), sample 200~500 real business prompts, and record time to first token P50/P95, output throughput, requests completed per unit time, and error rate.

    An illustrative load-test record table structure:

    1. case_id | context_len | concurrency | framework | ttft_p50 | ttft_p95 | out_tokens_per_s | error_rate

    5. Four Common Pitfalls

    1. Do not max out the context on the first launch. First run stably with the window commonly used in business, then scale up step by step, observing the VRAM level and stability at each step.
    2. Lock versions as a whole. Model weights, inference framework, compute libraries, drivers, kernel and operator implementations should be fixed as a whole; when troubleshooting, do not focus on a single parameter alone.
    3. Multiple cards do not mean “total VRAM added together”. Inter-card interconnect topology, collective communication library behavior, CPU and PCIe channels, system memory, and local disk throughput can all become bottlenecks, especially in long-context and pipeline-parallel scenarios.
    4. Enable optimizations one at a time. Features such as multi-token prediction, prefix caching, quantization strategies, and continuous batching should be turned on one by one. Establish a reproducible baseline first so that, when problems occur, you can pinpoint the specific variable.

    6. Deployment Checklist

    • Define the context limit and concurrency target, and write them into the requirements document
    • Build a VRAM budget table based on “weights + runtime + KV Cache + margin”
    • Run A/B tests on frameworks and parallelism strategies with real prompts
    • Lock the full-stack versions and record the image/configuration
    • Set up monitoring: VRAM level, time to first token, throughput, error rate
    • Roll out optimizations gradually and keep a rollback path

    7. Conclusion

    The answer to “Can it run on a few cards?” is often found in the requirements document rather than in the hardware spec sheet. Once context length, concurrency, workload, and acceptance metrics are clearly written down, the VRAM budget, parallelism strategy, framework selection, and optimization order will naturally converge. If you need to handle enterprise-grade traffic, you can further leverage general-purpose cloud container platforms, object storage, logging services, and monitoring and alerting capabilities to complete elastic scaling and observability, taking the inference service from “able to start” to “ready to operate.”