LLM Weight Deployment: Planning, Serving Architecture, and Inference Optimization

    This article explains how responsibilities shift when teams move from API calls to self-hosted LLM weights, covering hardware and memory planning, license review, file integrity, and data privacy. It then describes a layered inference service architecture and discusses quantization, batching, KV cache management, and parallel strategies for deployment.

    1. From API Calls to Weight Deployment: What Changes in Responsibility

    In the past, most teams used large models by calling remote APIs. Model training, inference optimization, and version upgrades were handled by the service provider. Users only needed to focus on request format, cost, and rate limits.

    Once model weights are opened up, users receive the model parameter files themselves. The following responsibilities then shift to the user:

    • Hardware selection and capacity planning: determining whether the model can fit into VRAM and whether throughput can cover peak business load.
    • Inference environment: including driver versions, operator libraries, and parallel strategies.
    • Security and compliance: including file integrity, license constraints, data retention, and access control.
    • Ongoing operations: including version rollback, performance regression testing, and failure alerts.

    The main benefits of self-hosted inference are that data remains within your environment, customization is possible as needed, and long-term serving costs can be controlled. The cost is a clear increase in engineering complexity and operational responsibility. Teams should first assess whether they have these capabilities before deciding how much to invest.

    2. Four Pre-Deployment Assessments

    2.1 VRAM and Memory Estimation

    The VRAM used by model weights can be estimated with the following formula:

    Weight VRAM (GB) ≈ Number of parameters (billions) × Bytes per parameter

    Under common precisions, the bytes per parameter are as follows: FP16 and BF16 use 2 bytes, INT8 uses 1 byte, and INT4 uses 0.5 bytes. For a 70B-parameter model, FP16 requires about 140 GB of VRAM for weights alone; after INT4 quantization, it requires about 35 GB.

    Actual usage also includes KV cache, activations, and runtime overhead. These parts grow with the maximum context length and the number of concurrent requests. Reserve space should be determined through measurement, not based only on weight size.

    2.2 License Review

    Open weights do not automatically mean arbitrary commercial use. Before launch, check the license text item by item for commercial scope, redistribution conditions, attribution requirements, and usage restrictions, and confirm whether there are constraints on user scale or industry. Legal and technical teams should confirm the conclusion together and record it in the model registry for later audits.

    2.3 File Integrity and Safe Loading

    Weight files downloaded from public channels should have their hashes verified and compared one by one with the digest published by the publisher. When loading, prefer serialization formats that contain only tensor data and avoid formats that deserialize executable objects, to reduce the risk of arbitrary code execution.

    2.4 Data and Privacy Boundaries

    Self-hosted deployment must clarify the following questions: whether logs record user input, whether prompts and model outputs need redaction, whether cache directories have access control configured, and whether log retention periods comply with internal rules. These rules should be written into deployment documentation and checked during code review.

    3. Layered Architecture for Inference Services

    A maintainable inference service is usually divided into five layers:

    1. Storage layer: Use object storage to save weight files and a version manifest; the manifest records the hash of each file.
    2. Loading layer: Read weights at startup and complete device mapping, precision settings, and tensor sharding.
    3. Inference layer: The inference engine performs forward computation and handles batch scheduling and KV cache management.
    4. Access layer: Provide a unified HTTP interface and handle authentication, rate limiting, and request length validation.
    5. Observability layer: Collect latency, throughput, VRAM usage, and error codes, and connect them to monitoring and alerts.

    The benefit of layering is that each layer can be independently replaced and scaled. As concurrency grows, only the number of inference layer instances needs to increase; the access and storage layers do not need to change.

    The schematic structure is as follows:

    1. Client -> Access layer (auth, rate limiting) -> Inference layer (multiple instances) <- Loading layer <- Storage layer (weights, hash manifest)
    2. |
    3. Observability layer (metrics, logs, alerts)

    4. Quantization and Inference Performance Optimization

    4.1 Quantization Tradeoffs

    Quantization reduces VRAM usage and memory bandwidth pressure by lowering numerical precision. Lower precision means a smaller footprint, but output quality may degrade. When choosing a quantization scheme, compare results at different precisions on your own evaluation set, focusing on metrics such as accuracy, output format compliance rate, and abnormal refusal rate; do not rely only on experience.

    4.2 Batching and Caching

    Online services usually merge multiple requests into one batch to improve hardware utilization. The longer the batch wait time, the larger the batch and the higher the throughput, but the time to first token for an individual request also increases. Teams need to set the wait window according to business latency requirements.

    KV cache stores attention intermediate results that have already been computed. Total cache capacity directly limits the total context length that can be served concurrently. Determine the maximum concurrency through stress testing and design queuing or rejection policies for requests that exceed capacity.

    4.3 Parallel Strategies

    When a single accelerator cannot hold the model, tensor parallelism or pipeline parallelism is required.