How rocm/vllm works
Purpose and entry points
This is the retired ROCm/vLLM codebase: a Python LLM inference and serving runtime, with optimized native kernels and broad hardware support. Primary user entry points are the CLI (vllm/entrypoints/cli/main.py), OpenAI-compatible HTTP server (vllm/entrypoints/openai/api_server.py), generic API server (vllm/entrypoints/api_server.py), and offline Python API (vllm/entrypoints/llm.py).
Request ingress and API adaptation
CLI/server configuration creates an engine, validates and normalizes prompts, chat templates, sampling, tool calls, structured-output, and multimodal inputs. The OpenAI serving layer maps HTTP request/streaming response semantics to engine requests and supports completion, chat, embeddings, pooling, scoring, audio, and batch routes.
• vllm/entrypoints/openai/serving_engine.py
• vllm/entrypoints/openai/serving_chat.py
• vllm/inputs/preprocess.py
Engine control plane
The engine owns request lifecycle: enqueue/abort, scheduling iterations, executor dispatch, detokenization, stop handling, and output streaming. There are legacy engine/core paths and a newer v1 architecture; new work should determine which path the active entry point selects rather than mixing their contracts.
• vllm/engine/async_llm_engine.py
• vllm/engine/llm_engine.py
• vllm/v1/engine/core.py
• vllm/v1/engine/processor.py
Scheduling and KV-cache management
Schedulers batch prefill and decode work under token, memory, and fairness constraints. KV cache is managed as block/page allocations, enabling prefix caching, eviction, and cache sharing/transfer; this is the central stateful boundary between request scheduling and model execution.
• vllm/core/scheduler.py
• vllm/core/block_manager.py
• vllm/v1/core/sched/scheduler.py
• vllm/v1/core/kv_cache_manager.py
Execution, models, and kernels
Executors run single-process, multiprocessing, or Ray-distributed workers. Workers load a registry-selected model and weights, construct model inputs, execute forward passes/attention, then return logits for sampling. Python layers dispatch to PyTorch, Triton, and compiled C++/CUDA/HIP operations; native sources contain attention, cache, collective, MoE, and quantized GEMM implementations.
• vllm/executor/uniproc_executor.py
• vllm/v1/worker/gpu_model_runner.py
• vllm/model_executor/models/registry.py
• csrc/torch_bindings.cpp
• csrc/attention/paged_attention_v1.cu
Portability, parallelism, and extensions
Platform abstraction targets CUDA, ROCm, CPU, TPU, and XPU. Distributed execution supports tensor/pipeline/expert/data parallelism and transport-specific collectives; KV transfer connectors support disaggregated prefill/decode and external cache systems such as LMCache, NIXL, Mooncake, shared storage, and NCCL P2P. Model loading integrates Transformers-style configurations/tokenizers and supports Hugging Face model artifacts; quantization is selected through model-executor schemes and hardware-specific kernels.
• vllm/platforms/rocm.py
• vllm/distributed/parallel_state.py
• vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
• vllm/model_executor/layers/quantization/__init__.py
Build and deployment boundary
The runtime is packaged as Python plus compiled extensions, built through CMake and setup.py. Container variants encode CPU, ROCm, TPU, and XPU environments. Buildkite drives hardware CI, releases, wheels, benchmarks, and nightly evaluations.
• CMakeLists.txt
• setup.py
• docker/Dockerfile.rocm
• .buildkite/test-pipeline.yaml
Main entry points: preprocess.py Input preprocessing · gpu_model_runner.py GPU model runner · llm_engine.py LLM engine · core.py V1 engine core
Components 26
Entrypoints
- CLI
vllm/entrypoints/cli/main.py - OpenAI HTTP API · OpenAI-compatible request and streaming response surface.
vllm/entrypoints/openai/api_server.py - Generic API server
vllm/entrypoints/api_server.py - Offline Python API
vllm/entrypoints/llm.py - OpenAI serving adapters · Maps completion, chat, embedding, pooling, scoring, audio, and batch APIs to engine requests.
vllm/entrypoints/openai/serving_engine.py - Input preprocessing · Validates prompts, templates, sampling, tools, structured output, and multimodal inputs.
vllm/inputs/preprocess.py
Legacy engine path
- Async LLM engine · Owns asynchronous request lifecycle and streamed outputs.
vllm/engine/async_llm_engine.py - LLM engine · Coordinates scheduling, execution, detokenization, and stopping.
vllm/engine/llm_engine.py - Legacy scheduler
vllm/core/scheduler.py - Legacy block manager · Allocates cache blocks for prefix reuse and eviction.
vllm/core/block_manager.py
V1 engine path
- V1 engine core · Newer engine contract; do not mix with legacy control-plane contracts.
vllm/v1/engine/core.py - V1 output processor
vllm/v1/engine/processor.py - V1 scheduler
vllm/v1/core/sched/scheduler.py - V1 KV cache manager · Central stateful boundary for page allocation, prefix caching, and cache transfer.
vllm/v1/core/kv_cache_manager.py
Execution runtime
- Executor · Runs local, multiprocessing, or Ray-distributed workers.
vllm/executor/uniproc_executor.py - GPU model runner · Builds inputs, runs forward passes, and returns logits.
vllm/v1/worker/gpu_model_runner.py - Model registry · Selects model implementations and loading paths.
vllm/model_executor/models/registry.py - Native attention kernels · Paged attention and other compiled accelerator operations.
csrc/attention/paged_attention_v1.cu - Distributed parallelism · Tensor, pipeline, expert, and data parallel coordination.
vllm/distributed/parallel_state.py - NIXL KV connector · Supports disaggregated prefill/decode and external cache transfer.
vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py - ROCm platform
vllm/platforms/rocm.py - Quantization schemes
vllm/model_executor/layers/quantization/__init__.py
Build & delivery
- CMake build · Builds compiled runtime extensions.
CMakeLists.txt - Python packaging
setup.py - ROCm container
docker/Dockerfile.rocm - Buildkite CI · Builds wheels and runs hardware tests, benchmarks, releases, and evaluations.
.buildkite/test-pipeline.yaml
Connections 27
- CLI → Input preprocessing: submits requests
- Generic API server → Input preprocessing: submits requests
- Offline Python API → Input preprocessing: submits requests
- OpenAI HTTP API → OpenAI serving adapters: HTTP routes
- OpenAI serving adapters → Input preprocessing: adapts requests
- Input preprocessing → Async LLM engine: legacy engine requests
- Input preprocessing → V1 engine core: V1 engine requests
- Async LLM engine → LLM engine: drives iterations
- LLM engine → Legacy scheduler: schedules
- Legacy scheduler → Legacy block manager: allocates KV blocks
- LLM engine → Executor: dispatches execution
- V1 engine core → V1 scheduler: schedules
- V1 scheduler → V1 KV cache manager: allocates KV pages
- V1 engine core → GPU model runner: dispatches model work
- GPU model runner → V1 output processor: logits and outputs
- Executor → Model registry: loads selected model
- GPU model runner → Model registry: loads selected model
- Model registry → Quantization schemes: selects optimization
- GPU model runner → Native attention kernels: dispatches kernels
- Executor → Distributed parallelism: coordinates workers
- V1 KV cache manager → NIXL KV connector: transfers cache
- Distributed parallelism → ROCm platform: uses platform backend
- ROCm platform → Native attention kernels: targets HIP kernels
- CMake build → Python packaging: produces extensions
- Python packaging → ROCm container: packages runtime
- Buildkite CI → CMake build: builds and tests
- Buildkite CI → ROCm container: validates image