Local Deployment Guide for Small-to-Medium Dense LLMs: VRAM, Quantization, and Evaluation

    This guide explores the practical considerations of locally deploying small-to-medium dense Large Language Models (LLMs) in the 20B to 30B parameter range. It compares the advantages of dense architectures against Mixture-of-Experts (MoE) models, outlines a task-driven approach to benchmark evaluation, and provides a detailed framework for calculating VRAM budgets for both model weights and KV cache. The article also offers recommendations for selecting quantization methods to ensure optimal performance on workstation and consumer-grade GPUs.

    Is Local Deployment Worth It?

    Dense models in the 20B to 30B parameter range are now capable of handling complex tasks. However, there is a difference between “running a model” and “using it reliably in production.” When deciding on local deployment, consider three primary factors: whether your data must remain within an intranet, how sensitive your application is to request latency, and whether your API call volume is high enough to make cloud costs prohibitive.

    This article assumes you are using a workstation or one to two GPUs with 24GB to 80GB of VRAM. The figures and examples provided are based on this hardware scenario.

    1. Advantages of Dense Architecture in This Parameter Range

    A dense model utilizes all of its parameters to generate each token. In contrast, a Mixture-of-Experts (MoE) model only activates a subset of experts, resulting in lower computational cost per token. Choosing a dense architecture typically offers three main advantages:

    1. More Predictable Behavior: Dense models do not rely on expert routing, meaning output quality does not suffer from occasional fluctuations caused by routing outcomes. This is particularly beneficial for agentic tasks that require continuous, multi-step decision-making.
    2. More Uniform Quantization Error Distribution: Quantization introduces rounding errors. In dense models, every layer participates in all computations, preventing errors from concentrating in specific experts. However, this must be validated on your own evaluation sets rather than being accepted as an absolute conclusion.
    3. Simpler Deployment Pipeline: Dense models can run on a single machine with a single GPU or a consumer-grade multi-GPU setup, eliminating the need for expert parallelism and complex load balancing.

    Dense architectures do come with trade-offs. Both VRAM usage and computational load scale proportionally with the total number of parameters. If an MoE model offers higher throughput at the same quality level, a dense model may be more expensive in high-concurrency scenarios. Throughput and cost should always be evaluated together during model selection.

    2. Evaluation: Define Tasks Before Choosing Benchmarks

    When evaluating a model, avoid relying solely on an aggregate leaderboard. Instead, clearly define your business tasks first, then select the corresponding benchmarks.

    2.1 Code and Software Engineering

    • SWE-bench Verified: Based on real open-source repository issues, the model must locate the problem, modify the code, and pass corresponding unit tests. It assesses cross-file comprehension and patch correctness, making it much closer to actual development than simple code completion.
    • LiveCodeBench: Collects competitive programming questions and segments them by release date to minimize artificially inflated scores caused by training data leakage. It primarily evaluates algorithmic reasoning and first-attempt pass rates.

    Scores on these benchmarks are influenced by many factors, including the agentic framework, toolsets, maximum step limits, and the number of runs. Scores are only comparable if tested under identical conditions.

    2.2 Agents and Tool Calling

    For agentic tasks, you need to measure two metrics simultaneously: single-step action accuracy and overall task completion rate. The difference between the two can be substantial. For example, if a task requires 10 steps, and each step has a 95% accuracy rate with independent steps, the overall task completion rate drops to 0.95^10, or roughly 60%. The single-step accuracy may look impressive, but the overall result might be insufficient.

    Reference benchmarks include:

    • OSWorld: Completing GUI operations in a real desktop environment.
    • tau-bench: Simulating multi-turn tool calling and user interactions in scenarios like retail and aviation.

    2.3 Instruction Following and Reasoning

    • IFEval: Tests instruction following using automatically verifiable constraints, such as word count, formatting, and keyword frequency.
    • MMMU: Assesses multimodal reasoning across multiple disciplines, suitable for evaluating visual inputs.
    • Competitive math problems are highly susceptible to training data contamination, so their results should be interpreted with caution.

    2.4 Multimodal and Long Context

    The context length listed on a model card typically refers to its natively supported length. Exceeding this requires position extrapolation techniques, the effectiveness of which must be tested independently. Long context also significantly increases KV cache usage, which is discussed in detail below.

    Image and video inputs also consume token quotas. A single high-resolution image can correspond to thousands of tokens, meaning multimodal deployments will face VRAM constraints much earlier than text-only deployments.

    2.5 Minimum Requirements for Reporting Numbers

    Any reported score should be accompanied by the following information: model name and version, quantization method, benchmark name and version, number of runs, decoding parameters, and the agentic framework used. Without this information, numbers cannot be reproduced by others or used for cross-model comparisons.

    3. VRAM Budget

    3.1 Weight Footprint

    Estimating the VRAM required for model weights is straightforward: multiply the parameter count by the number of bytes per parameter. Using a 27B parameter dense model as an example:

    Precision Weight Footprint (approx., excluding KV cache) Typical Hardware Baseline Notes
    FP16 / BF16 54 GB Single 80GB GPU or multi-GPU Highest precision, highest cost
    FP8 / INT8 27 GB Single 48GB GPU Precision loss requires empirical testing
    INT4 14–17 GB Single 24GB consumer GPU Very little headroom, only suitable for short contexts

    The INT4 figure includes the quantization scaling coefficients and the space occupied by layers retained at higher precision. None of the figures in the table account for other runtime overheads.

    3.2 KV Cache Footprint

    The KV cache calculation formula is as follows:

    Per-token usage = 2 × Number of layers × Number of KV heads × Head dimension × Bytes per element

    Total usage = Per-token usage × Sequence length × Number of concurrent requests

    These parameters can be found in the model’s configuration file, such as num_hidden_layers, num_key_value_heads, and head_dim.

    Here is an example using a hypothetical model: 64 layers, 8 KV heads, a head dimension of 128, and stored in FP16.

    • Per-token usage: 2 × 64 × 8 × 128 × 2 bytes = 256 KB
    • 16K context, single request: approx. 4 GB
    • 64K context, single request: approx. 16 GB

    If the weights use INT4 quantization (approx. 15 GB), running a 64K context on a 24GB GPU would require roughly 31 GB for weights and KV cache combined, exceeding the VRAM capacity. Therefore, the claim that “INT4 can run on 24GB” is only true under the premise of short contexts and a single request.

    3.3 Quantization Selection

    Prioritize quantized versions with a public calibration process, such as AWQ or GPTQ formats. The precision loss after quantization should be measured on your own evaluation set rather than adopting numbers from others.