LLM Deployment Guide: Performance, Cost, and Parameter Selection

    This article examines open-source LLM deployment choices across parameter size, GPU memory estimation, lightweighting methods, and Kubernetes-based inference service setup, with practical guidance on balancing latency, concurrency, cost, and SLA validation.

    Over the past year, open-source large language models have followed two development paths. One pursues larger parameter scales to explore the upper limits of general capability. The other focuses on engineering deployment, using structural optimization and inference acceleration to let models run reliably in more business scenarios. For developers and enterprises, the core question is which specification is most suitable under given latency, concurrency, and budget constraints.

    1. Choosing Parameter Size: Business Constraints First, Model Capability Second

    Flagship models stand out on high-difficulty tasks such as complex reasoning, mathematical derivation, and competition-level code generation. The tradeoff is high compute and GPU memory consumption and relatively high per-request latency. They usually require multi-node clusters and are not suitable for directly handling high-concurrency user-facing traffic.

    Medium-sized models have smaller parameter scales and a lower deployment barrier. In routine Agent evaluations and simple tool-calling tasks, the output quality gap between the two is limited. For most scenarios such as intelligent customer service, document summarization, and code completion, medium-sized models are usually sufficient.

    For specific specifications, refer to the model card published by the model provider. When comparing models, look at both total parameter count and activated parameter count. A MoE structure activates only part of its experts each time, so inference compute and GPU memory footprint use different calculation bases; the same formula cannot be directly applied.

    Selection recommendation: first run both specifications against your own business evaluation set, and record accuracy, P95 latency, and per-request cost. Choose a specification only after all three meet the SLA. Do not decide based only on leaderboard rankings.

    2. Estimating GPU Memory: A Verifiable Calculation Method

    Many deployment failures come from insufficient GPU memory estimation. Estimate in three parts:

    1. Weight memory: parameter count multiplied by bytes per parameter. FP16 uses 2 bytes, INT8 uses 1 byte, and INT4 uses about 0.5 bytes.
    2. KV Cache memory: related to concurrency, context length, number of layers, and hidden dimension. In long-context and high-concurrency scenarios, it may exceed the weights themselves.
    3. Activation and runtime overhead: includes the inference framework and CUDA context, among other things. Reserve 10% to 20% headroom.

    Suppose a 280B-parameter model. Weights alone require about 280 GB under INT8 and about 140 GB under INT4, without counting KV Cache. Therefore, even INT4-quantized weights may not fit on a single GPU; calculate based on GPU count and tensor parallelism.

    3. Lightweighting Techniques: What Is General and What Depends on Official Releases

    Common methods include structural pruning, parameter sharing, knowledge distillation, and quantization. Their effective boundaries differ:

    • Official distilled or pruned versions have already been trained and evaluated and can be used directly. Their effectiveness is subject to official evaluation data.
    • Directly pruning an arbitrary existing model may damage its representations. Retraining and evaluation are usually required to confirm that quality has not dropped significantly.
    • Quantization can reduce GPU memory usage, but low-bit precision may affect math and code tasks. Before launch, compare FP16, INT8, and INT4 results on your own evaluation set.

    Paged attention techniques such as PagedAttention manage KV Cache in blocks to reduce memory fragmentation and improve concurrency. They depend on the implementation of the inference engine. Confirm whether the engine in use supports them, enable them in the configuration, and then validate the effect.

    4. Deployment Practice: Launching an Inference Service with Kubernetes

    Using a mainstream cloud provider’s container service and object storage as an example—this article does not constitute a product recommendation—the recommended approach is as follows:

    • Use images with fixed version numbers and avoid the latest tag, which can cause environment drift.
    • Bake CUDA, cuDNN, and Python dependencies into the image to ensure consistency across environments.
    • Store model weights in object storage and mount them into containers through a PVC, avoiding re-downloading on every startup.
    • Configure a readiness probe so the service receives traffic only after weights have finished loading.

    Below is an illustrative manifest. It cannot be used directly in production; replace the image address, node labels, PVC name, and probe path before use.

    1. apiVersion: apps/v1
    2. kind: Deployment
    3. metadata:
    4. name: llm-inference
    5. labels:
    6. app: llm-inference
    7. spec:
    8. replicas: 2
    9. selector:
    10. matchLabels:
    11. app: llm-inference
    12. template:
    13. metadata:
    14. labels:
    15. app: llm-inference
    16. spec:
    17. nodeSelector:
    18. gpu-type: a100-80g # Adjust based on actual node labels in the cluster
    19. containers:
    20. - name: llm-engine
    21. image: registry.example.com/llm-inference:v1.0.0 # Use a fixed version, not latest
    22. ports:
    23. - containerPort: 8000
    24. env:
    25. - name: MODEL_PATH
    26. value: "/models"
    27. - name: QUANT_MODE
    28. value: "int8"
    29. - name: MAX_BATCH_SIZE
    30. value: "32"
    31. resources:
    32. requests:
    33. cpu: "8"
    34. memory: "64Gi"
    35. nvidia.com/gpu: 4
    36. limits:
    37. nvidia.com/gpu: 4
    38. readinessProbe:
    39. httpGet:
    40. path: /health
    41. port: 8000
    42. initialDelaySeconds: 120 # Adjust based on measured weight loading time
    43. periodSeconds: 10
    44. volumeMounts:
    45. - name: model-volume
    46. mountPath: /models
    47. readOnly: true
    48. volumes:
    49. - name: model-volume
    50. persistentVolumeClaim:
    51. claimName: llm-model-pvc
    52. ---
    53. apiVersion: v1
    54. kind: Service
    55. metadata:
    56. name: llm-inference
    57. spec:
    58. selector:
    59. app: llm-inference
    60. ports:
    61. - port: 80
    62. targetPort: 8000
    63. type: ClusterIP

    Deployment and validation steps:

    1. Confirm that the PVC llm-model-pvc is bound and that weight files exist under /models.
    2. Run kubectl apply -f llm-inference.yaml.
    3. Run kubectl get pods -l app=llm-inference and wait until READY shows 1/1.
    4. Run kubectl get svc llm-inference to confirm that the Service has been created.
    5. Run kubectl port-forward svc/llm-inference 8080:80, then use curl to request the health check endpoint and a test sample.
    6. If the Pod is not ready for a long time, run kubectl logs to check weight loading logs and adjust initialDelaySeconds based on the measured loading time.

    Startup time depends on scheduling speed.