Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

LLM Quantization Deployment: GPTQ vs AWQ vs GGUF Format Selection & Performance Comparison

LLM Quantization Deployment: GPTQ vs AWQ vs GGUF Format Selection & Performance Comparison

This comprehensive guide compares GPTQ, AWQ, and GGUF quantization formats for LLM deployment, covering core principles, production inference topologies, hardware baselines, performance benchmarks, vLLM and llama.cpp configurations, Kubernetes deployment, observability, troubleshooting, and emerging FP8/NVFP4 pathways on Hopper/Blackwell GPUs.

1. Core Principles and Bottlenecks: Why LLM Inference Is Memory-Bandwidth Bound

LLM autoregressive inference splits into Prefill (parallel prompt processing, compute-bound) and Decode (sequential token generation). In Decode, each new token requires moving the entire model weights (tens of GB) from GPU HBM to SRAM, making it Memory-Bandwidth Bound .

For a 32B parameter model, BF16 weights occupy ~64 GB. On a single 80 GB GPU with 2 TB/s bandwidth, theoretical weight-transfer limit is ~31 tokens/s, leaving almost no VRAM for high-concurrency KV Cache.

Quantizing 16-bit weights to 4-bit (W4A16) reduces VRAM and bandwidth needs to 1/4. Three quantization formats take different approaches:

GPTQ (Second-order Hessian error compensation) : Column-wise quantization using approximate Hessian inverse, compensating quantization error to subsequent columns in real time, relying on a calibration dataset to minimize layer-output reconstruction error.

AWQ (Activation-Aware Weight Quantization) : Only ~1% of salient weight channels (corresponding to largest activation magnitudes) determine most accuracy. AWQ scales salient channels before 4-bit uniform quantization. Inference uses Marlin/GEMM fused dequantization kernels with near-zero overhead.

GGUF (llama.cpp universal binary container + K-Quants block quantization) : Designed for heterogeneous compute. Single file embeds model architecture, tokenizer, and tensor metadata. Uses Q4_K_M (important layers 6-bit, rest 4-bit mixed super-block quantization) enabling layer-wise offload between CPU AVX-512/AMX and GPU, plus mmap zero-copy loading.

2026 Toolchain Critical Update : Early community AutoGPTQ and AutoAWQ projects archived/deprecated since 2025. Production quantization pipelines should now use vLLM's official llm-compressor (v0.15.0) (or GPTQModel ) to generate standardized compressed-tensors / quantized weights, served by vLLM v0.33.0 (GPU high-concurrency) or llama.cpp (CPU/heterogeneous).

2. Production Inference Topology and Hardware Baseline

Enterprises typically adopt a hybrid topology: vLLM production cluster for high concurrency, llama.cpp edge/heterogeneous nodes for low-resource scenarios.

+-------------------------------------------------------------------------+
| Unified Gateway & Routing (TLS termination + Token rate limiting)          |
| [Clients / Agent] ---> [Nginx / Envoy Gateway: 10.30.0.10:443]              |
+------------------------------------+------------------------------------+
|
+--------------------------+--------------------------+
| (High-concurrency online: W4A16 AWQ/GPTQ)              | (Edge/Dev/CPU hybrid: GGUF)      |
v                                                      v
+---------------------------------------+          +-----------------------------------+
| Primary: vLLM v0.33.0 inference nodes |          | Fallback: llama.cpp heterogeneous |
| [vllm-node-01: 10.30.1.11:8000]       |          | [llamacpp-01: 10.30.1.21:8080]    |
| - 2x L40S (48GBx2) / 1x A100 (80GB)   |          | - 1x RTX 4090 (24GB) + 128GB RAM|
| - PagedAttention + Continuous Batch   |          | - -ngl 48 (partial layer offload) |
| - Marlin W4A16 fused dequant kernel   |          | - Q4_K_M mixed-precision block    |
+---------------------------------------+          +-----------------------------------+
|                                                      |
+--------------------------+--------------------------+
v
[Prometheus / vmagent: 10.30.2.10:8429]
(scrape /metrics: TTFT, TPOT, KV Cache utilization)

3. Multi-Dimensional Selection Decision Matrix (Hardware, Throughput, Cloud Cost)

Benchmark baseline: 32B model (e.g., Qwen3-32B / DeepSeek equivalent), 32K context, daily production concurrency 16-32.

Decision Matrix

Static Weight VRAM : BF16 ~64 GB; AWQ ~18.5 GB; GPTQ ~18.5 GB; GGUF ~19.8 GB (splittable to system RAM)

Recommended Engine : BF16 vLLM v0.33.0; AWQ vLLM v0.33.0 (primary); GPTQ vLLM v0.33.0; GGUF llama.cpp (llama-server)

Min GPU Hardware : BF16 2× A100 80GB (or 4× L40S); AWQ 1× L40S 48GB (25GB left for KV); GPTQ 1× L40S 48GB; GGUF 1× RTX 4090 24GB or pure 64C CPU

High-Concurrency Throughput (32 concurrent) : BF16 very high (no dequant overhead); AWQ very high (Marlin kernel 2-3x speedup); GPTQ high (slightly slower than AWQ, calibration-limited); GGUF low (lacks PagedAttention continuous batching)

Single-Request Low-Concurrency Latency : BF16 slower (64GB transfer bottleneck); AWQ fast; GPTQ fast; GGUF very fast (single-user C++ minimal framework overhead)

Calibration Time & Complexity : BF16 no quantization needed; AWQ medium (~15 min, no backprop); GPTQ higher (requires Hessian inverse); GGUF low ( llama-quantize few minutes direct)

Accuracy Retention (vs BF16) : BF16 100% baseline; AWQ 98.5% ~ 99.5% (more stable on outliers); GPTQ 97.5% ~ 99.0% (depends on calibration quality); GGUF 97.0% ~ 98.8% ( Q4_K_M performs well)

Monthly Cloud GPU Cost Reference : BF16 2× A100-80G ~ $3,600/mo; AWQ 1× L40S-48G ~ $1,150/mo; GPTQ 1× L40S-48G ~ $1,150/mo; GGUF no-GPU high-spec CPU ~ $380/mo

One-Line Selection Decision Rules

Online multi-concurrent API service (prefer AWQ via llm-compressor + vLLM) : On single 48GB/80GB GPU, AWQ + Marlin kernel offers best combined accuracy retention and concurrent throughput with full OpenAI-compatible API.

Existing GPTQ model assets or extreme VRAM pressure : Reuse HuggingFace GPTQ weights or quantize with llm-compressor using group_size=128; vLLM also supports Marlin acceleration.

Insufficient VRAM / edge local / pure CPU (choose GGUF + llama.cpp ) : Only 16GB/24GB VRAM but need to run 32B/70B models, or single-developer/internal low-concurrency tooling. Strictly forbidden to use single-instance Ollama or default non-batching config for 20+ high-concurrency production services.

H100/H200/B200/B300 next-gen hardware : Prefer native FP8 (W8A8) or NVFP4 ; no need for W4A16.

4. Primary Solution End-to-End Config & Deployment ( llm-compressor + vLLM v0.33.0)

4.1 Hardware & VRAM Baseline Pre-Check

Verify GPU model, driver, CUDA version (vLLM v0.33.0 official image defaults to CUDA 13.0), PCIe/NVLink topology, and calculate VRAM safety margin.

# Check GPU model, VRAM, driver version, and interconnect topology
nvidia-smi --query-gpu=index,name,memory.total,driver_version,pcie.link.gen.current  --format=csv && nvidia-smi topo -m

Typical interpretation output:

index, name, memory.total [MiB], driver_version, pcie.link.gen.current 0, NVIDIA L40S, 46068 MiB, 580.65.06, 4      <-- Key: total VRAM 45GB, PCIe Gen4    GPU0    CPU Affinity    NUMA Affinity GPU0      X      0-63            0  # Multi-GPU: if SYS cross-NUMA appears instead of NV# (NVLink), Tensor Parallel cross-GPU latency increases significantly

VRAM Capacity Formula (must calculate before production launch) :

$$ ext{Required VRAM(GB)} \approx rac{ ext{Params(B)} imes ext{Bitwidth(bit)}}{8} imes 1.15 + ext{Concurrent Sequences} imes ext{Avg Context Length} imes ext{Per-Token KV Bytes}$$

Example: 32B-AWQ (4-bit) + L40S (45GB): weights + activation buffer ~ 32 * 0.5 * 1.15 ≈ 18.4 GB, leaving ~ 23 GB for PagedAttention KV Cache (~200K+ total concurrent tokens).

4.2 Production-Grade AWQ / GPTQ Quantization with llm-compressor

Since AutoAWQ and AutoGPTQ are deprecated, use vLLM's official llm-compressor (v0.15.0) for calibration, outputting compressed-tensors -compatible high-quality weight directory.

Quantization script /opt/llm/quantize_awq.py:

import os from datasets import load_dataset from transformers import AutoModelForCausalLM, AutoTokenizer from llmcompressor import oneshot from llmcompressor.modifiers.awq import AWQModifier  MODEL_ID = os.environ.get("BASE_MODEL_DIR", "/data/models/Qwen3-32B") SAVE_DIR = os.environ.get("QUANT_SAVE_DIR", "/data/models/Qwen3-32B-AWQ") CALIB_SAMPLES = 256 MAX_SEQ_LEN = 2048  # 1. Load original BF16 model and tokenizer model = AutoModelForCausalLM.from_pretrained(     MODEL_ID,     torch_dtype="auto",     device_map="auto", ) tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)  # 2. Prepare calibration dataset (must match real business corpus, e.g., mixed Chinese/English instructions/code, avoid single English Wiki bias) ds = load_dataset("json", data_files="/data/calib/biz_calib_256.jsonl", split="train") ds = ds.select(range(min(CALIB_SAMPLES, len(ds))))  def tokenize_fn(sample):     return tokenizer(         sample["text"],         padding=False,         max_length=MAX_SEQ_LEN,         truncation=True,     )  ds = ds.map(tokenize_fn, remove_columns=ds.column_names)  # 3. Configure AWQ W4A16 quantization recipe (skip output layer lm_head to prevent accuracy collapse) recipe = [     AWQModifier(         ignore=["lm_head"],         scheme="W4A16",         targets=["Linear"],     ) ]  # 4. Execute one-shot calibration quantization and save model.save_pretrained(SAVE_DIR, save_compressed=True) tokenizer.save_pretrained(SAVE_DIR)

For GPTQ W4A16 (since llm-compressor v0.14.0+ includes Triton accelerated quantization kernels, ~15x speedup), replace AWQModifier with

GPTQModifier(targets="Linear", scheme="W4A16", ignore=["lm_head"])

.

4.3 vLLM v0.33.0 Production Service Config and Four-Dimensional Breakdown

Manage API Key via controlled env file /etc/vllm/vllm.env (permissions 0600), never hardcode keys in Docker Compose or systemd command line.

sudo install -o root -g root -m 0600 /dev/null /etc/vllm/vllm.env

Create /etc/systemd/system/vllm-server.service (or equivalent Docker/K8s manifest):

[Unit] Description=vLLM Inference Server (v0.33.0 AWQ Production) After=network-online.target  [Service] Type=simple EnvironmentFile=/etc/vllm/vllm.env ExecStart=/usr/bin/docker run --rm --name vllm-qwen3-32b 
   --gpus '"device=0"' 
   --ipc=host 
   --ulimit memlock=-1 
   -p 10.30.1.11:8000:8000 
   -v /data/models:/models:ro 
   -e VLLM_API_KEY=${VLLM_API_KEY} 
   vllm/vllm-openai:v0.33.0 
   --model /models/Qwen3-32B-AWQ 
   --served-model-name qwen3-32b 
   --quantization compressed-tensors 
   --dtype float16 
   --gpu-memory-utilization 0.90 
   --max-model-len 32768 
   --max-num-seqs 64 
   --max-num-batched-tokens 8192 
   --enable-prefix-caching 
   --disable-log-requests ExecStop=/usr/bin/docker stop -t 30 vllm-qwen3-32b Restart=always RestartSec=10s  [Install] WantedBy=multi-user.target

Effective method : After modifying launch parameters, must execute

sudo systemctl daemon-reload && sudo systemctl restart vllm-server

(Restart required, inference engine must reallocate VRAM pool and recompile CUDA Graph).

Four-dimensional breakdown :

4.4 High-Frequency Ops Commands and Real-Time Metrics Interpretation

# 1. Real-time monitor GPU memory bandwidth utilization (mem%) and compute core utilization (sm%) nvidia-smi dmon -s mu -d 2 -c 5
# gpu  fb  bar1  ccpm  sm  mem  enc  dec  jpg  ofa # Idx  MB   MB    MB    %   %    %    %    %    %     0 41520   24     0   38  89    0    0    0    0  <-- Key: sm=38% but mem=89%, typical memory-bandwidth saturated     0 41520   24     0   41  91    0    0    0    0
# 2. One-liner to fetch vLLM core health metrics: KV Cache usage, queue count, preemption count curl -sS http://10.30.1.11:8000/metrics | grep -E '^vllm:(kv_cache_usage_perc|num_requests_)' | grep -E 'kv_cache_usage_perc|running|waiting|preemptions'
vllm:kv_cache_usage_perc{...} 0.4215   <-- KV Cache usage 42.15% (> 0.85 needs scaling attention) vllm:num_requests_running{...} 18       <-- Current concurrent batch processing count vllm:num_requests_waiting{...} 0        <-- Queued requests 0, service healthy vllm:num_preemptions_total{...} 0        <-- Key: > 0 indicates VRAM full causing request eviction and recompute!

5. Before vs After Tuning Closed Loop: Eliminating KV Cache Preemption and Throughput Collapse

Scenario : After deploying 32B-AWQ service, 32 concurrent requests frequently showed tail latency spikes to 12 seconds, GPU compute utilization fluctuated wildly.

Before tuning (abnormal config and live output) : Original config mistakenly used --quantization awq (not using Marlin fused kernel) and --gpu-memory-utilization 0.75, --max-model-len 65536, without Prefix Caching.

# Pre-tuning load test and metrics capture curl -sS http://10.30.1.11:8000/metrics | grep -E '^vllm:(kv_cache_usage_perc|num_preemptions_total)' | head -n 10
vllm:kv_cache_usage_perc{...} 0.9841   <-- Key: KV Cache long at 98% extreme redline! vllm:num_preemptions_total{...} 147      <-- 147 KV preemption evictions occurred, massive compute wasted on re-prefill!

vLLM console logs showed massive warnings:

WARNING 11-13 01:15:22 engine.py:412] Sequence group req_8912 is preempted by PreemptionMode.RECOMPUTE mode because there is not enough KV cache space.

Optimization actions :

Switch --quantization to awq_marlin (or compressed-tensors auto-routes Marlin) and lock --dtype float16.

Raise --gpu-memory-utilization from 0.75 to 0.90 (releases extra 6.9GB VRAM for KV Cache).

Converge --max-model-len to actual business Prompt upper bound 32768, and enable --enable-prefix-caching.

After tuning (normal verification output and load test comparison) :

# Use vllm bench serve for 32 concurrent fixed input/output load test comparison vllm bench serve 
  --backend openai 
  --base-url http://10.30.1.11:8000 
  --model qwen3-32b 
  --dataset-name random 
  --random-input-len 1024 
  --random-output-len 256 
  --max-concurrency 32 
  --num-prompts 128
============ Serving Benchmark Result ============ Successful requests:           128 Benchmark duration (s):        19.42 Total input tokens:            131072 Total generated tokens:        32768 Output token throughput (tok/s): 1687.33   <-- Key: before only 610 tok/s, improved 2.76x! Mean TTFT (ms):              184.20   <-- before Mean TTFT reached 1420ms P99 TTFT (ms):               412.50 Mean TPOT (ms):              18.10   <-- per-token generation stable at 18ms (~55 tok/s/user)

Re-check /metrics confirm vllm:num_preemptions_total stays 0, kv_cache_usage_perc stable at 0.54 safe zone.

6. Alternative Solution Core Config and Pitfalls (llama.cpp GGUF Heterogeneous Deployment)

When production or edge environment has only single 24GB GPU (e.g., RTX 4090) or pure high-spec CPU server, must use GGUF + llama.cpp heterogeneous layer offload.

6.1 Model Conversion and Q4_K_M Quantization Commands

# 1. Convert HuggingFace BF16 model to F16 GGUF intermediate format python3 /opt/llama.cpp/convert_hf_to_gguf.py 
  /data/models/Qwen3-32B 
  --outfile /data/models/gguf/Qwen3-32B-f16.gguf 
  --outtype f16  # 2. Execute Q4_K_M mixed-precision block quantization (balance size and accuracy) /opt/llama.cpp/build/bin/llama-quantize 
  /data/models/gguf/Qwen3-32B-f16.gguf 
  /data/models/gguf/Qwen3-32B-Q4_K_M.gguf 
  Q4_K_M 16

6.2 llama-server Heterogeneous Launch Config and Four-Dimensional Breakdown

Assume node equipped with 1x RTX 4090 (24GB) + 128GB DDR5, 32B model has 64 layers, place first 48 layers in GPU VRAM (~16GB), remaining 16 layers in CPU memory:

/opt/llama.cpp/build/bin/llama-server 
  --model /data/models/gguf/Qwen3-32B-Q4_K_M.gguf 
  --alias qwen3-32b-gguf 
  --host 10.30.1.21 
  --port 8080 
  --n-gpu-layers 48 
  --ctx-size 32768 
  --parallel 4 
  --threads 16 
  --flash-attn 
  --cache-type-k q8_0 
  --cache-type-v q8_0 
  --metrics

Four-dimensional breakdown (GGUF-specific pitfalls) :

7. Measured Performance Metrics Comparison (32B Model Baseline)

Under unified 1024 input / 256 output test set, AWQ, GPTQ, and GGUF measured performance:

Measured Metrics

Hardware Environment : AWQ 1× L40S (48GB); GPTQ 1× L40S (48GB); GGUF 1× L40S (48GB); GGUF 1× RTX 4090 (24GB) + CPU

Single-concurrency generation speed (TPOT) : AWQ 78 tok/s; GPTQ 74 tok/s; GGUF full GPU 84 tok/s; GGUF hybrid 21 tok/s (limited by PCIe/memory bandwidth)

32 concurrent total throughput : AWQ 1,687 tok/s; GPTQ 1,540 tok/s; GGUF full GPU 490 tok/s (limited by static slots); GGUF hybrid 82 tok/s

32 concurrent P99 TTFT : AWQ 412 ms; GPTQ 465 ms; GGUF full GPU 2,840 ms; GGUF hybrid >6,500 ms

MMLU / Code benchmark accuracy retention : AWQ 99.1%; GPTQ 98.4%; GGUF full GPU 98.6%; GGUF hybrid 98.6%

8. Automated VRAM Budget Calculation and Service Pre-Check Script (Supports --dry-run )

Before releasing new quantized model, run following one-click pre-check script to auto-validate VRAM budget, quantization format fields, and API liveness (API Key read from controlled 0600 file):

#!/usr/bin/env bash set -euo pipefail  # Usage: ./llm_deploy_precheck.sh <model_billions> <bits> <vllm_url> [--dry-run] if [[ $# -lt 3 ]]; then echo "Usage: $0 <model_billions> <bits> <vllm_url> [--dry-run]" >&2 exit 1 fi  PARAMS_B="${1}" BITS="${2}" VLLM_URL="${3}" DRY_RUN="${4:-}" ENV_FILE="/etc/vllm/vllm.env"  if [[ -f "${ENV_FILE}" ]]; then set -a && source "${ENV_FILE}" && set +a fi  log_info() { printf '[INFO] %s %s
' "$(date '+%F %T')" "$*"; } log_warn() { printf '[WARN] %s %s
' "$(date '+%F %T')" "$*" >&2; }  calc_vram_budget() { local est_gb est_gb="$(awk -v p="${PARAMS_B}" -v b="${BITS}" 'BEGIN {printf "%.1f", p * (b / 8.0) * 1.15}')" log_info "Model static weight+buffer estimated VRAM: ${est_gb} GB (${PARAMS_B}B @ ${BITS}-bit)" }  check_gpu_free() { if [[ "${DRY_RUN}" == "--dry-run" ]]; then log_info "[DRY-RUN] Will call nvidia-smi to verify free VRAM and vLLM /health endpoint" return 0 fi if ! command -v nvidia-smi >/dev/null 2>&1; then log_warn "nvidia-smi not detected, skipping local GPU VRAM check" else nvidia-smi --query-gpu=index,name,memory.free --format=csv,noheader | while IFS= read -r line; do log_info "Current GPU free VRAM: ${line}" done fi }  check_vllm_api() { if [[ "${DRY_RUN}" == "--dry-run" ]]; then log_info "[DRY-RUN] Will probe ${VLLM_URL}/health and /v1/models" return 0 fi curl -fsS -m 5 "${VLLM_URL}/health" >/dev/null log_info "vLLM health endpoint OK (${VLLM_URL}/health)"  local models_json models_json="$(curl -fsS -m 5 -H "Authorization: Bearer ${VLLM_API_KEY:-}" "${VLLM_URL}/v1/models")" local model_ids model_ids="$(printf '%s' "${models_json}" | jq -r '.data[].id' | tr '
' ' ')" log_info "Mounted model list: ${model_ids}" }  main() { calc_vram_budget check_gpu_free check_vllm_api }  main

9. Selection Red Lines and Production Change Risk Matrix

Change Risk Matrix

Switch quantization format (BF16 -> AWQ) : Impact model output distribution and TTFT. Pre-check: must compare perplexity (PPL) and JSON format compliance on business test set. Execution window: canary 10% traffic for 24h, confirm no hallucination before full rollout. Rollback: gateway weight switch back to original BF16 upstream node.

Adjust gpu-memory-utilization : Requires vllm-server restart, ~30s interruption. Pre-check: confirm no other training/monitoring processes on same GPU. Execution window: business low-peak; rolling restart per node. Rollback: restore original .service params and systemctl restart vllm-server.

Change model storage PVC in K8s : High risk: accidental PVC deletion loses tens of GB weights . Pre-check: confirm HuggingFace/object storage backup intact. Execution window: strictly forbid direct kubectl -n llm delete pvc; scale down Replica first. Rollback: re-pull model weights from internal MinIO/S3 artifact repo.

Upgrade vLLM image version : Risk of operator kernel or quantization config compatibility changes. Pre-check: verify target image loads existing compressed-tensors directory without errors on test GPU. Execution window: canary single node upgrade and run vllm bench serve. Rollback: revert image tag to previous stable version and restart container.

Four Immutable Quantization Selection Red Lines

Forbid new projects continuing to depend on AutoAWQ / AutoGPTQ for model quantization : Upstream archived, new architecture models (e.g., Qwen3/DeepSeek new variants) directly error incompatible, unified migration to llm-compressor.

Forbid quantizing Chinese/code core models with pure English Wiki calibration set without business calibration data : GPTQ and AWQ calibration distribution shift causes cliff-drop in specific long-tail capabilities (e.g., SQL generation, strict JSON output).

Forbid blindly applying W4A16 instead of native FP8 on Hopper/Blackwell GPUs (H100/H200/B300) : When single GPU VRAM sufficient, FP8 W8A8 has native Tensor Core hardware instruction acceleration, Prefill and Decode comprehensive energy efficiency significantly better than software dequantized W4A16.

Forbid using GGUF Q2_K / IQ2_XS 2-bit extreme compression for production QA and code generation : 4-bit ( Q4_K_M / W4A16) is engineering usable sweet spot floor; below 3-bit logical reasoning hallucination rate cannot meet online SLA.

10. Kubernetes GPU Cluster Production Deployment (vLLM v0.33.0)

In enterprise multi-node multi-GPU K8s clusters, deploying quantized LLMs must solve three engineering problems: Shared Memory ( /dev/shm ) insufficiency , Multi-GPU NCCL communication topology , and Model weight persistent mounting .

10.1 vLLM Deployment and Service Production Manifest ( namespace: llm )

apiVersion: apps/v1 kind: Deployment metadata: name: vllm-qwen3-32b-awq namespace: llm spec: replicas: 2 strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 0 maxSurge: 1 selector: matchLabels: app: vllm-qwen3-32b-awq template: metadata: labels: app: vllm-qwen3-32b-awq spec: containers: - name: vllm image: vllm/vllm-openai:v0.33.0 args: - "--model=/models/Qwen3-32B-AWQ" - "--served-model-name=qwen3-32b" - "--quantization=compressed-tensors" - "--dtype=float16" - "--tensor-parallel-size=2" - "--gpu-memory-utilization=0.90" - "--max-model-len=32768" - "--enable-prefix-caching" - "--port=8000" env: - name: VLLM_API_KEY valueFrom: secretKeyRef: name: vllm-api-secret key: api-key - name: NCCL_DEBUG value: "WARN" ports: - name: http containerPort: 8000 resources: requests: cpu: "8" memory: "48Gi" nvidia.com/gpu: "2" limits: cpu: "16" memory: "64Gi" nvidia.com/gpu: "2" readinessProbe: httpGet: path: /health port: 8000 initialDelaySeconds: 60 periodSeconds: 10 livenessProbe: httpGet: path: /health port: 8000 initialDelaySeconds: 120 periodSeconds: 20 volumeMounts: - name: model-storage mountPath: /models readOnly: true - name: dshm mountPath: /dev/shm volumes: - name: model-storage persistentVolumeClaim: claimName: llm-models-pvc - name: dshm emptyDir: medium: Memory sizeLimit: 16Gi

Four-dimensional breakdown (K8s GPU deployment special) :

10.2 Common K8s GPU Pod Troubleshooting Commands

# 1. View llm namespace Pod scheduling and ready status kubectl -n llm get pods -o wide -l app=vllm-qwen3-32b-awq
# 2. Troubleshoot Pod Pending or CrashLoopBackOff root cause kubectl -n llm describe pod -l app=vllm-qwen3-32b-awq | grep -A 12 'Events:'
Events:   Type     Reason            Age   From               Message   ----     ------            ----  ----               -------   Warning  FailedScheduling  42s   default-scheduler  0/4 nodes are available: 4 Insufficient nvidia.com/gpu.  <-- Key: GPU resource insufficient

11. LLM Inference Observability System (Prometheus + Grafana Core Metrics)

After quantized model goes live, cannot only watch host CPU and GPU VRAM usage; must tightly monitor TTFT (Time To First Token) , TPOT (Time Per Output Token) , and KV Cache pressure .

11.1 Production Essential PromQL Cheatsheet

# 1. First token latency (TTFT) P99 (unit: seconds) histogram_quantile( 0.99, sum(rate(vllm:time_to_first_token_seconds_bucket[5m])) by (le, model_name) )  # 2. Per-token generation latency (TPOT) P95 (unit: milliseconds) histogram_quantile( 0.95, sum(rate(vllm:time_per_output_token_seconds_bucket[5m])) by (le, model_name) ) * 1000  # 3. Prefix Cache hit rate (higher means better system prompt reuse) sum(rate(vllm:prefix_cache_hits_total[5m])) / sum(rate(vllm:prefix_cache_queries_total[5m])) * 100  # 4. Real-time output token throughput (tok/s) sum(rate(vllm:generation_tokens_total[1m])) by (model_name)

11.2 Inference Service Alert Rules ( vllm_slo_alerts.yml )

groups: - name: llm_inference_slo interval: 15s rules: - alert: VLLMKVCacheSaturated expr: vllm:kv_cache_usage_perc > 0.85 for: 3m labels: severity: warning annotations: summary: "vLLM {{ $labels.model_name }} KV Cache usage exceeds 85%" - alert: VLLMPreemptionOccurring expr: increase(vllm:num_preemptions_total[5m]) > 0 for: 1m labels: severity: critical annotations: summary: "vLLM {{ $labels.model_name }} KV Cache preemption occurring, need rate limiting or scale out" - alert: VLLMTTFTP99High expr: |   histogram_quantile(     0.99,     sum(rate(vllm:time_to_first_token_seconds_bucket[5m])) by (le, model_name)   ) > 2.0 for: 3m labels: severity: warning annotations: summary: "vLLM {{ $labels.model_name }} P99 TTFT exceeds 2 seconds"

12. Troubleshooting Closed Loops (Multi-GPU NCCL Deadlock & Quantized Output Repetition)

12.1 Loop 1: Multi-GPU Tensor Parallel PCIe P2P Communication Timeout Deadlock

1. Symptom : On dual-GPU consumer or non-NVLink PCIe servers enabling --tensor-parallel-size 2 to start vLLM, process hangs at Loading model weights stage, then throws NCCL timeout error.

2. Before adjustment (abnormal log output) :

[rank0]: Watchdog caught collective operation timeout: WorkNCCL(SeqNum=1, OpType=ALLREDUCE) ran for 180000 milliseconds before timing out. [rank0]: torch.distributed.DistBackendError: NCCL error in: /pytorch/torch/csrc/distributed/c10d/NCCLUtils.cpp:272, unhandled system error

3. Root cause : Some dual-GPU server motherboards have BIOS enabled IOMMU / ACS (Access Control Services) or hardware lacks PCIe P2P direct connect support, causing NCCL default P2P memory access attempt to be silently dropped by hardware.

4. Fix : Explicitly disable problematic NIC/PCIe P2P and InfiniBand probing in environment variables (fallback to shared memory/PCIe Host forwarding), and restart service:

# Append following config in container or systemd environment variables export NCCL_P2P_DISABLE=1 export NCCL_IB_DISABLE=1

5. After adjustment (normal startup verification output) :

INFO 11-13 01:28:11 model_runner.py:1042] Loading model weights took 9.2145 GB (per rank) INFO 11-13 01:28:24 worker.py:241] Memory profiling takes 11.42 seconds INFO 11-13 01:28:39 model_runner.py:1318] Graph capturing finished in 14 secs, took 0.48 GiB INFO:      Application startup complete.  <-- Key: dual-GPU initialization and ready within 30 seconds

6. Rollback : If mistakenly added NCCL_P2P_DISABLE=1 on A100/H100 nodes with full NVLink, lose 30%+ cross-GPU bandwidth, must immediately remove env var and restart to restore NVLink P2P.

12.2 Loop 2: Quantized Model Outputs Malformed JSON or Infinite Repetition in Long Conversations

1. Symptom : 32B model quantized to 4-bit via GPTQ deployed; short QA normal, but when input exceeds 8K context or requires complex JSON Schema output, model tail starts infinite repetition of same sentence (Repetition Loop).

2. On-site reproduction and comparison detection :

# Use curl to send 8K context JSON structured request to verify reproduction curl -sS -m 30 http://10.30.1.11:8000/v1/chat/completions 
  -H "Content-Type: application/json" 
  -H "Authorization: Bearer ${VLLM_API_KEY}" 
  -d '{
  "model": "qwen3-32b",
  "temperature": 0.0,
  "max_tokens": 512,
  "messages": [{"role": "user", "content": "Please output strictly JSON with 20 config items..."}]
}' | jq -r '.choices[0].message.content' | tail -n 5
"status": "active",  "status": "active",  "status": "active",   <-- Key: fell into greedy decoding dead loop repetition

3. Root cause :

On one hand, original GPTQ quantization used only 64 short English samples as calibration set, causing long-sequence Chinese/JSON activation distribution distortion.

On the other hand, business side set temperature=0.0 without repetition_penalty, 4-bit quantization introduced tiny logit jitter amplified into dead loop under greedy decoding.

4. Fix :

Switch to AWQ ( llm-compressor AWQModifier ) and recalibrate quantization using 256 samples of length 2048 real business mixed Chinese/English+JSON samples.

Set default inference request params repetition_penalty: 1.05 and temperature: 0.1 (or enable vLLM structured output --guided-decoding-backend xgrammar to enforce JSON syntax tree).

5. Verification : Retest 100 8K context structured tasks, JSON validity rate recovered from 86% to 99.5%, repetition phenomenon eliminated.

13. Frontier Supplement: FP8 and NVFP4 Route Comparison on Hopper/Blackwell Architectures

If your production cluster already uses NVIDIA H100 / H200 / B200 / B300 new-gen GPUs, quantization selection logic shifts from "W4A16 saves VRAM" to Native low-precision Tensor Core compute acceleration :

Quantization Scheme Comparison

AWQ / GPTQ (W4A16) : Ampere / Ada (A10/L40S/4090); 4-bit weight / 16-bit activation; VRAM compression 4x, alleviates Decode memory bottleneck; enable via --quantization compressed-tensors.

FP8 (W8A8) : Hopper / Ada (H100/H200/L40S); 8-bit weight / 8-bit activation; Prefill + Decode full-stage hardware acceleration , near-lossless accuracy; enable via FP8Modifier + --quantization fp8.

NVFP4 / MXFP4 : Blackwell (B200/B300); 4-bit float weight / microscaling; balances 4-bit extreme VRAM with Blackwell native FP4 compute; llm-compressor v0.15.0 native support.

On vLLM v0.33.0 (default CUDA 13.0), enabling dynamic FP8 KV Cache further frees 50% context VRAM:

# On FP8-capable GPUs, further quantize KV Cache to fp8_e4m3, doubling concurrent context capacity docker run --rm --gpus '"device=0"' -p 10.30.1.11:8000:8000 
  -v /data/models:/models:ro 
  vllm/vllm-openai:v0.33.0 
  --model /models/Qwen3-32B-FP8 
  --kv-cache-dtype fp8_e4m3 
  --calculate-kv-scales 
  --max-model-len 65536

14. SGLang vs vLLM Quantized Inference Engine Comparison and Structured Output Practice

In 2026 GPU inference production, besides vLLM, SGLang is also important choice for deploying quantized models (AWQ/GPTQ/FP8), especially excelling in multi-turn Agent, Tree-of-Thought, and strongly constrained JSON structured output scenarios.

14.1 SGLang Core Launch Config and Four-Dimensional Breakdown

SGLang reduces first-token latency in multi-turn tool calls significantly via RadixAttention (radix-tree based automatic prefix KV Cache reuse) and zero-overhead jump-constrained decoding (Compressed FSM).

# SGLang production launch command (load llm-compressor produced AWQ model) python3 -m sglang.launch_server 
  --model-path /data/models/Qwen3-32B-AWQ 
  --served-model-name qwen3-32b 
  --host 10.30.1.12 
  --port 30000 
  --tp 2 
  --quantization awq_marlin 
  --dtype float16 
  --mem-fraction-static 0.88 
  --context-length 32768 
  --schedule-policy lpm 
  --api-key "${SGLANG_API_KEY}"

Effective method : Modify launch params requires service process restart ( Restart ).

Four-dimensional breakdown :

14.2 Load Test and Structured Output Verification Comparison

# Verify SGLang OpenAI compatible interface and check cache hit rate metrics curl -sS http://10.30.1.12:30000/metrics | grep -E '^sglang:(cache_hit_rate|num_running_reqs|gen_throughput)'
sglang:cache_hit_rate{model="qwen3-32b"} 0.7842   <-- Key: 78.4% prefix hit, multi-turn Agent scenario excellent sglang:num_running_reqs{model="qwen3-32b"} 24 sglang:gen_throughput{model="qwen3-32b"} 1824.5   <-- Current generation throughput (tok/s)

15. Cross-Machine Distributed Inference and Quantization Accuracy Regression Evaluation SOP

When model scale reaches 70B / 405B level (even W4A16 quantized still needs 40GB~230GB weight space), single-machine 4/8 GPU VRAM insufficient, need Ray + vLLM to build cross-machine Tensor Parallel / Pipeline Parallel cluster.

15.1 Ray Cross-Machine Cluster Launch and vLLM Distributed Deployment

On head node ( 10.30.1.11) and worker node ( 10.30.1.12) start Ray daemons (pre-confirm 10GbE/RoCE network connectivity):

# 1. Start Ray control plane on Head node (10.30.1.11) ray start --head 
  --node-ip-address=10.30.1.11 
  --port=6379 
  --num-gpus=4  # 2. Worker node (10.30.1.12) joins cluster ray start --address='10.30.1.11:6379' 
  --node-ip-address=10.30.1.12 
  --num-gpus=4

Confirm all 8 GPUs online, then launch cross-machine distributed inference service on Head node:

ray status && 
vllm serve /models/DeepSeek-R1-70B-AWQ 
  --served-model-name deepseek-70b 
  --distributed-executor-backend ray 
  --tensor-parallel-size 4 
  --pipeline-parallel-size 2 
  --quantization compressed-tensors 
  --dtype float16 
  --gpu-memory-utilization 0.90 
  --max-model-len 32768 
  --port 8000
Cross-machine topology iron law : Intra-machine NVLink GPUs run --tensor-parallel-size (high-frequency AllReduce communication), cross-machine NICs preferentially run --pipeline-parallel-size (only layer-to-layer point-to-point activation transfer, far less sensitive to cross-machine bandwidth).

15.2 Quantization Pre-Production Automated Accuracy Regression Evaluation ( lm-eval )

Any quantized model before entering production canary must compare quantized (BF16) vs quantized (AWQ/GPTQ/GGUF) on core benchmarks, ensuring score degradation controlled within 1.5% :

# Use lm_eval to run automated regression test on quantized online OpenAI API MODEL_ARGS="model=qwen3-32b,base_url=http://10.30.1.11:8000/v1/completions" MODEL_ARGS="${MODEL_ARGS},num_concurrent=16" lm_eval --model local-completions 
  --model_args "${MODEL_ARGS}" 
  --tasks ceval-valid,gsm8k 
  --limit 200 
  --batch_size auto

Typical regression acceptance comparison output:

| Tasks     |Version|Filter|n-shot| Metric     |BF16_Base|AWQ_W4A16|Delta  | |-----------|-------|------|------|-----------|---------|---------|------| |ceval-valid|      1|none  |     5|acc       | 0.8450  | 0.8380  |-0.70%|  <-- Drop < 1.5%, acceptance passed |gsm8k      |      3|exact |     5|exact_match| 0.9100  | 0.9010  |-0.90%|

Confirm drop meets SLA, then at Nginx gateway layer introduce live traffic at weight=10 (10% canary) for 24h observation, confirm no abnormal repetition and P99 timeout before full switch.

16. Nginx Streaming Gateway Canary Config and KV Cache Capacity Quick Calculator

Quantized model pre/post launch streaming output (SSE) experience often bottlenecked at L7 gateway buffering and timeout config.

16.1 Nginx Streaming Inference Gateway Production Config ( /etc/nginx/conf.d/llm_gateway.conf )

upstream llm_qwen3_pool { # 90% traffic to existing stable BF16 node, 10% canary to new quantized AWQ node server 10.30.1.10:8000 weight=90 max_fails=2 fail_timeout=10s; server 10.30.1.11:8000 weight=10 max_fails=2 fail_timeout=10s; keepalive 128; }  server { listen 443 ssl http2; server_name llm-api.internal.example.com;  ssl_certificate   /etc/nginx/ssl/llm.crt; ssl_certificate_key /etc/nginx/ssl/llm.key;  location /v1/ { proxy_pass http://llm_qwen3_pool; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Host $host;  # Critical streaming SSE config: disable response buffering, prevent first token being batched by Nginx proxy_buffering off; proxy_cache off; chunked_transfer_encoding on;  # Long-thinking reasoning models (e.g., R1/QwQ) need enlarged read timeout proxy_connect_timeout 5s; proxy_read_timeout 300s; proxy_send_timeout 60s; } }

Effective method : Execute sudo nginx -t && sudo systemctl reload nginx ( Reload , smooth traffic switch without interrupting existing streaming connections).

Four-dimensional breakdown :

16.2 Daily Troubleshooting and VRAM Quick Calc One-Liners

# 1. One-liner estimate 32B model (64 layers, 8 KV heads, head_dim=128, FP16) 32K context single-concurrency KV usage awk 'BEGIN { layers=64; kv_heads=8; head_dim=128; bytes=2; ctx=32768; gb = (2 * layers * kv_heads * head_dim * bytes * ctx) / (1024^3); printf "Single 32K context KV Cache VRAM usage: %.2f GB
", gb }'
Single 32K context KV Cache VRAM usage: 4.00 GB  <-- Key: GQA model each 32K request uses 4GB, 23GB KV pool max concurrently holds ~5-6 full 32K requests
# 2. Real-time check host GPU ECC hardware errors and PCIe throttling anomalies nvidia-smi -q -d ECC,PERFORMANCE | grep -E 'Aggregate|Volatile|Clocks Throttle|SW Thermal|HW Slowdown'
Volatile ECC                          : N/A     Aggregate ECC                         : N/A     Clocks Throttle Reasons       Idle                              : Not Active       SW Thermal Slowdown             : Not Active  <-- If becomes Active, indicates datacenter cooling insufficient causing GPU throttling, TPOT doubles       HW Slowdown                       : Not Active
# 3. Check llama-server process actual physical memory (RSS) and VRAM mapping ps -eo pid,comm,rss:10,vsz:12 --sort=-rss | grep -E 'PID|llama-server|vllm'

17. Quantized Base with Multi-LoRA Hot-Loading Hybrid Deployment Practice

In enterprise multi-business-line scenarios, often don't need separate 32B VRAM instance per fine-tuning task, but adopt "1 AWQ quantized base + N lightweight LoRA adapters dynamic hot-loading" .

17.1 vLLM v0.33.0 Multi-LoRA Production Launch Params

vllm serve /models/Qwen3-32B-AWQ 
  --served-model-name qwen3-32b-base 
  --quantization compressed-tensors 
  --dtype float16 
  --gpu-memory-utilization 0.90 
  --enable-lora 
  --max-loras 8 
  --max-lora-rank 64 
  --max-cpu-loras 16 
  --lora-modules 
    sql-agent=/models/loras/qwen3-sql-r32 
    k8s-ops=/models/loras/qwen3-k8s-r64

Effective method : Mount initial LoRA at startup, runtime can use VLLM_ALLOW_RUNTIME_LORA_UPDATING=True with /v1/load_lora_adapter API to hot-register new LoRA ( Reload no base restart needed).

Four-dimensional breakdown :

17.2 Multi-LoRA Routing Call and Verification Output

curl -sS http://10.30.1.11:8000/v1/chat/completions 
  -H "Content-Type: application/json" 
  -H "Authorization: Bearer ${VLLM_API_KEY}" 
  -d '{
  "model": "k8s-ops",
  "max_tokens": 128,
  "messages": [{"role": "user", "content": "What is the first command to troubleshoot Pod CrashLoopBackOff?"}]
}' | jq -r '.model, .usage.total_tokens'
k8s-ops 94

17.3 Quantized Inference Pre-Launch Five-Point Final Checklist

Format and kernel alignment : Confirm vLLM loading AWQ/GPTQ logs show using Marlin kernel not slow generic dequant fallback.

VRAM headroom reservation : --gpu-memory-utilization and --max-model-len load tested with vllm:num_preemptions_total staying 0.

Gateway streaming passthrough : Nginx/Envoy disabled proxy_buffering and relaxed proxy_read_timeout to 300s.

Credential and permission isolation : All API Keys injected via 0600 env file or K8s Secret, no unauthenticated port exposure.

Accuracy regression acceptance : lm-eval core business suite drop < 1.5%, and 8K long text no repetition dead loop.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

Report an issue with this article

Reader feedback

Was this useful?

Useful0

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion