Local LLM Deployment: A Practical Guide to VRAM and Workload Assessment
This article explains how to plan local deployment of large language models, with a focus on GPU memory budgeting and workload evaluation. It covers why starting from GPU count alone is unreliable, how to break total VRAM into weights, runtime overhead, KV cache, and safety margin, and how precision format and context length act as decisive constraints. It also compares inference framework trade-offs across short requests and long prompts, provides a four-question decision checklist, lists common deployment pitfalls, and outlines a general approach to cloud deployment. Readers will learn how to move from a minimal "can it start" configuration to a configuration validated against real business traffic.
1. Start with Constraints, Not GPU Count
When a newly released large-scale multimodal Mixture-of-Experts (MoE) model appears, the most common first question is “how many accelerators do I need to run it?” The question is reasonable, but it rarely leads to an actionable answer. A more reliable order is to first confirm two hard constraints—precision format and context length—to obtain a reference configuration that can start; then introduce concurrency, request types, and response targets to determine whether that configuration can support real workloads.
One frequent misconception needs clarification: for an MoE model, “active parameters” refers to the parameter scale that is routed and activated in a single forward pass and participates in matrix computation. It determines compute consumption and single-request latency characteristics, not VRAM usage. Weights must reside in VRAM in their complete form; routing layers, shared layers, normalization parameters, vocabulary, and output projections also occupy space. Dividing active parameters by VRAM capacity is the most typical calculation error in local deployment.
2. VRAM Budget: Break “Total Sum” into Four Items
A reusable budgeting formula is:
Total VRAM ≈ weights + runtime overhead + KV cache + safety marginKV cache ≈ 2 × layers × KV heads × head dimension × sequence length × concurrency × bytes per element
Among the four items, weights and runtime overhead are relatively fixed. What actually fluctuates with the workload is the KV cache, which scales linearly with both context length and concurrency. This means the cache overhead of a scenario with 128K context and 32 concurrent requests can be hundreds of times that of a single 8K session.
In engineering practice, reserve 15%–25% headroom for the framework’s communication buffers, temporary activations, VRAM fragmentation, and burst peaks. When headroom is insufficient, the problem usually does not appear as a “startup failure” but as allocation failures or severe throughput jitter after running for a while, which is more costly to troubleshoot.
For multi-GPU deployment, note that VRAM is not simply additive: tensor parallelism splits weights across GPUs, but communication buffers, per-GPU runtime contexts, and framework caches are duplicated, so the actual usable ratio is lower than the theoretical value.
3. Precision and Context: Two Decisive Variables
Precision format directly determines weight size. The weight footprint of the same model differs by roughly a factor of two between FP8 and BF16, while 4-bit quantization compresses VRAM further but may introduce accuracy loss and more complex operator support issues. The choice should be based on business acceptance metrics rather than simply “fitting in memory.”
Context length affects both VRAM and latency. Attention computation and cache reads/writes both grow with sequence length, and time to first token (TTFT) is especially sensitive to long prompts. A pragmatic approach is to first lock the window that the business actually needs (most conversational and retrieval-augmented scenarios fall in the 32K–128K range) and treat ultra-long windows as an optional capability rather than a default.
4. Framework Selection: Trade-offs Between Short Requests and Long Prompts
Different inference frameworks optimize for different goals, and performance varies with workload shape. With optional optimizations such as speculative decoding and prefix caching disabled to establish a clean baseline, common patterns are:
- Short requests, low-latency chat: implementations with low scheduling overhead and aggressive batching strategies have advantages in TTFT and output throughput;
- Long prompts, document analysis: implementations with more thorough prefill-phase optimization achieve lower TTFT;
- Sustained output phase: differences between implementations usually narrow, so measurements are needed.
There is therefore no universally “faster framework.” The recommendation is to run an A/B test with your own prompts:
# Minimal example: a comparison benchmark loopcases = [{"name": "chat_short", "prompt": short_prompt, "concurrency": 8, "max_tokens": 256},{"name": "doc_long", "prompt": long_prompt, "concurrency": 4, "max_tokens": 1024},{"name": "agent_mix", "prompt": agent_prompt, "concurrency": 16, "max_tokens": 512},]for c in cases:run_benchmark(backend=backend_a, **c) # record TTFT, TPOT, throughput, error raterun_benchmark(backend=backend_b, **c)
Metrics should cover at least four items: TTFT, time per output token, total system throughput, and timeout/failure rate. Looking at throughput alone can easily mask tail-latency problems.
5. Four-Question Decision Checklist
- Context: is 32K or 128K common, or is there a hard need for 256K or more?
- Concurrency: single-user validation, team sharing, or external service?
- Workload: which is the primary scenario—chat, intelligent coding, agents, retrieval augmentation, or long documents?
- Acceptance: is “it starts” enough, or are there explicit numerical requirements for latency, throughput, and stability?
Once these four questions are answered, the configuration can basically be derived in reverse: first use weights and precision to determine the minimum GPU count and the per-GPU VRAM lower bound, then use context and concurrency to determine the cache budget, and finally validate against acceptance targets to check whether latency requirements are met.
6. Common Pitfalls and How to Avoid Them
- Maxing out context on first startup: first run the window commonly used by the business, then scale up step by step to observe the inflection point.
- Version drift: model weights, inference framework, acceleration libraries, drivers, and kernels need to be locked as a whole; avoid tuning a single parameter during troubleshooting.
- Ignoring topology: inter-GPU interconnect bandwidth, whether P2P and collective communication work properly, CPU and PCIe lanes, host memory and local disk throughput can all become bottlenecks.
- Enabling all optimizations at once: speculative decoding, prefix caching, and similar features should be enabled one by one, keeping a baseline for rollback and localization.
- Lack of observability: only by wiring latency, throughput, VRAM, and error rates into logging and monitoring alerts can you tell whether scaling up is due to insufficient compute or misconfiguration.
7. A General Approach to Cloud Deployment
If cloud resources are used, a general capability combination can be assembled: a container platform hosts inference services and elastic scaling, object storage holds model weights and datasets, a message queue smooths peaks and fills valleys, and logging plus monitoring alerts handle observability. In such scenarios, Baidu AI Cloud typically provides general-purpose capabilities; specific specifications and quotas should be based on the actual provisioned environment.
The final criterion is simple: if you only ask “can it run on a few GPUs,” the answer can be given once precision and context are determined; if you ask “can it support the business,” you must bring real requests into the benchmark.
