31B Dense Model Deployment Guide: VRAM Estimation and Selection

    This guide explores deployment scenarios and strategies for 31-billion (31B) parameter dense large language models. It details the essential specifications to verify before deployment and provides a step-by-step approach to estimating VRAM usage, covering weights, KV cache, and activation overheads, helping teams plan capacity and select hardware efficiently.

    What Scenarios Suit Dense Models?

    During inference, a dense model computes all parameters for every token, whereas a Mixture of Experts (MoE) model routes to activate only a fraction of them. This architectural difference directly impacts deployment strategies.

    The fixed computational path of a dense architecture makes latency more predictable and post-fine-tuning behavior more straightforward. It is well-suited as a base model for coding assistants, Agent workflows, and complex reasoning tasks. The trade-off is that weights consume more VRAM, and the computational cost per inference is higher.

    If your team requires stable latency and straightforward capacity planning, a 31B dense model is a strong candidate. If high throughput and low unit cost are the primary goals, evaluate MoE solutions first.

    Conclusion first: 31B dense models are suitable for scenarios demanding stable latency and simple capacity planning. Before deployment, estimate VRAM across three components: weights, KV cache, and activations/framework overhead. Quality regression testing is mandatory after quantization, and results must be confirmed before going live.

    How many GPUs does a 31B model require? Can it run on consumer-grade graphics cards? Will int4 quantization degrade performance? The answers depend on model specifications, precision, and concurrency targets. The following sections outline estimation methods and validation steps.

    What Specifications to Confirm Before Deployment

    Always refer to official model cards and configuration files for specifications rather than relying on second-hand information. Before starting your estimation, record the following items:

    Item Where to Verify Why It Matters
    Parameter count & version Model card, version page of the weight repository Determines weight VRAM; different versions may have different architectures
    Layers, KV heads, head dimension config.json Determines the per-token KV cache footprint
    Context limit Model card & config file Determines max input length, but does not guarantee reliable long-text performance
    Supported modalities Model card Determines if preprocessing for visual inputs is required
    License terms Original license text Governs commercial use and distribution requirements

    Common mistakes fall into three categories. First, checking only the parameter count while ignoring the number of layers and KV heads, leading to skewed KV cache estimates. Second, overlooking license terms before commercial use or redistribution. Third, treating the context limit as a guarantee of long-text effectiveness.

    The numerical examples in this article are based on hypothetical configurations. For actual calculations, substitute the values from your config.json.

    How to Estimate VRAM for a 31B Dense Model

    VRAM is divided into at least three parts: weights, KV cache, and activations/framework overhead. Many teams calculate only the weights and run out of VRAM when handling long-text requests in production.

    Weight VRAM

    Weight VRAM is calculated as: Parameter count × Bytes per parameter. Taking a 31B parameter model as an example:

    Precision Bytes per Parameter Weight Size (GB) Weight Size (GiB)
    bf16 2 62.0 57.8
    int8 1 31.0 28.9
    int4 0.5 15.5 14.4

    Quantization formats typically also save scaling parameters (e.g., scale, zero point), which are not included in the table. Actual weight files will be slightly larger than the values shown.

    KV Cache VRAM

    The KV cache bytes per token is calculated as: 2 × Number of layers × Number of KV heads × Head dimension × Bytes per element. The total footprint for a request equals the per-token bytes × Sequence length × Batch size.

    Assuming a configuration of 64 layers, 8 KV heads, a head dimension of 128, and a KV cache using bf16 (2 bytes per element), the calculations are as follows:

    • Per token: 2 × 64 × 8 × 128 × 2 = 262,144 bytes, or approximately 256 KiB.
    • 1 request, sequence length 32,768: 262,144 × 32,768 ≈ 8 GiB.
    • 8 concurrent requests, 8,192 tokens each: 262,144 × 8,192 × 8 ≈ 16 GiB.

    Switching the KV cache to int8 halves this footprint. Long contexts and high concurrency can cause the KV cache to exceed the weight size, becoming the VRAM bottleneck.

    Activations and Overhead

    Peak activations correlate with batch size and prefill length. The framework also requires workspace and CUDA contexts. It is recommended to reserve at least 15% to 25% of VRAM headroom to accommodate long contexts and large batch sizes.