Open-Weight Large Models: Local Deployment and Capacity Planning in Practice

    This guide covers the engineering essentials of running open-weight large language models on your own infrastructure. It explains how open-weight releases differ from API-hosted and fully open-source models, then walks through license review, VRAM estimation, quantization choices, inference modes, serving architecture, performance tuning, and production rollout. It also provides a practical order for choosing between prompting, RAG, and fine-tuning, plus a checklist of common deployment mistakes.

    1. Open Weight Is Not Open Source

    When a model provider releases complete model weights, the technical community often discusses market implications, and demand for related compute hardware may also attract attention. From an engineering perspective, the core change is a shift in delivery model: the model user moves from being an API caller to a weight holder.

    Three model forms should be distinguished clearly:

    Form What you hold Control Responsibility boundary
    API-hosted None Limited by provider parameters and quotas Availability is handled by the service provider
    Open weight Weight files plus configuration Deployment location, batching strategy, and context strategy are controlled by the user Resource planning, stability, and compliance are the user’s responsibility
    Fully open source Weights plus training code and data pipeline Retraining is possible Full lifecycle responsibility

    Open-weight releases usually guarantee only that inference is reproducible. Training code, data mixtures, and data cleaning processes are generally not released. As a result, open weights provide deployment freedom, not training freedom.

    This creates two direct consequences:

    1. Hardware costs shift from pay-as-you-go usage to fixed or reserved capacity, which means capacity planning must be done by the deploying organization.
    2. Security responsibility shifts as well. Once weights run in a self-owned environment, access control, log retention, and content moderation become engineering obligations of the user.

    2. Four Pre-Deployment Checks

    2.1 License Terms and Compliance Constraints

    Open-weight releases often come with usage licenses. Each condition should be reviewed carefully:

    • Whether commercial use is allowed
    • Whether there are restrictions on specific industries or regions
    • Whether derivative models must remain open
    • Whether attribution and change notices are required
    • Whether there are limits on concurrency or user scale for a single deployment

    If these terms are not clarified first, later engineering investment may face rework.

    2.2 VRAM Estimation: Calculate Before Buying GPUs

    Inference VRAM consists of three main parts: weights, KV cache, and framework or activation overhead. Weights are a fixed cost. KV cache grows linearly with sequence length multiplied by concurrency, and in real load testing it is often the true bottleneck.

    1. def estimate_vram_gb(params_b, dtype_bytes=2, layers=80,
    2. kv_heads=8, head_dim=128,
    3. max_len=8192, concurrency=64):
    4. """Rough estimate of inference VRAM requirements (GB, using 1024-based units)."""
    5. weights = params_b * dtype_bytes # weight size
    6. kv_per_token = 2 * layers * kv_heads * head_dim * dtype_bytes # K and V tensors
    7. kv_total = kv_per_token * max_len * concurrency / (1024 ** 3)
    8. reserve = weights * 0.2 + 2.0 # activations, framework overhead, fragmentation reserve
    9. return {
    10. "weights": round(weights, 1),
    11. "kv_cache": round(kv_total, 1),
    12. "reserve": round(reserve, 1),
    13. "total": round(weights + kv_total + reserve, 1),
    14. }
    15. # 70B parameters, FP16, 8K context, 64 concurrent requests
    16. print(estimate_vram_gb(70))
    17. # {'weights': 140.0, 'kv_cache': 160.0, 'reserve': 30.0, 'total': 330.0}

    These numbers reveal a commonly underestimated fact: under long-context conditions, KV cache can exceed the model weights themselves. If the context window is reduced from 8K to 2K and concurrency is reduced from 64 to 16, KV cache can drop to around 10 GB. Therefore, the first priority in capacity planning is often not to buy larger GPUs, but to tighten context windows and concurrency limits.

    Inference frameworks that support grouped-query attention, KV cache quantization, and paged memory management can significantly reduce this overhead. These capabilities should be compared carefully during framework selection.

    2.3 Quantization Strategy Trade-offs

    • Weight quantization, such as INT8 or INT4: This mainly reduces weight memory usage. It usually provides near-linear gains in throughput and VRAM savings, but may introduce some accuracy loss. Quantization should be validated on your own evaluation sets.
    • KV cache quantization: This mainly reduces peak VRAM usage and provides the most direct benefit for long-context scenarios.
    • Activation quantization and sparsification: Benefits are less stable and depend heavily on hardware generation. These are best treated as supplementary options after load testing.

    A practical approach is to first establish an FP16 baseline for accuracy and latency, then enable quantization options one by one and run regression evaluations. Avoid stacking multiple quantization strategies at once. Otherwise, accuracy regressions are difficult to attribute.

    2.4 Inference Mode: Online Interaction or Offline Batch Processing

    Online interaction focuses on time to first token and single-request responsiveness. Offline batch processing focuses on cost per token. The scheduling strategies for these two modes are opposite:

    • Online interaction requires headroom and smaller batch sizes to protect latency.
    • Offline batch processing should fill batches as much as possible to reduce cost.

    With the same weights and the same hardware, the optimal configuration can differ significantly between these two goals. The primary objective should be clarified before deployment.

    3. Key Engineering Components of an Inference Service

    Continuous Batching and Memory Management

    Static batching must wait for the slowest request to finish before releasing a slot. As a result, GPU utilization is often below 30%. Continuous batching allows requests to enter and leave batches dynamically at token granularity. When combined with paged KV cache management, it reduces VRAM fragmentation and is now a major source of inference throughput. During selection, confirm whether the serving framework natively supports these two capabilities.

    Parallelism and Multi-GPU Sharding

    When weights do not fit on a single GPU, or when lower per-token latency is required, two types of parallelism can be used:

    • Tensor parallelism: This splits computation inside a single layer. Communication between GPUs is frequent, so it is suitable for single-node environments with high-speed interconnects. It can reduce latency.
    • Pipeline parallelism: This splits computation across layers. Communication volume is lower, but pipeline bubbles are introduced. It is often more cost-effective across machines.

    A common production pattern is tensor parallelism within a single node combined with pipeline parallelism across nodes. More parallelism is not always better. If inter-GPU interconnect bandwidth is insufficient, communication overhead can consume the compute gains.

    Service API Layer

    It is recommended to expose an HTTP API consistent with mainstream conventions, covering common fields such as messages, max_tokens, temperature, top_p, and stream. The main benefit is that existing application code can usually switch backends with minimal changes:

    1. payload = {
    2. "model": "local-model",
    3. "messages": [{"role": "user", "content": prompt}],
    4. "max_tokens": 512,
    5. "temperature": 0.7,
    6. "top_p": 0.9,
    7. "stream": True,
    8. }
    9. # Stream the response to receive incremental tokens. Rendering can start after the first token, which significantly improves perceived responsiveness.

    The API layer should also handle:

    • Authentication and tenant quotas
    • Request timeouts and idempotent retries
    • Context length validation, rejecting oversized requests instead of silently truncating them
    • Sensitive content filtering and audit logs

    4. Performance Tuning: Focus on Four Metrics

    Metric Meaning Optimization direction
    TTFT: time to first token Queueing plus prefill time Reduce input length, improve batching efficiency, avoid mixing long and short requests
    TPOT: time per output token Per-token latency during decoding Improve VRAM bandwidth utilization and control concurrency limits
    Throughput in tokens/s Total output per unit time Increase batch size and enable continuous batching
    Peak VRAM Hard capacity constraint Control context and concurrency, and apply KV cache quantization

    The tuning loop should be:

    1. Build a reproducible baseline with a fixed prompt set and fixed concurrency.
    2. Change one variable at a time.
    3. Rerun the same script.
    4. Compare the four metrics above and output consistency.

    Without a reproducible baseline, any conclusion that “it became faster after tuning” is unreliable.

    5. From Single-Node Validation to Enterprise Deployment

    Once validation succeeds on a single GPU, scaling out requires additional engineering support:

    • Elasticity and gateway: Use multiple replicas with a unified gateway for routing, canary releases, and rate limiting. Deploy long requests and short requests in separate pools to avoid mutual interference in latency.
    • Storage and distribution: Weight files are often hundreds of GB. Store them in object storage with versioning and pre-warmed replicas to avoid startup storms caused by simultaneous pulls during node scaling.
    • Observability: Collect GPU utilization, VRAM usage, batch size distribution, queue wait time, and the four latency metrics. Connect these to monitoring and alerting, and define threshold-based alert rules.
    • Cost attribution: Track token consumption and resource usage by tenant or business line. Otherwise, a self-built cluster can easily become an unexplained expense within six months.

    These capabilities often correspond to generic cloud categories such as container platforms, elastic compute, object storage, and monitoring and alerting. Cloud providers such as Baidu AI Cloud may provide them as generic capabilities. Specific choices should be evaluated based on your scale and compliance requirements.

    6. Fine-Tuning or RAG: A Decision Order

    A common mistake after obtaining weights is to immediately fine-tune the model when results are unsatisfactory. It is better to follow an order of increasing cost:

    1. Prompting and output constraints: Most formatting and style issues can be solved at this layer.
    2. Retrieval-augmented generation, or RAG: Missing knowledge, insufficient timeliness, or the need for citation tracing are retrieval problems, not parameter problems.
    3. Fine-tuning: Only consider fine-tuning when the task format is stable, sufficient samples are available, and the first two layers have reached their practical ceiling.

    The cost of fine-tuning is not limited to training. It also includes evaluation set construction, version management, rollback mechanisms, and revalidation. This workload is often seriously underestimated.

    7. Common Pitfalls

    • Estimating VRAM only from parameter count while ignoring KV cache, leading to immediate OOM after launch
    • Moving directly from FP16 to quantization without accuracy regression testing
    • Lacking a reproducible load-testing baseline, so tuning is based on intuition
    • Mixing long requests and short requests in the same replica pool, causing uncontrolled P99 latency
    • Ignoring license terms and discovering restrictions only during commercialization
    • Lacking content moderation and access auditing, making security responsibility impossible to trace

    Summary: Open weights turn large models from a service into an asset. They expand the capability boundary, but they do not remove the core engineering challenges: VRAM estimation, batching and scheduling, quantization regression, observability, and cost control. The more open the weights become, the more responsibility shifts to the deploying organization. The most reliable path is to calculate capacity accurately, stabilize the baseline, and only then move to tuning and scaling.