# rocm/vllm architecture

> Architecture diagram of the GitHub repository rocm/vllm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rocm/vllm
- Repository: https://github.com/rocm/vllm

## Overview

#### 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: [`vllm/inputs/preprocess.py`](https://github.com/rocm/vllm/blob/main/vllm/inputs/preprocess.py) (Input preprocessing), [`vllm/v1/worker/gpu_model_runner.py`](https://github.com/rocm/vllm/blob/main/vllm/v1/worker/gpu_model_runner.py) (GPU model runner), [`vllm/engine/llm_engine.py`](https://github.com/rocm/vllm/blob/main/vllm/engine/llm_engine.py) (LLM engine), [`vllm/v1/engine/core.py`](https://github.com/rocm/vllm/blob/main/vllm/v1/engine/core.py) (V1 engine core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Entrypoints"]
  node_cli["CLI<br/>entrypoint<br/>[main.py]"]
  node_openai_api["OpenAI HTTP API<br/>server<br/>[api_server.py]"]
  node_generic_api["Generic API server<br/>[api_server.py]"]
  node_offline_llm["Offline Python API<br/>[llm.py]"]
  node_openai_serving["OpenAI serving adapters<br/>API adaptation<br/>[serving_engine.py]"]
  node_input_preprocess["Input preprocessing<br/>normalization<br/>[preprocess.py]"]
end

subgraph group_legacy["Legacy engine path"]
  node_async_engine["Async LLM engine<br/>legacy control plane"]
  node_llm_engine["LLM engine<br/>legacy control plane<br/>[llm_engine.py]"]
  node_legacy_scheduler["Legacy scheduler<br/>[scheduler.py]"]
  node_legacy_blocks[("Legacy block manager<br/>KV cache<br/>[block_manager.py]")]
end

subgraph group_v1["V1 engine path"]
  node_v1_core["V1 engine core<br/>control plane<br/>[core.py]"]
  node_v1_processor["V1 output processor<br/>response processing<br/>[processor.py]"]
  node_v1_scheduler["V1 scheduler<br/>[scheduler.py]"]
  node_v1_kv_cache[("V1 KV cache manager")]
end

subgraph group_runtime["Execution runtime"]
  node_executor["Executor<br/>worker dispatch"]
  node_gpu_runner["GPU model runner<br/>model execution"]
  node_model_registry["Model registry<br/>model selection<br/>[registry.py]"]
  node_native_kernels{{"Native attention kernels<br/>C++/CUDA/HIP"}}
  node_distributed["Distributed parallelism<br/>parallel runtime<br/>[parallel_state.py]"]
  node_kv_transfer["NIXL KV connector<br/>KV transfer<br/>[nixl_connector.py]"]
  node_rocm_platform["ROCm platform<br/>platform adapter<br/>[rocm.py]"]
  node_quantization["Quantization schemes<br/>model optimization<br/>[__init__.py]"]
end

subgraph group_delivery["Build &amp; delivery"]
  node_build["CMake build<br/>native build<br/>[CMakeLists.txt]"]
  node_packaging["Python packaging<br/>package build<br/>[setup.py]"]
  node_rocm_container["ROCm container<br/>deployment image<br/>[Dockerfile.rocm]"]
  node_ci["Buildkite CI<br/>CI pipeline<br/>[test-pipeline.yaml]"]
end

node_cli -->|"submits requests"| node_input_preprocess
node_generic_api -->|"submits requests"| node_input_preprocess
node_offline_llm -->|"submits requests"| node_input_preprocess
node_openai_api -->|"HTTP routes"| node_openai_serving
node_openai_serving -->|"adapts requests"| node_input_preprocess
node_input_preprocess -.->|"legacy engine requests"| node_async_engine
node_input_preprocess -.->|"V1 engine requests"| node_v1_core
node_async_engine -->|"drives iterations"| node_llm_engine
node_llm_engine -->|"schedules"| node_legacy_scheduler
node_legacy_scheduler -->|"allocates KV blocks"| node_legacy_blocks
node_llm_engine -->|"dispatches execution"| node_executor
node_v1_core -->|"schedules"| node_v1_scheduler
node_v1_scheduler -->|"allocates KV pages"| node_v1_kv_cache
node_v1_core -->|"dispatches model work"| node_gpu_runner
node_gpu_runner -->|"logits and outputs"| node_v1_processor
node_executor -->|"loads selected model"| node_model_registry
node_gpu_runner -->|"loads selected model"| node_model_registry
node_model_registry -->|"selects optimization"| node_quantization
node_gpu_runner -->|"dispatches kernels"| node_native_kernels
node_executor -->|"coordinates workers"| node_distributed
node_v1_kv_cache -->|"transfers cache"| node_kv_transfer
node_distributed -->|"uses platform backend"| node_rocm_platform
node_rocm_platform -->|"targets HIP kernels"| node_native_kernels
node_build -->|"produces extensions"| node_packaging
node_packaging -->|"packages runtime"| node_rocm_container
node_ci -->|"builds and tests"| node_build
node_ci -->|"validates image"| node_rocm_container

click node_cli "https://github.com/rocm/vllm/blob/main/vllm/entrypoints/cli/main.py"
click node_openai_api "https://github.com/rocm/vllm/blob/main/vllm/entrypoints/openai/api_server.py"
click node_generic_api "https://github.com/rocm/vllm/blob/main/vllm/entrypoints/api_server.py"
click node_offline_llm "https://github.com/rocm/vllm/blob/main/vllm/entrypoints/llm.py"
click node_openai_serving "https://github.com/rocm/vllm/blob/main/vllm/entrypoints/openai/serving_engine.py"
click node_input_preprocess "https://github.com/rocm/vllm/blob/main/vllm/inputs/preprocess.py"
click node_async_engine "https://github.com/rocm/vllm/blob/main/vllm/engine/async_llm_engine.py"
click node_llm_engine "https://github.com/rocm/vllm/blob/main/vllm/engine/llm_engine.py"
click node_legacy_scheduler "https://github.com/rocm/vllm/blob/main/vllm/core/scheduler.py"
click node_legacy_blocks "https://github.com/rocm/vllm/blob/main/vllm/core/block_manager.py"
click node_v1_core "https://github.com/rocm/vllm/blob/main/vllm/v1/engine/core.py"
click node_v1_processor "https://github.com/rocm/vllm/blob/main/vllm/v1/engine/processor.py"
click node_v1_scheduler "https://github.com/rocm/vllm/blob/main/vllm/v1/core/sched/scheduler.py"
click node_v1_kv_cache "https://github.com/rocm/vllm/blob/main/vllm/v1/core/kv_cache_manager.py"
click node_executor "https://github.com/rocm/vllm/blob/main/vllm/executor/uniproc_executor.py"
click node_gpu_runner "https://github.com/rocm/vllm/blob/main/vllm/v1/worker/gpu_model_runner.py"
click node_model_registry "https://github.com/rocm/vllm/blob/main/vllm/model_executor/models/registry.py"
click node_native_kernels "https://github.com/rocm/vllm/blob/main/csrc/attention/paged_attention_v1.cu"
click node_distributed "https://github.com/rocm/vllm/blob/main/vllm/distributed/parallel_state.py"
click node_kv_transfer "https://github.com/rocm/vllm/blob/main/vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py"
click node_rocm_platform "https://github.com/rocm/vllm/blob/main/vllm/platforms/rocm.py"
click node_quantization "https://github.com/rocm/vllm/blob/main/vllm/model_executor/layers/quantization/__init__.py"
click node_build "https://github.com/rocm/vllm/blob/main/CMakeLists.txt"
click node_packaging "https://github.com/rocm/vllm/blob/main/setup.py"
click node_rocm_container "https://github.com/rocm/vllm/blob/main/docker/Dockerfile.rocm"
click node_ci "https://github.com/rocm/vllm/blob/main/.buildkite/test-pipeline.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_openai_api,node_generic_api,node_offline_llm,node_openai_serving,node_input_preprocess toneBlue
class node_async_engine,node_llm_engine,node_legacy_scheduler,node_legacy_blocks toneAmber
class node_v1_core,node_v1_processor,node_v1_scheduler,node_v1_kv_cache toneMint
class node_executor,node_gpu_runner,node_model_registry,node_native_kernels,node_distributed,node_kv_transfer,node_rocm_platform,node_quantization toneRose
class node_build,node_packaging,node_rocm_container,node_ci toneIndigo
```

## Components

### Entrypoints

- [CLI](https://github.com/rocm/vllm/blob/main/vllm/entrypoints/cli/main.py): entrypoint · `vllm/entrypoints/cli/main.py`
- [OpenAI HTTP API](https://github.com/rocm/vllm/blob/main/vllm/entrypoints/openai/api_server.py): server · OpenAI-compatible request and streaming response surface. · `vllm/entrypoints/openai/api_server.py`
- [Generic API server](https://github.com/rocm/vllm/blob/main/vllm/entrypoints/api_server.py): server · `vllm/entrypoints/api_server.py`
- [Offline Python API](https://github.com/rocm/vllm/blob/main/vllm/entrypoints/llm.py): python API · `vllm/entrypoints/llm.py`
- [OpenAI serving adapters](https://github.com/rocm/vllm/blob/main/vllm/entrypoints/openai/serving_engine.py): API adaptation · Maps completion, chat, embedding, pooling, scoring, audio, and batch APIs to engine requests. · `vllm/entrypoints/openai/serving_engine.py`
- [Input preprocessing](https://github.com/rocm/vllm/blob/main/vllm/inputs/preprocess.py): normalization · Validates prompts, templates, sampling, tools, structured output, and multimodal inputs. · `vllm/inputs/preprocess.py`

### Legacy engine path

- [Async LLM engine](https://github.com/rocm/vllm/blob/main/vllm/engine/async_llm_engine.py): legacy control plane · Owns asynchronous request lifecycle and streamed outputs. · `vllm/engine/async_llm_engine.py`
- [LLM engine](https://github.com/rocm/vllm/blob/main/vllm/engine/llm_engine.py): legacy control plane · Coordinates scheduling, execution, detokenization, and stopping. · `vllm/engine/llm_engine.py`
- [Legacy scheduler](https://github.com/rocm/vllm/blob/main/vllm/core/scheduler.py): scheduler · `vllm/core/scheduler.py`
- [Legacy block manager](https://github.com/rocm/vllm/blob/main/vllm/core/block_manager.py): KV cache · Allocates cache blocks for prefix reuse and eviction. · `vllm/core/block_manager.py`

### V1 engine path

- [V1 engine core](https://github.com/rocm/vllm/blob/main/vllm/v1/engine/core.py): control plane · Newer engine contract; do not mix with legacy control-plane contracts. · `vllm/v1/engine/core.py`
- [V1 output processor](https://github.com/rocm/vllm/blob/main/vllm/v1/engine/processor.py): response processing · `vllm/v1/engine/processor.py`
- [V1 scheduler](https://github.com/rocm/vllm/blob/main/vllm/v1/core/sched/scheduler.py): scheduler · `vllm/v1/core/sched/scheduler.py`
- [V1 KV cache manager](https://github.com/rocm/vllm/blob/main/vllm/v1/core/kv_cache_manager.py): KV cache · Central stateful boundary for page allocation, prefix caching, and cache transfer. · `vllm/v1/core/kv_cache_manager.py`

### Execution runtime

- [Executor](https://github.com/rocm/vllm/blob/main/vllm/executor/uniproc_executor.py): worker dispatch · Runs local, multiprocessing, or Ray-distributed workers. · `vllm/executor/uniproc_executor.py`
- [GPU model runner](https://github.com/rocm/vllm/blob/main/vllm/v1/worker/gpu_model_runner.py): model execution · Builds inputs, runs forward passes, and returns logits. · `vllm/v1/worker/gpu_model_runner.py`
- [Model registry](https://github.com/rocm/vllm/blob/main/vllm/model_executor/models/registry.py): model selection · Selects model implementations and loading paths. · `vllm/model_executor/models/registry.py`
- [Native attention kernels](https://github.com/rocm/vllm/blob/main/csrc/attention/paged_attention_v1.cu): C++/CUDA/HIP · Paged attention and other compiled accelerator operations. · `csrc/attention/paged_attention_v1.cu`
- [Distributed parallelism](https://github.com/rocm/vllm/blob/main/vllm/distributed/parallel_state.py): parallel runtime · Tensor, pipeline, expert, and data parallel coordination. · `vllm/distributed/parallel_state.py`
- [NIXL KV connector](https://github.com/rocm/vllm/blob/main/vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py): KV transfer · Supports disaggregated prefill/decode and external cache transfer. · `vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py`
- [ROCm platform](https://github.com/rocm/vllm/blob/main/vllm/platforms/rocm.py): platform adapter · `vllm/platforms/rocm.py`
- [Quantization schemes](https://github.com/rocm/vllm/blob/main/vllm/model_executor/layers/quantization/__init__.py): model optimization · `vllm/model_executor/layers/quantization/__init__.py`

### Build & delivery

- [CMake build](https://github.com/rocm/vllm/blob/main/CMakeLists.txt): native build · Builds compiled runtime extensions. · `CMakeLists.txt`
- [Python packaging](https://github.com/rocm/vllm/blob/main/setup.py): package build · `setup.py`
- [ROCm container](https://github.com/rocm/vllm/blob/main/docker/Dockerfile.rocm): deployment image · `docker/Dockerfile.rocm`
- [Buildkite CI](https://github.com/rocm/vllm/blob/main/.buildkite/test-pipeline.yaml): CI pipeline · Builds wheels and runs hardware tests, benchmarks, releases, and evaluations. · `.buildkite/test-pipeline.yaml`

## Connections

- 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
