Local LLM Deployment: Model Selection and Speed Optimization Guide

    This guide explains how to choose and speed up locally deployed large language models on consumer GPUs. It covers the capacity-speed-capability trade-off, VRAM estimation for weights and KV cache, practical differences between Q4 and Q6 quantization, the impact of context length on throughput, key runtime settings, task-based selection recommendations, and a repeatable acceptance and tuning workflow.

    1. The Core Problem: Local Inference Is a Three-Way Trade-Off Between Capacity, Speed, and Capability

    When running large models on consumer GPUs, most people first ask which model is the best. But what really determines the experience is not a model leaderboard. It is the mutual pressure among three variables: the VRAM and memory capacity required by the model weights, the token throughput achievable during the decoding stage, and the model’s own capability ceiling. Max out any one of them, and the other two must give way.

    Once you understand this, selection shifts from finding the strongest model to finding the combination that best matches your hardware and task. A common mistake is treating parameter count as a capability indicator. In fact, many modern open-source models use a mixture-of-experts (MoE) architecture, where the total parameter count is not the same as the number of parameters actually activated in a single forward pass. Total parameters determine how much space the weights occupy; activated parameters determine the computation and speed. This explains why a model with about 3B activated parameters out of more than 30B total can reach a decoding speed of 40 to 50 token/s on a 12 GB VRAM machine, while a dense 27B model, even quantized to 4-bit, runs at only single-digit token/s.

    2. Capacity Estimation: First Check Whether the Model Fits

    The first step in selection is not speed but capacity. A rough yet sufficiently reliable estimate is: at 4-bit quantization, each billion parameters takes about 0.6 to 0.7 GB of VRAM; at 8-bit, about 0.9 to 1.0 GB per billion parameters; at 16-bit, close to 2 GB per billion parameters. You also need to reserve space for the KV cache, which grows linearly with context length and depends on structural parameters such as the number of layers, the number of attention heads, and whether grouped-query attention is used.

    The key conclusion is that weights can overflow into memory, with the CPU joining the computation, but the cost is a cliff-like drop in speed. In testing, a 12 GB VRAM machine running a 27B-class 4-bit quantized model reached only about 3.6 token/s, which is basically unusable for interactive work. In contrast, a sparse model with 35B total parameters and about 3B activated per token could fit its weights plus KV cache into VRAM relatively comfortably, holding a steady speed above 40 token/s. So the principle of capacity planning is to prioritize keeping the weights and the KV cache for the commonly used context length entirely resident in VRAM, treating memory as a buffer rather than a source of compute.

    A rough capacity calculation can be written as:

    1. def estimate_vram(params_b, bits, ctx_len, kv_bytes_per_token):
    2. weight_gb = params_b * (bits / 8) * 1.0 / 8 * 8 / 8 # Convert per billion parameters according to bits
    3. weight_gb = params_b * bits / 8 / 1000 * 1000 / 8
    4. return weight_gb, ctx_len * kv_bytes_per_token / 1024**3

    In real engineering, it is better to read the weight usage and KV cache usage printed in the runtime logs directly, and then adjust the context limit accordingly, avoiding repeated trial and error based on formulas.

    3. Quantization Precision: The Real Difference Between Q6 and Q4

    Quantization compresses 16-bit weights into a low-bit representation to gain capacity and bandwidth benefits. The decoding stage is limited by VRAM bandwidth, so the speedup from low-bit quantization is often more noticeable than expected. For the same model, moving from the 6.5-bit tier down to the 4.2-bit tier raised measured throughput from 42 token/s to 55 token/s, and in long-context scenarios from 37 to around 50.

    It is important to stress that quantization is not lossless. The rule of thumb is that capability regression becomes noticeable below 8-bit, and the gap widens at the 4-bit tier for tasks such as long-document summarization, multi-step reasoning, and code generation. The recommendation is: if the model has capability to spare (for example, a 30B-class sparse model is more than enough for the task), trading it for speed with 4-bit is worthwhile; if the model is already at the capability floor, keep higher precision and accept sacrificing context length or lower speed.

    4. Context Length: The Underestimated Performance Variable

    Extending the context from 4,000 tokens to 20,000 tokens dropped measured throughput from 42 to 37, and for the sparse model from 55 to 50. The drop looks mild, but VRAM usage grows linearly or even super-linearly, and once weight swapping is triggered, speed falls into an unusable range.

    A more effective engineering approach is not to force very long contexts but to process in layers: first use retrieval or segmented summarization to compress the material to a few thousand tokens, then hand it to the model for synthesis; for tasks that must take long input, use a hybrid strategy of a sliding window plus a global summary. This preserves speed and avoids the quality degradation caused by attention dilution under long contexts.

    5. Key Runtime Configuration

    • Set the context length to what the task actually needs; do not max it out by default. The KV cache is the most easily overlooked VRAM killer.
    • Turning off unnecessary chain-of-thought output can significantly reduce the number of output tokens and latency. Most GUI inference tools support this through a switch field in the prompt template, for example by writing a disable-thinking flag variable in the system prompt.
    • For sampling, use a temperature of 0.2 to 0.4 and top_p of 0.9 to balance stability and diversity. Higher batch concurrency improves GPU utilization but raises VRAM pressure at the same time.
    • If you use a cloud-based approach, you can deploy inference services on a container platform, put logging and monitoring alerts in front to observe time-to-first-token and throughput, and host model weights and versions on object storage.

    6. Selection Conclusions by Task Type

    • Daily Q&A, structured extraction, short-text rewriting: prioritize a medium-sized sparse model with 4-bit quantization, above 50 token/s, with an interactive experience close to the cloud.
    • Long-document understanding, report summarization, complex reasoning: choose a more capable dense model and accept lower speed, or switch to elastic cloud compute.
    • Very long context with stability requirements: small-parameter models are more reliable under long windows and can serve as a preprocessing and initial screening stage.
    • Pursuing ultimate quality: 12 GB of local VRAM is unrealistic, so turn to on-demand cloud calls, with local handling only data preprocessing and privacy-sensitive steps.

    7. Acceptance and Tuning Workflow

    It is advisable to set up a fixed acceptance script: the same prompt set covering short Q&A, long-document summarization, and code generation, with a fixed random seed, recording time-to-first-token, steady-state throughput, peak VRAM usage, and output quality scores. Change only one variable at a time (quantization tier, context limit, concurrency) to form a comparison table. This turns selection from subjective impression into a reproducible engineering decision, and makes it easy to recalibrate parameters quickly after a hardware upgrade.