LLM Deployment Cheat Sheet

Production LLM deployment — vLLM, TGI, Ray Serve, quantization (AWQ, GPTQ, GGUF), latency optimization, scaling strategies, and serving infrastructure for large l.

Last Updated: May 1, 2025

Serving Frameworks

FrameworkKey FeatureBest ForThroughput
vLLMPagedAttention — near-zero memory wasteHigh-throughput APIs, OpenAI-compatibleBest for concurrent users
Text Generation Inference (TGI)Hugging Face's solution, watermarks, grammarHuggingFace ecosystem usersGood, with optimizations
Ray ServeDistributed serving + model compositionMulti-model pipelines, complex routingScales horizontally
TensorRT-LLMNVIDIA-optimized, best GPU utilizationNVIDIA GPU-only, max performanceHighest single-node perf
OllamaSimple local deployment, GGUF modelsDevelopment, local testingLow (single user)
Llama.cppCPU inference, GGUF quantizationEdge devices, CPU-only serversLow, but runs anywhere
SGLangStructured generation + radix attentionStructured outputs, JSON modesExcellent for structured
BentoMLGeneral model serving frameworkTeams serving multiple model typesGood, with batching

vLLM Quick Start

pip install vllm
Install vLLM — requires CUDA-compatible GPU
vllm serve meta-llama/Llama-2-7b-chat-hf
Serve a model with default settings — auto-detects best config
vllm serve model --tensor-parallel-size 2
Split model across 2 GPUs for large models (70B+)
vllm serve model --max-model-len 8192
Set max context length — longer = more GPU memory
vllm serve model --gpu-memory-utilization 0.90
Use 90% of GPU memory for KV cache — higher = more concurrent requests
vllm serve model --max-num-seqs 256
Max concurrent sequences — balance throughput vs latency
vllm serve model --quantization awq
Load AWQ quantized model — ~4x less memory, near-identical quality
OpenAI-compatible API on port 8000
vLLM exposes /v1/chat/completions — drop-in replacement for OpenAI SDK

Quantization Guide

MethodPrecisionMemory vs FP16Quality ImpactLoad Time
FP16 (baseline)16-bit100% (~14GB for 7B)ReferenceFast
INT88-bit~50%<0.5% degradationFast
GPTQ4-bit~25%1-2% degradationSlow (calibration needed)
AWQ4-bit~25%<1% degradationFast (auto-calibrated)
GGUF (Q4_K_M)4-bit~25%1-3% degradationFast (pre-quantized)
GGUF (Q5_K_M)5-bit~31%<1% degradationFast (pre-quantized)
GGUF (Q8_0)8-bit~50%NegligibleFast (pre-quantized)
NF4 (QLoRA)4-bit + double quant~20%2-4% degradationFast (bnb config)

Latency Optimization

ItemDescription
Continuous BatchingDon't wait for full batch — process each token as it's generated. vLLM and TGI do this automatically
KV Cache ManagementPagedAttention (vLLM) ensures efficient GPU memory use — no fragmentation, higher concurrency
Speculative DecodingUse small draft model to predict tokens → large model verifies in parallel — 2-3x speedup
Prompt KV Cache ReuseCache system prompt KV states — only compute user prompt tokens. vLLM's automatic prefix caching
Quantization4-bit models run on cheaper GPUs (T4 instead of A100) or fit more concurrent users on same hardware
Flash Attention 2Memory-efficient attention — 2-4x faster than standard attention. Supported by vLLM, TGI, and most frameworks
StreamingReturn tokens as they're generated (TTFT optimization) — users see first token in 100-500ms vs 5-30s
Request PrioritizationAssign priority to requests — interactive users get low latency, batch jobs get throughput
GPU SelectionA100 (best), H100 (2x A100), A10G (budget), L4 (inference-optimized budget), L40S (mid-range sweet spot)
Load BalancingRound-robin across multiple model replicas with session affinity for multi-turn conversations
Pro Tip: Quantization is the single biggest lever for production LLM deployment. Going from FP16 to 4-bit (AWQ/GPTQ) typically gives 3-4x throughput improvement with <1% accuracy loss for most models.