vLLM and LLM Inference Serving
vLLM is an open-source engine that runs large language model inference on GPUs and serves the results through an OpenAI-compatible API. It exists to make LLM serving fast and cheap by cutting the memory wasted on the key-value cache, so more requests fit on one GPU.
itArtificial intelligence and machine learning | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — vLLM and LLM Inference Serving
vLLM is the bit of an LLM system that takes a model which is very good at predicting the next token and asks it to do that for many people without turning a GPU into an expensive waiting room. It accepts requests through an OpenAI-compatible API, then makes the hardware spend more of its time producing tokens and less of it admiring unused memory. That is a surprisingly specialised job, because generation happens one token at a time.
The first important passenger is the KV cache, the per-request attention state that grows as a prompt and response grow. Before vLLM, a server could reserve one large continuous area for every request, sized for the longest possible conversation. Most conversations finish early. The unused reservation cannot help anybody else, which is efficient only if the GPU is collecting empty seats as a hobby.
vLLM's answer is PagedAttention. It breaks that cache into fixed-size blocks and gives a request another block only when it needs one. The blocks need not sit next to each other, so the service can use the memory it has rather than the neatly rectangular memory it wishes it had. Shared prompt prefixes can also reuse their already-computed blocks. That matters when many requests begin with the same system prompt or document.
The other moving part is continuous batching, where the scheduler rebuilds the batch at every generation step. A request that finishes leaves; a waiting request can take its place. This avoids the static-batching ritual in which a short request sits finished while the longest response in the group continues its novel. The scheduler balances prompt processing, called prefill, against ongoing token generation, called decode, while the cache places a hard limit on the work it can admit.
The architecture is not a single mysterious box. An API server handles HTTP and tokenization. An engine core schedules requests and manages cache blocks. GPU workers load weight shards and run forward passes. When one GPU is not enough, tensor parallelism splits layer work within a node, pipeline parallelism splits layers across stages, and data parallelism adds replicas for throughput. More machinery helps only when the model, interconnect, and workload call for it; a quiet single-GPU service may not need this whole travelling circus.
Start with the Intro for the full route from request to worker. Use the Slides to see how cache, scheduler, and parallelism fit together. Keep the Cheatsheet nearby when reading startup capacity signals or choosing a scaling strategy. The Field Notes then covers the practical traps: cache pressure, preemption, prompt shape, and the evidence that says which constraint has actually arrived.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://docs.vllm.ai/en/latest/
Supports
- vLLM is a fast and easy-to-use library for LLM inference and serving.
- https://docs.vllm.ai/en/latest/
Supports
- vLLM is fast with PagedAttention, continuous batching of incoming requests, chunked prefill, prefix caching, CUDA/HIP graphs, and a wide range of quantization formats (FP8, MXFP8/MXFP4, NVFP4, INT8, INT4, GPTQ/AWQ, GGUF, compressed-tensors, ModelOpt, TorchAO).
- https://docs.vllm.ai/en/latest/
Supports
- vLLM seamlessly supports 200+ model architectures on HuggingFace, including decoder-only LLMs, Mixture-of-Expert LLMs, hybrid attention and state-space models, multi-modal models, and embedding and retrieval models.
- https://docs.vllm.ai/en/latest/
Supports
- vLLM supports NVIDIA GPUs, AMD GPUs, and x86/ARM/PowerPC CPUs, with hardware plugins for Google TPUs, Intel Gaudi, IBM Spyre, Huawei Ascend, Apple Silicon, and others.
- https://docs.vllm.ai/en/latest/
Supports
- vLLM was originally developed in the Sky Computing Lab at UC Berkeley and has grown into one of the most active open-source AI projects with contributors from over 2000 contributors.
- https://blog.vllm.ai/2023/06/20/vllm.html
Supports
- PagedAttention takes inspiration from traditional OS concepts such as paging and virtual memory, allowing the KV cache to be non-contiguous by allocating memory in fixed-size pages (blocks), limiting wastage to under 4% in the last block.
- https://arxiv.org/abs/2309.06180
Supports
- The vLLM paper is Efficient Memory Management for Large Language Model Serving with PagedAttention, Kwon et al., SOSP 2023.
- https://docs.vllm.ai/en/latest/design/arch_overview/
Supports
- vLLM V1 uses a multi-process architecture: an API server process (ZMQ to engine cores), an engine core process per data-parallel rank running the scheduler and KV cache management, one GPU worker process per GPU, and a conditional DP coordinator process.
- https://docs.vllm.ai/en/latest/design/arch_overview/
Supports
- A single-node deployment with 4 GPUs (vllm serve --tensor-parallel-size 4) has 1 API server, 1 engine core, and 4 GPU workers = 6 processes total.
- https://docs.vllm.ai/en/latest/design/arch_overview/
Supports
- By default there is 1 API server process; under data parallelism the API server count scales to match the data parallel size, configurable with --api-server-count. Each API server connects to all engine cores via ZMQ in a many-to-many topology.
- https://docs.vllm.ai/en/latest/getting_started/quickstart/
Supports
- vllm serve <model> starts the OpenAI-compatible server at http://localhost:8000 by default, implementing list models, create chat completion, and create completion endpoints.
- https://docs.vllm.ai/en/latest/getting_started/quickstart/
Supports
- By default the server applies generation_config.json from the Hugging Face model repository if it exists; pass --generation-config vllm to use vLLM defaults instead.
- https://docs.vllm.ai/en/latest/getting_started/quickstart/
Supports
- The --api-key flag or VLLM_API_KEY environment variable enable API key checking in the header; multiple keys can be passed for key rotation.
- https://docs.vllm.ai/en/latest/getting_started/quickstart/
Supports
- vLLM supports multiple attention backends, selected automatically or via --attention-backend; on NVIDIA CUDA these include FLASH_ATTN and FLASHINFER, on AMD ROCm TRITON_ATTN, ROCM_ATTN, and variants.
- https://docs.vllm.ai/en/latest/getting_started/quickstart/
Supports
- The LLM class provides the primary Python interface for offline inference; SamplingParams specifies sampling parameters; llm.generate adds prompts to the engine's waiting queue and executes with high throughput.
- https://www.anyscale.com/blog/continuous-batching-llm-inference
Supports
- LLM inference is memory-IO bound, not compute bound; it takes more time to load 1MB of data to the GPU's compute cores than for those cores to perform LLM computations on 1MB of data, so throughput is largely determined by how large a batch fits in high-bandwidth GPU memory.
- https://www.anyscale.com/blog/continuous-batching-llm-inference
Supports
- A 13B parameter model consumes nearly 1MB of state for each token in a sequence; on an A100 with 40GB RAM, after storing 26GB of model parameters, about 14k tokens can be held in memory at once, capping the batch size for a given max sequence length.
- https://www.anyscale.com/blog/continuous-batching-llm-inference
Supports
- Continuous batching (also called dynamic batching or iteration-level scheduling) implements iteration-level scheduling where the batch size is determined per iteration; once a sequence completes, a new sequence can be inserted in its place, yielding higher GPU utilization. This was described in the Orca paper (OSDI 2022).
- https://www.anyscale.com/blog/continuous-batching-llm-inference
Supports
- Continuous batching frameworks manage the prefill vs decode mix via hyperparameters such as waiting_served_ratio, the ratio of requests waiting for prefill to those waiting for end-of-sequence tokens.
- https://www.anyscale.com/blog/continuous-batching-llm-inference
Supports
- The prefill phase pre-computes inputs of the attention mechanism that remain constant over the lifetime of the generation, and efficiently uses the GPU's parallel compute because these inputs can be computed independently.
- https://docs.vllm.ai/en/latest/serving/parallelism_scaling/
Supports
- vLLM's distributed inference includes Megatron-LM's tensor parallel algorithm; the default distributed runtimes are Ray for multi-node and native Python multiprocessing for single-node, overridable with --distributed-executor-backend mp|ray.
- https://docs.vllm.ai/en/latest/serving/parallelism_scaling/
Supports
- Guidelines for choosing a distributed inference strategy: single GPU if the model fits; single-node multi-GPU tensor parallelism if the model is too large for one GPU but fits on one node; multi-node combining tensor parallel (per node) with pipeline parallel (per node count) if the model is too large for one node.
- https://docs.vllm.ai/en/latest/serving/parallelism_scaling/
Supports
- vLLM supports Data Parallel attention with Expert or Tensor Parallel MoE layers for large-scale Mixture-of-Experts deployment.
- https://docs.vllm.ai/en/latest/serving/parallelism_scaling/
Supports
- At startup vLLM logs GPU KV cache size (total tokens the cache can hold) and Maximum concurrency for a given tokens-per-request estimate taken from ModelConfig.max_model_len; use these to size the deployment.
- https://docs.vllm.ai/en/latest/serving/parallelism_scaling/
Supports
- For multi-node deployment, every node must provide an identical execution environment including model path and Python packages; container images are recommended. Tensor parallel size is set to GPUs per node and pipeline parallel size to the number of nodes.
- https://docs.vllm.ai/en/latest/serving/parallelism_scaling/
Supports
- GPUDirect RDMA allows network adapters to directly access GPU memory, bypassing CPU and system memory, reducing latency and CPU overhead for large cross-node data transfers; enable with IPC_LOCK capability and /dev/shm shared memory.
- https://docs.vllm.ai/en/latest/design/arch_overview/
Supports
- vLLM models' constructor signature is uniform: def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):, enabling sharding and quantization at initialization so each layer only creates the shard it needs and a 405B model can be served across many 80GB GPUs.
- https://docs.vllm.ai/en/latest/
Supports
- vLLM supports speculative decoding including n-gram, suffix, EAGLE, and DFlash drafters, and multi-token-prediction (MTP) modules.
- https://docs.vllm.ai/en/latest/
Supports
- vLLM's server implements the OpenAI-compatible API server plus the Anthropic Messages API and gRPC support, with structured outputs using xgrammar or guidance, tool calling, and reasoning parsers.
- https://github.com/Hannibal046/awesome-llm
Supports
- The Awesome-LLM list's LLM Inference section catalogs serving engines including vLLM, SGLang, llama.cpp, ollama, Text-Generation-Inference (TGI), TensorRT-LLM, DeepSpeed-MII, and LMDeploy.
- https://www.digitalocean.com/community/tutorials/digitalocean-s-technical-writing-guidelines
Supports
- The DigitalOcean Technical Writing Guidelines govern the writing style of learner-facing content; they are not added to sources.yaml because they govern style rather than course facts.
