Skip to main content

vLLM — Source Code Analysis Index

Quick Summary

vLLM is a high-throughput, memory-efficient inference and serving engine for large language models. Written primarily in Python with CUDA/Triton extensions, it implements PagedAttention for KV cache management, supports 100+ model architectures, and exposes OpenAI/Anthropic-compatible APIs. Key design choices include: continuous batching with iteration-level scheduling, block-level KV cache with prefix caching, pluggable attention backends, and speculative decoding.

Documents

FileContents
01-overview.mdProject classification, tech stack, directory map, module diagram
02-startup.mdEntry point, initialization sequence, thread/process model, memory layout
03-api.mdAll API endpoints with sequence diagrams (OpenAI, Anthropic, management)
04-shutdown.mdSignal handling, graceful shutdown sequence, resource cleanup inventory
05-data-structures.mdCore data structures: Request, SamplingParams, KVCacheBlock, SchedulerOutput, etc.
06-storage.mdModel weight formats (SafeTensors, GGUF, BnB), KV cache persistence, configuration
07-protocol.mdZMQ IPC protocol, HTTP/SSE, NCCL, KV Connector, MCP tool protocol
08-crosscutting.mdAuthentication, logging, Prometheus metrics, OpenTelemetry tracing, rate limiting
09-extensions.mdPlugin system, attention backends, structured output, quantization, speculative decoding

Key Files to Read First

FileReason
vllm/v1/engine/core.pyEngine core: the central scheduling + execution loop
vllm/v1/engine/async_llm.pyAsyncLLM: main interface between API server and engine
vllm/v1/core/sched/scheduler.pyScheduler: determines which requests get tokens each step
vllm/v1/worker/gpu_model_runner.pyGPU model runner: prepares inputs, executes forward pass
vllm/entrypoints/openai/api_server.pyAPI server: FastAPI app setup, router registration
vllm/v1/request.pyRequest: core data structure flowing through the pipeline
vllm/v1/core/kv_cache_utils.pyKV cache block management: prefix caching, block hashing
vllm/config/model.pyModelConfig: central configuration for model loading