Open-Weight LLM Deployment Guide: From Evaluation to Production

    This guide covers the main decisions in deploying open-weight large language models. It compares API access with self-hosting, shows how to estimate GPU memory and compute needs, and defines latency, throughput, and cost targets. It also reviews license terms, weighs quantization, batching, and parallelism options, and explains when to use prompt engineering, retrieval-augmented generation, or fine-tuning. Finally, it describes a data preparation process and an evaluation loop for testing changes.

    1. Why Open Weights Matter

    There are two main ways to use large model capabilities: pay per call through an online API, or obtain the model weights directly and run them in your own environment. The two differ clearly in data control, cost structure, and engineering complexity.

    • API access: Quick to integrate, with no infrastructure to maintain. Data must be processed by an external service, and cost grows linearly with call volume.
    • Self-hosting: You control the data boundary, and you can adjust inference parameters and serving policies as needed. However, hardware purchase or rental, service operations, and version upgrades are all handled by your team.

    Which approach to choose depends on whether the business meets the following conditions: high data sensitivity, large and stable call volume, a need for deep customization, and clear internal requirements for latency and availability. Neither approach is inherently better than the other.

    2. An Evaluation Framework Before Deployment

    2.1 Estimating Memory and Compute

    GPU memory is the first hurdle in deciding whether a model can be deployed. You can estimate the memory needed for the weights themselves by multiplying the parameter count by the bytes per parameter:

    • Half precision (FP16/BF16): 2 bytes per parameter
    • 8-bit integer quantization (INT8): 1 byte per parameter
    • 4-bit integer quantization (INT4): 0.5 bytes per parameter

    For a 70B (70 billion) parameter model, half-precision weights need about 140GB of GPU memory, and about 35GB after INT4 quantization. Actual requirements also include the KV cache, activation values, and runtime overhead. For planning, teams usually reserve a 20% to 40% margin on top of the weight size. The KV cache grows with concurrency and context length. These figures are planning estimates, and final numbers must be confirmed through load testing.

    1. VRAM required ≈ weight memory + KV cache memory + runtime overhead
    2. Weight memory = parameter count × bytes per parameter
    3. KV cache memory ≈ concurrency × context length × cache size per token

    2.2 Throughput, Latency, and Cost Model

    Define target metrics before selecting a model:

    • Time to first token: the time from when a user sends a request to when the first output token arrives
    • Output throughput: tokens generated per second, which determines how many concurrent requests one device can serve
    • Peak concurrency and availability targets

    Two formulas are enough for cost comparison:

    • Monthly self-hosting cost ≈ amortized hardware cost + power and data center costs + operations staff
    • Monthly API cost ≈ monthly token volume × unit price

    Self-hosting has a cost advantage only when device utilization is high. When devices sit idle, hardware depreciation and electricity costs still accrue, and the unit cost rises quickly. Call volume forecasts are therefore a key input to the decision.

    2.3 Reviewing License Terms Before Deployment

    Review the license terms item by item before deployment. Focus on the scope of commercial use, redistribution conditions, constraints on derivative models, and restrictions on use cases. Keep a record of the review conclusions for future compliance audits.

    3. Inference Optimization and Quantization Trade-offs

    3.1 Weight Quantization

    Quantization reduces numerical precision to cut GPU memory use, and it may also improve throughput. The cost is accuracy loss, and sensitivity differs across tasks. In general, long-chain reasoning and code generation are more sensitive to precision, while simple classification and extraction tasks are less affected.

    Precision Memory Footprint Main Risk Recommended Use
    BF16/FP16 Highest High cost Quality baseline and evaluation reference
    INT8 About half of half precision Lower risk First choice for most production workloads
    INT4 About a quarter of half precision Complex tasks may degrade noticeably Resource-constrained or high-concurrency scenarios

    After quantization, compare all metrics against your own evaluation set. Do not judge the result only by how much memory was saved.

    3.2 Batching and Cache Management

    • Continuous batching: Dynamically merges requests that arrive at different times into the same batch. This reduces device idle time and improves throughput.
    • Paged KV cache management: Allocates the cache in pages. This reduces GPU memory fragmentation, so usable concurrency gets closer to the theoretical value.
    • Prefix caching: When many requests share the same system prompt, the already computed prefix is reused. This lowers time to first token.

    3.3 Parallelism Strategies

    When a single accelerator can hold the model, deploy on that single accelerator to avoid communication overhead. When the model exceeds the capacity of one accelerator, you can use the following approaches:

    • Tensor parallelism: Splits the computation of the same layer across multiple accelerators within one node. Communication is frequent, so this approach depends heavily on high-bandwidth interconnects inside the node.
    • Pipeline parallelism: Places different layers on different devices or nodes. It suits scaling across nodes but introduces pipeline bubbles that affect latency.

    3.4 Deployment Configuration Example

    The following is a generic configuration structure for illustration. The field names only show the design approach and do not define the parameters of any specific framework.

    1. model:
    2. weights_path: /models/<model-name>/ # Weights directory, bound to the version number
    3. sha256: "<checksum from the publisher>" # Must be verified before launch
    4. precision: bf16 # Runtime precision
    5. inference:
    6. quantization: none # none | int8 | int4
    7. parallel_devices: 2 # Number of devices used for tensor parallelism
    8. context_limit: 8192 # Maximum context length per request
    9. serving:
    10. max_concurrency: 64 # Concurrency limit per instance
    11. request_timeout_ms: 30000 # Release resources after timeout
    12. prefix_cache: true # Reuse shared prefixes

    4. Choosing a Customization Path

    Customization aims to make the model fit the business, not to make the model itself stronger. The approaches differ widely in cost and risk:

    Approach Suitable Scenarios Cost Main Risk
    Prompt engineering General tasks and rapid validation Low Capability ceiling is limited by the base model
    Retrieval-augmented generation (RAG) Depends on an internal knowledge base that changes often Medium Retrieval quality directly determines answer quality
    Parameter-efficient fine-tuning Fixed output formats and domain terminology Medium Requires high training data quality and is prone to overfitting
    Full fine-tuning Deep domain adaptation with large data volumes High High compute and maintenance cost, and it may hurt general capabilities

    Invest step by step in the order of prompt engineering, retrieval augmentation, parameter-efficient fine-tuning, and full fine-tuning. Most business problems can be solved in the first two steps, so training is not needed from the start.

    4.1 Data Preparation Process

    Training data quality usually matters more than quantity. Process the data in these steps:

    1. Collect: Define the data sources and the authorized scope of use.
    2. Deduplicate: Remove exact duplicates and highly similar samples to avoid excessive memorization.
    3. Redact: Remove personal information, account identifiers, keys, and other sensitive fields.
    4. Standardize formats: Convert data from different sources into a consistent instruction and response structure.
    5. Split: Divide the data into training, validation, and test sets. The test set must not be used for training.
    6. Spot-check: Randomly sample records for manual quality review. Rework the entire batch if it fails.

    4.2 Evaluation Loop

    Every change to the model or configuration should go through the same evaluation, rather than relying on intuition.

    1. For each case in the evaluation set:
    2. output = call the model under test(case.input)
    3. score = scoring rule(output, case.reference_answer)
    4. record(case.id, score, model version, config version)
    5. Summarize the overall average score and the breakdown by task