Selecting and Quantizing 31B Dense Models: A Practical Deployment Guide

    This article explains how to choose and deploy a 31B-parameter dense open-source model in production. It covers model card verification, VRAM estimation (weights, KV cache, and runtime overhead), quantization workflows (BF16, 8-bit, AWQ/GPTQ 4-bit), inference framework selection, business evaluation, common troubleshooting, and a pre-launch checklist. Written for engineers who need a practical, capacity-aware deployment plan with minimal risk.

    1. What “31B” Actually Means

    “31B” refers to a model with approximately 31 billion parameters. The “dense” models discussed in this article activate all parameters on every inference pass. This differs from Mixture-of-Experts (MoE) models, which route each token through only a subset of expert parameters. For dense models, VRAM usage and compute scale directly with parameter count, making capacity estimation straightforward.

    This parameter scale is widely adopted because it sits between capability and cost. It handles more complex reasoning and coding tasks than smaller models, while being far easier to deploy on a single server than much larger counterparts.

    2. Verify the Model Card Before Selection

    The original text does not specify a concrete model name, version, or source, so readers cannot independently verify capability claims. Before deployment, confirm the following details from the official model card and record them in your team’s model selection log:

    • Full model name and version, including any version suffix in the repository name.
    • License type as stated on the model card; have legal review the terms before commercial use.
    • The official maximum context length and how it was tested.
    • Supported input modalities (e.g., image, video, OCR).
    • Supported language coverage.
    • Architecture parameters from the configuration file: layer count, KV head count, head_dim, etc., used for VRAM estimation.

    Do not include capabilities in your proposal or marketing materials that are not explicitly documented on the model card.

    3. VRAM Estimation: Weights Are Only Part of the Picture

    Weight size is straightforward to calculate: parameter count × bytes per parameter.

    Precision Bytes per Parameter Approx. Weight Size Use Case
    BF16 2 ~62 GB Precision baseline; requires large VRAM
    8-bit 1 ~31 GB Acceptable quality loss for most use cases; requires testing
    4-bit (e.g., AWQ, GPTQ) ~0.5 ~16–17 GB Local development or consumer GPUs; retest long-context scenarios

    These numbers cover weights only. A production service must also reserve space for the following:

    1. KV cache: For each token, K and V must be stored per layer. Bytes per token = 2 × number of layers × KV heads × head_dim × bytes per element.
    2. Activations and runtime overhead: CUDA context, framework buffers, and similar typically require several additional GB.
    3. Unquantized components in quantized checkpoints: Embedding and output layers are often kept at higher precision, so the actual file size may exceed the estimate.

    The following example uses assumed values to demonstrate the scale; always reference the model’s actual config.json. Assume 64 layers, 8 KV heads, head_dim of 128, with KV cache stored in BF16: each token uses about 256 KB. A 32K-token request consumes approximately 8 GB of KV cache. Adding BF16 weights (~62 GB) brings the total close to 80 GB. If the context extends to 256K tokens, the KV cache alone would require roughly 64 GB—a single 80 GB GPU cannot reliably sustain a BF16 configuration at that length.

    In short: fitting weights on a single 80 GB GPU does not guarantee the model can serve long contexts or high concurrency. Capacity planning should be based on measured peak VRAM usage, not theoretical weight size.

    4. Quantization and Deployment Workflow

    1. Run a BF16 baseline on hardware matching your production environment. Record time-to-first-token, tokens per second, and peak VRAM usage.
    2. Select a quantization method. Common practice is AWQ or GPTQ for weights, with optional FP8 quantization for the KV cache. The two can be combined, but must be re-evaluated as a whole.
    3. Compare quantized output against the baseline using the same set of business samples. Record accuracy, output-format compliance rate, and latency.
    4. Set your maximum context length and maximum concurrency, then stress-test for peak VRAM. Reserve at least 10% headroom.
    5. Roll out gradually. Monitor error rate, overly long outputs, and timeout ratio. Only switch full traffic after confirming stability.

    5. Inference Frameworks and Example Launch Commands

    Common choices include vLLM, SGLang, and TensorRT-LLM. Key differences:

    • vLLM: Broad community ecosystem with an OpenAI-compatible API; well suited for rapid deployment.
    • SGLang: Optimized for structured output and multi-turn invocation; verify support for your target model.
    • TensorRT-LLM: Offers deep tuning on NVIDIA platforms, but the build process and version dependencies are more complex.

    Example with vLLM (adjust parameter names to your version; replace the model path with a local directory or the official repository name):

    1. vllm serve <model-path-or-repo-name> \
    2. --max-model-len 32768 \
    3. --gpu-memory-utilization 0.90 \
    4. --tensor-parallel-size 1

    If using quantized weights, specify the format accordingly. For an AWQ version, add --quantization awq. Refer to the model card and framework documentation for the exact value.

    Once the service is running, call it via the OpenAI-compatible endpoint:

    1. curl http://localhost:8000/v1/chat/completions \
    2. -H "Content-Type: application/json" \
    3. -d '{"model": "<model-name>", "messages": [{"role": "user", "content": "Hello"}]}'

    Do not expose the inference port directly to the public internet. Place a gateway in front to handle authentication, rate limiting, and access logging.

    6. Business Evaluation: Public Benchmarks Are Only a First Filter

    Public benchmark scores reflect general capability. Real-world results are also affected by prompt design, retrieval quality, and output parsing. Use a two-stage selection process: first, use public benchmarks to filter out clearly inadequate candidates; second, use business-specific data for the final decision. A typical evaluation table includes the following fields:

    Field Description Example
    Task Specific task in your business Contract clause extraction
    Sample size Number of samples per task At least 200 per task recommended
    Metrics Accuracy, format compliance, latency Field-level F1
    Threshold Minimum bar for launch Must not underperform the current solution
    Regression Re-test after each version or quantization change Fixed sample set

    7. Common Issue Troubleshooting

    • Out-of-memory (OOM) at startup: Reduce the maximum context length or gpu-memory-utilization, or switch to a lower-precision weight format.
    • Degraded output quality on long texts: First confirm whether 4-bit quantization is active; compare against 8-bit or BF16 results.
    • Low throughput: Verify that the framework supports the compute kernels for your selected quantization format, and check batching-related settings.
    • Truncated output: Check whether max_tokens plus input length exceeds the model’s context limit.

    8. Pre-Launch Checklist

    • Model name, version, and license verified from the official model card.
    • VRAM estimation includes weights, KV cache, and runtime overhead.
    • Business evaluation set established; quantization results compared against baseline.
    • Stress tests completed for the target context length and concurrency level.
    • Service configured with authentication, rate limiting, and monitoring.