Private Deployment of Chinese Multimodal Models: Model Selection, GPU Memory, and Scaling

    A practical guide to deploying Chinese-developed multimodal models on premises or in a private cloud. Learn how to estimate weight and KV cache memory, translate request rates into concurrency, validate inference engine stability, and configure autoscaling and monitoring for production workloads. All sizing figures are estimates that should be verified against your model version and load tests.

    Deploying a multimodal large language model in an enterprise data center or private cloud usually involves three stages: validating capabilities on a small hardware footprint, choosing the model size and numerical precision, and preparing for stable operation under concurrent load. Each stage requires different evidence.

    This guide covers model selection and compute planning, memory and concurrency sizing, inference engine stability, and microservice scaling and monitoring. It includes reusable calculations, reference tables, and a configuration example. Numerical estimates reflect typical configurations; use your own model version and load-test results for final capacity planning.

    1. Three Checks Before Deployment

    Review the license

    Some open-model licenses allow commercial use but impose additional conditions on user scale, redistribution, or specific applications. Complete legal review before purchasing hardware.

    Verify model files

    Record the SHA256 hashes of downloaded weight files and compare them with the values supplied by the publisher. This helps detect files that have been replaced during transfer.

    Build a compatibility matrix

    Document the accelerator driver, runtime library, operating system kernel, and inference framework versions. Check each combination against the relevant release notes.

    Treat combinations outside the matrix as unvalidated environments, not production-ready configurations.

    2. Model Selection and Compute Planning

    Parameter count determines weight memory requirements, while numerical precision determines the bytes required per parameter:

    • FP16 or BF16: 2 bytes per parameter.
    • INT8: 1 byte per parameter.
    • INT4: approximately 0.5 bytes per parameter.

    Quantized files also contain scaling factors, so actual INT4 storage is somewhat higher than the theoretical minimum.

    The following estimates cover weights only. They exclude KV cache and runtime overhead.

    Model size FP16/BF16 INT8 INT4
    4B About 8 GB About 4 GB About 2.5 GB
    9B About 18 GB About 9 GB About 5.5 GB
    14B About 28 GB About 14 GB About 8 GB
    70B About 140 GB About 70 GB About 40 GB

    Validate quantization quality

    INT8 weight quantization generally causes relatively small quality losses on many general-purpose tasks. INT4 can have a more noticeable effect on reasoning and long-context tasks.

    Before deployment, compare the quantized model with the original model on your organization’s evaluation set. Business stakeholders should define acceptable quality degradation and record it in the model-selection document.

    Choose a fine-tuning method

    The appropriate fine-tuning method depends on the available data and the objective.

    LoRA typically trains only 0.1%–1% of model parameters. It is suitable for output formatting, style adaptation, and instruction-following tasks. A few hundred to a few thousand high-quality examples can provide a starting point.

    Injecting knowledge requires more data and attention to preserving the model’s general capabilities.

    P-Tuning v2 trains fewer parameters. Its performance ceiling on complex tasks is typically lower than LoRA’s, making it more suitable for simpler tasks or memory-constrained environments.

    A practical sequence is to validate the application with a quantized model first, collect real requests, and then consider LoRA fine-tuning.

    During validation, a single inference server equipped with Chinese-made accelerator cards can support testing for knowledge-base question answering, document understanding, and OCR post-processing. Recalculate hardware requirements as request volume changes.

    3. Memory and Concurrency Planning

    3.1 Memory Components

    Approximate device memory requirements are:

    1. Total memory ≈ model weights + KV cache + runtime overhead

    For the KV cache, bytes per token can be calculated as:

    1. KV cache bytes per token =
    2. 2 × number of layers × number of KV heads × head dimension × bytes per element

    The factor of 2 accounts for the key and value caches. Read the layer count, KV head count, and head dimension from the model configuration rather than reusing values from another model.

    For a model with 32 layers, 8 KV heads, a head dimension of 128, and FP16 cache elements:

    1. 2 × 32 × 8 × 128 × 2 = 131,072 bytes

    That is approximately 128 KB per token.

    At a context length of 4,096 tokens, the KV cache requires approximately 512 MB per request. Sixteen requests generating concurrently require approximately 8 GB.

    Runtime overhead includes inference engine memory pools, activations, and fragmentation. Reserve approximately 10%–20% of total device memory as headroom.

    3.2 Estimate Concurrency from QPS

    Little’s Law provides an estimate of requests in flight:

    1. Requests in flight = QPS × average request duration

    At a peak rate of 5 queries per second and an average request duration of 8 seconds, approximately 40 requests will be in flight.

    Production capacity should include headroom. Plan for roughly 1.2–1.5 times peak demand, and use load testing to verify how much concurrency a single instance can safely support.

    3.3 Inference Framework Parameters

    For vLLM-style frameworks, the following settings deserve particular attention. Other accelerator-specific frameworks may use different names for similar controls.

    • max_model_len: Maximum context length per request. Increasing it raises the potential KV cache requirement per request, so size it together with concurrency.
    • gpu_memory_utilization: Fraction of device memory available to the inference engine. A value of 0.9 is common; reducing it to 0.85 may help when out-of-memory errors occur frequently.
    • max_num_seqs: Maximum number of concurrent sequences in a batch. This is a key control for balancing memory use and throughput.
    • Continuous batching: Admits new requests as soon as existing requests finish, improving throughput.
    • Chunked prefill: Splits the prefill computation for long prompts into chunks to reduce fluctuations in other requests’ time to first token.

    3.4 Load-Test Metrics and Procedure

    Metric Meaning Reporting method
    TTFT Time to first token P50, P95, and P99
    TPOT Average time per output token Bucketed by output length
    Throughput Output tokens per second and completed requests per second Average over a steady-state window
    Error rate Share of requests with timeouts, OOM errors, or HTTP 5xx responses Per-minute aggregation
    Peak device memory Maximum device memory consumption Sampled throughout the test

    Use the following procedure:

    1. Build a test set that reflects real request distributions, including both short questions and long documents.
    2. Start at low concurrency and increase the load in stages. Run each stage steadily for at least 10 minutes and record all metrics.
    3. Identify the point where P95 TTFT exceeds the target or the error rate begins to rise. Set safe per-instance concurrency to approximately 70%–80% of that level.

    3.5 Troubleshoot Out-of-Memory Errors

    1. Check the product of max_model_len and max_num_seqs to assess whether the theoretical maximum KV cache requirement exceeds available memory.
    2. Enforce a max_tokens limit at the gateway to prevent unusually long outputs from exhausting memory.
    3. Reduce gpu_memory_utilization or max_num_seqs and observe whether OOM errors stop.
    4. Check for memory consumption that grows steadily over time. If memory does not fall after requests finish, investigate a possible leak using the stability checks below.

    4. Inference Engine Stability

    The inference framework connects accelerator hardware to application services. Validate its stability separately from model quality and peak throughput.

    Run a sustained-load test

    Operate at 70%–80% of rated concurrency for at least 72 hours. Track process resident set size (RSS) and device memory over time.

    Memory that remains elevated after the load is removed, or that grows linearly over long periods, warrants investigation for a possible leak.

    Measure latency variability

    Calculate the ratio of P99 latency to P50 latency. A persistently high ratio often points to batching scheduler or memory allocation issues. Use framework logs to investigate.

    Configure health checks carefully

    A readiness probe should succeed only after the model has finished loading.

    A liveness probe should check whether the process responds.

    Model loading can take several minutes. Allow sufficient initial delay and timeout settings; otherwise, the container may enter a repeated restart cycle.

    Add circuit breaking and graceful degradation

    The following thresholds are starting points. Adjust them to business tolerance.

    Condition Action
    Error rate exceeds 5% over a one-minute window Open the circuit breaker; fail new requests quickly or route them to a backup model
    P95 latency exceeds twice the SLA target for two minutes Apply rate limiting to reduce incoming concurrency per instance
    Circuit breaker has been open for 30 seconds Admit a small number of probe requests; close the circuit if normal operation resumes

    5. Microservice Design and Autoscaling

    Decouple the inference layer from the gateway and business logic.

    The gateway should handle authentication, rate limiting, and request parameter limits. The inference service should focus on computation. Scaling then requires replicating inference instances without changing the business services.

    Prepare Metrics for HPA

    The Kubernetes Horizontal Pod Autoscaler requires appropriate metrics:

    • The default HPA resource metrics cover CPU and memory, which are insufficient for GPU inference services.
    • For GPU-utilization-based scaling in supported environments, deploy DCGM exporter to collect metrics and expose them as custom metrics through Prometheus Adapter.
    • Queue depth or requests in flight are generally better scaling signals. With batching, GPU utilization can stay close to 100% even while the queue continues to grow, making utilization a poor indicator of additional load.
    • For event-driven scaling, KEDA can integrate with Prometheus.

    Example: Scale by Queued Requests

    The following configuration scales on the average number of queued requests per pod. Replace the metric name with the one actually exposed by Prometheus Adapter.

    1. apiVersion: autoscaling/v2
    2. kind: HorizontalPodAutoscaler
    3. metadata:
    4. name: llm-infer-hpa
    5. spec:
    6. scaleTargetRef:
    7. apiVersion: apps/v1
    8. kind: Deployment
    9. name: llm-infer
    10. minReplicas: 2
    11. maxReplicas: 8
    12. metrics:
    13. - type: Pods
    14. pods:
    15. metric:
    16. name: requests_waiting
    17. target:
    18. type: AverageValue
    19. averageValue: "4"
    20. behavior:
    21. scaleUp:
    22. stabilizationWindowSeconds: 30
    23. scaleDown:
    24. stabilizationWindowSeconds: 300

    Account for Scaling Delays

    Two sources of delay matter.

    First, a new instance may need several minutes to load the model and become ready. Set scaling thresholds early enough to account for that delay.

    Second, the cluster must have available accelerator resources. If no cards are free, pod scaling must be coordinated with node autoscaling.

    Set minReplicas high enough to cover normal peak demand to avoid most cold starts. A scale-down stabilization window of approximately five minutes helps prevent repeated starts and stops caused by short-term traffic fluctuations.

    6. Monitoring, Alerting, and Platform Selection

    Monitoring should cover three areas: hardware, inference services, and business requests.

    Priority Example metrics or conditions Example alert threshold
    P1 Service unavailability and error rate Error rate above 5% for five minutes
    P2 Device memory headroom and queued requests Device memory utilization above 90% for 10 minutes
    P3 GPU utilization and cost Utilization below 20% for one hour

    When selecting platform services such as object storage, logging, load balancing, and container orchestration, compare compatibility with the chosen software and accelerator stack, any applicable certification requirements, billing models, and cost predictability.