Why vLLM?
High Throughput
2-3x faster than standard inference with continuous batching
Memory Efficient
PagedAttention reduces memory waste by up to 80%
Easy Integration
Compatible with HuggingFace models and OpenAI API format
Multi-GPU Support
Built-in tensor parallelism for distributed inference
Installation
1
Install vLLM
2
Verify Installation
3
Using Docker (Recommended)
vLLM requires CUDA 11.4 or higher and a GPU with compute capability 7.0 or higher.
GPU Requirements
Memory Requirements by Model Size
Supported Consumer GPUs
Quick Start
Standalone OpenAI API Server
Deploy an OpenAI-compatible API server with vLLM:Chat Template Configuration
Download and use the ChatML template for proper formatting:The chat template file is required for proper message formatting with the Qwen models.
Python Wrapper
Use the vLLM wrapper for Transformers-like interface:1
Download the Wrapper
2
Use in Python
Wrapper Configuration
API Usage
Using OpenAI Python Client
Advanced Configuration
Performance Tuning
Configuration Parameters
string
required
Model name or path (HuggingFace format)
int
default:"1"
Number of GPUs for tensor parallelism
string
default:"auto"
Data type:
auto, bfloat16, float16, float32int
Maximum sequence length (prompt + generation)
float
default:"0.90"
Fraction of GPU memory to use (0.0 to 1.0)
int
default:"256"
Maximum number of sequences processed in parallel
int
Maximum tokens processed in a batch
int
default:"4"
CPU swap space size in GB
boolean
Disable request logging for reduced overhead
Multi-GPU Deployment
Tensor Parallelism
Distribute model layers across multiple GPUs:GPU Selection
Control which GPUs to use:Production Deployment
Systemd Service
Create/etc/systemd/system/qwen-vllm.service:
Docker Deployment
Load Balancing
Nginx configuration for multiple vLLM instances:Performance Benchmarks
Throughput Comparison
Qwen-7B on A100 80GB GPU:Memory Efficiency
Qwen-72B memory usage:Limitations
Troubleshooting
CUDA Out of Memory
CUDA Out of Memory
Error:
torch.cuda.OutOfMemoryErrorSolutions:- Reduce
--gpu-memory-utilization(try 0.85 or 0.80) - Decrease
--max-model-len - Use quantized Int4 model
- Increase
--tensor-parallel-size
Model fails to load
Model fails to load
Error:
ValueError: trust_remote_code is requiredSolution: Always include --trust-remote-code:Infinite generation
Infinite generation
Issue: Model generates indefinitelySolution: Set proper stop tokens:
Low throughput
Low throughput
Issue: Not achieving expected performanceSolutions:
- Increase
--max-num-seqsfor more concurrent requests - Use
--dtype bfloat16instead of float16/float32 - Disable request logging with
--disable-log-requests - Check GPU utilization with
nvidia-smi
Tensor parallel errors
Tensor parallel errors
Error: Issues with multi-GPU deploymentSolutions:
- Ensure all GPUs have same model
- Check NCCL configuration
- Verify GPU visibility:
- Test with Ray backend:
Monitoring
Health Checks
Metrics Collection
vLLM exposes Prometheus metrics:Next Steps
FastChat Integration
Add web UI and more features with FastChat
Production Guide
Production deployment best practices
Performance Tuning
Advanced performance optimization
Monitoring Setup
Set up comprehensive monitoring