Local LLM Deployment Guide: VRAM Requirements and Inference Optimization Essentials

    This guide covers the key considerations for deploying large language models on local hardware, including how to estimate VRAM requirements, optimize KV Cache usage, configure container startup parameters safely, and improve serving performance through Prefill-Decode disaggregation.

    1. First, Do the VRAM Math

    As model parameter counts climb into the hundreds of billions, VRAM becomes the first barrier to local deployment. The memory occupied by model weights can be estimated directly: parameter count multiplied by bytes per parameter. For a 100B-parameter model, weights require roughly 200GB in BF16 precision and about 100GB in FP8. This excludes KV Cache, activation values, communication buffers, and framework overhead, so you should reserve additional VRAM in practice. The exact amount depends on context length and concurrency, and should be verified with real measurements.

    GPU count recommendations typically come from the deployment guides published by model providers. Some guides suggest 4 GPUs for a lightweight variant and 8 GPUs for an extra-large variant, but these numbers must be verified against the specific model version—they cannot be copied blindly from secondhand sources.

    When selecting hardware, per-GPU VRAM is only one metric. Interconnect bandwidth between GPUs (such as NVLink or PCIe) and network latency between nodes directly affect tensor parallelism efficiency. If your deployment spans multiple nodes, network quality often becomes the bottleneck before single-GPU compute does.

    2. KV Cache Quantization: Reducing VRAM Pressure Under Concurrency

    The KV Cache stores the key and value vectors for every processed token, and its memory footprint grows with context length, number of concurrent requests, and layer count. A rough estimation formula is: 2 × number of layers × number of KV heads × head dimension × sequence length × concurrency × bytes per element.

    Quantizing the KV Cache from FP16 to FP8 halves the bytes per element, allowing the same VRAM to hold roughly twice the cache capacity. This is a common practice, but its precision impact depends on the model architecture, task type, and quantization calibration method. Code generation, mathematical reasoning, and long-document retrieval each respond differently to precision changes. Evaluate quantized and non-quantized results against your own business benchmark before going live, and confirm the difference is acceptable.

    Block size also needs to be tuned per scenario. Inference frameworks with Paged Attention split the KV Cache into fixed-size blocks. Larger blocks mean fewer memory allocations, but short requests waste more of the final block, causing internal fragmentation. Common frameworks default to 16 or 32; larger blocks (such as 256) suit long-context scenarios with similar request lengths. There is no universally optimal block size—test against your own request length distribution.

    3. Startup Command Example and Checklist

    Below is a sample container startup command. Parameter names vary across framework versions, so verify each item against the documentation for your version before use.

    1. docker run --gpus '"device=0,1,2,3"' \
    2. --ipc=host \
    3. -p 127.0.0.1:8000:8000 \
    4. -v /data/models/<model-name>:/models/<model-name>:ro \
    5. <inference-image>:<pinned-tag> \
    6. --model /models/<model-name> \
    7. --kv-cache-dtype fp8 \
    8. --block-size 32 \
    9. --tensor-parallel-size 4

    Check the following before and after startup:

    • Pin the image to a specific version tag; never use latest.
    • -p 127.0.0.1:8000:8000 listens on localhost only. If you must expose the service externally, place it behind a gateway or reverse proxy and enable authentication.
    • --ipc=host lets the container share the host’s IPC resources, which weakens container isolation—assess the risk.
    • If the framework offers an option to execute remote model code, enable it only after reviewing the code and pinning the model version, to avoid running untrusted code.
    • Allocate only the GPUs you actually need; don’t default to all devices.
    • After startup, verify outputs with fixed test requests and record VRAM usage.

    4. PD Disaggregation: Separating Prefill and Decode

    The Prefill phase processes the entire input prompt at once, making it compute-intensive. The Decode phase generates tokens one at a time, reading large amounts of weights and KV Cache at each step, making it memory-bandwidth-intensive. When both run on the same set of GPUs, long Prefill requests slow down ongoing Decode requests, causing jitter in time per output token (TPOT) and potentially higher time to first token (TTFT).

    Prefill-Decode disaggregation (PD disaggregation) runs the two phases on separate GPU groups. With 8 GPUs, for example, you can allocate 4 GPUs to Prefill and 4 to Decode, or adjust the split based on your actual workload ratio. Once Prefill completes, the KV Cache must be transferred to the Decode node over a high-speed network (commonly RDMA).