Local Deployment of Large Models: How to Size VRAM, Context, and Concurrency
This article explains how to plan local deployment of next-generation large sparse (MoE) models. It shows why activated parameter counts cannot be used to estimate VRAM, breaks down memory consumption across weights, KV cache, runtime overhead, and optimization structures, and explains how inference engine behavior shifts with workload shape. It also covers the four questions to settle before a project starts, parallelism and topology considerations for an eight-card node, common pitfalls, a reusable load-testing workflow, and how to choose between cloud and on-premises setups based on data requirements and elasticity. The goal is to help readers move from "how many cards are enough" to a configuration grounded in real workloads.
1. The conclusion first: a single node works, but “is it enough” is not the first question
For local deployment of next-generation ultra-large sparse (MoE) models, the most common community question is whether eight cards are enough to run the model. From an engineering standpoint, if you use a native low-precision weight format, a single node with eight high-end inference cards is already a fairly clear starting point. If ultra-long context (million-level tokens) is a hard requirement, you need a newer generation of accelerators with more VRAM capacity and higher bandwidth, and a single eight-card node is the safer choice.
In real projects, though, I would rather not keep the discussion at the level of “how many cards.” Context length, concurrency, request type (chat, code completion, agents, retrieval-augmented generation, long documents), and response targets (time to first token, sustained throughput, stability) usually determine the final configuration more than card count does. Put differently, hardware is the constraint, and the business workload is the objective function.
2. Why you cannot estimate VRAM from activated parameters
The defining trait of a sparse model is “many total parameters, few activated per pass.” Activated parameters describe how many parameters actually take part in a single forward pass; they affect compute and memory-access pressure, not the size of the resident weights. At deployment time, VRAM is divided among at least four consumers:
- Full model weights: even when a MoE expert layer is not activated for a given request, it must stay resident in VRAM; otherwise it has to be reloaded on every request, with unacceptable latency.
- KV cache: grows roughly linearly with context length and concurrency, and is the main variable in long-context scenarios.
- Runtime and framework overhead: communication buffers, temporary activations, CUDA graphs, and memory-pool fragmentation.
- Extra structures from optimization features: multi-token prediction heads, prefix cache indexes, and so on.
The following illustrative estimation logic helps build intuition (the numbers only demonstrate the method and are not metrics for any specific product):
# Demonstrates how to break down the VRAM budgetdef estimate_vram(params_b, bytes_per_param, ctx_len, concurrency,layers, kv_heads, head_dim, bytes_per_kv):weights = params_b * 1e9 * bytes_per_paramkv_per_token = 2 * layers * kv_heads * head_dim * bytes_per_kvkv_cache = kv_per_token * ctx_len * concurrencyruntime = weights * 0.10 # Rule-of-thumb reserve: communication/temporary buffers/fragmentationreturn (weights + kv_cache + runtime) / 1e9 # GB
The conclusion is straightforward: weights decide whether the model can start at all, while the KV cache decides how many users and how much context you can serve. When context grows from 32K to 128K or beyond, the VRAM increase comes mainly from the cache rather than the weights, which is exactly why long-context scenarios need more VRAM headroom.
3. Inference engine differences: do not pick a side before checking the metric definitions
On identical hardware and with the same quantization format, different inference frameworks can swap places depending on workload shape. One typical observation: with speculative decoding, prefix reuse, and similar optimizations turned off to establish a baseline, some engines have faster time to first token on short requests; as prompts get longer, other engines show lower time to first token, while still possibly holding a slight edge in sustained output throughput.
This is not a contradiction, because different workloads care about different metrics:
- Chat and voice interaction: time to first token comes first, output speed second.
- Intelligent coding and agents: long-context stability and tool-call success rate come first.
- Retrieval-augmented generation and long documents: prefill efficiency and cache hit rate come first.
- Batch offline processing: overall throughput and cost per unit come first.
So the right approach is to run a comparative load test using your real prompt distribution and target concurrency, instead of copying a “who is faster” leaderboard.
4. Four questions to answer before starting the project
- Context: is the real daily distribution 32K, 128K, or do you genuinely need 256K or more? Is long context concentrated in a small number of requests?
- Concurrency: single-user validation, shared team use, or a service offered externally? How large is the gap between peak and average?
- Workload: which is the main scenario among chat, coding, agents, retrieval-augmented generation, and long documents, and which are the long tail?
- Acceptance: do you only need the service to come up, or are there explicit numeric targets for time to first token, throughput, and error rate?
These four answers directly determine card count, parallelism strategy, and whether multiple nodes are needed.
5. Parallelism strategy and topology: eight cards are not “VRAM added together”
Multi-card deployment commonly uses two kinds of partitioning. Tensor parallelism splits the weights of a single layer across cards horizontally; it involves frequent communication and is sensitive to inter-card bandwidth. Pipeline parallelism splits by layer; it moves less data but introduces bubbles. In practice the two are often combined, with expert parallelism carrying the distribution of MoE experts.
Also worth checking: whether inter-card links are symmetric, whether CPU and PCIe lanes are balanced, whether system memory is enough to handle weight loading and page cache, and whether local disk reads and writes can complete a cold start within an acceptable time. If any one of these becomes a bottleneck, it shows up as “the cards are not fully utilized but latency is high.”
6. Common pitfalls and how to avoid them
- Do not max out the context on the first launch. First run the window your workload commonly uses, then scale up step by step while watching the cache growth curve.
- Lock versions as a set across model format, inference framework, acceleration libraries, driver, and kernel; when troubleshooting, do not tune just one parameter.
- Enable optimization features one at a time: establish a baseline with no optimizations, then turn on speculative decoding and prefix caching, changing one thing at a time and recording metrics each time.
- Monitoring should cover VRAM, cache hit rate, queueing latency, and time to first token, not just utilization.
7. A reusable load-testing workflow
# Illustrative: fix the random seed and prompt set, then sweep concurrency and contextfor ctx in 8192 32768 131072; dofor c in 1 8 32; dobench --model local-sparse-llm \--context $ctx --concurrency $c \--dataset prompts.jsonl --warmup 2 --repeat 5 \--metrics ttft,tpot,throughput,error_ratedonedone
Organize the results into a two-dimensional “context × concurrency” table, then overlay the thresholds your workload can accept. That gives you a capacity watermark: at what concurrency latency starts to degrade, and at what context length you need to scale out or apply a fallback strategy (sliding window, summary compression, cache reuse).
8. Cloud or local: trade off based on data and elasticity
If data compliance requirements are strict and the workload is stable, self-built or dedicated resource pools are more controllable. If traffic fluctuates heavily and you need to validate quickly, building an elastic inference service on general cloud capabilities such as container platforms, object storage, message queues, log services, and monitoring and alerting is more economical. In these scenarios Baidu AI Cloud typically offers a general combination of components spanning compute, container orchestration, and observability, making it easier to link load testing, canary rollout, and scale-out into a closed loop.
9. Summary
For local deployment of ultra-large sparse models, the correct order is: first describe the business requests, context, concurrency, and acceptance targets, then work backward to the server and parallelism strategy; first establish a baseline with no optimizations, then enable optimizations one by one; first load-test with real workloads, then talk about scaling out. Asking only “are eight cards enough” yields an answer that stops holding as soon as the workload changes. Bring the workload into the test, and the configuration becomes deterministic.
