# vllm-project/vllm-ascend architecture

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

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

## Overview

vLLM Ascend is a hardware plugin that adapts vLLM inference to Huawei Ascend NPUs. The principal workflow is a vLLM serving request handled by the Ascend worker and attention/model operations, with native CANN kernels providing device computation. The repository also has distinct MoE, multimodal-cache, compilation, distributed-transfer, and runtime-guard capabilities. The README establishes the plugin role; source-index references and sampled excerpts support only the internal links shown, so other connections are omitted rather than inferred.

Main entry points: [`vllm_ascend/platform.py`](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/platform.py) (Ascend Plugin), [`csrc/attention/kv_quant_sparse_flash_attention_vllm/op_kernel/kv_quant_sparse_flash_attention_vllm_service_vector_mla.h`](https://github.com/vllm-project/vllm-ascend/blob/main/csrc/attention/kv_quant_sparse_flash_attention_vllm/op_kernel/kv_quant_sparse_flash_attention_vllm_service_vector_mla.h) (Sparse Attention Kernel), [`vllm_ascend/worker/v2/pcp_manager.py`](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/worker/v2/pcp_manager.py) (Batch Manager), [`vllm_ascend/compilation/graph_fusion_pass_manager.py`](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/compilation/graph_fusion_pass_manager.py) (Graph Fusion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["vLLM Integration"]
  node_plugin["Ascend Plugin<br/>[platform.py]"]
  node_worker["Ascend Worker<br/>[worker.py]"]
  node_worker_batch["Batch Manager<br/>[pcp_manager.py]"]
  node_hardware["Hardware Profile"]
  node_engine_patch["Engine Patches"]
  node_balance_patch["Balance Scheduling"]
end

subgraph group_compute["Model Computation"]
  node_attn_utils["Attention Utilities<br/>[attn_utils.py]"]
  node_rotary["Rotary Embedding"]
  node_fusion["Graph Fusion"]
  node_attention["Attention Backend<br/>[attention_v1.py]"]
  node_mla["MLA Backend<br/>[mla_v1.py]"]
  node_sparse_kernel["Sparse Attention Kernel"]
  node_kernel_common["Kernel Primitives<br/>[matmul.h]"]
  node_moe_kernel["Quantized MoE Kernel"]
end

subgraph group_distributed["Distributed Runtime"]
  node_weight_transfer["HCCL Weight Transfer<br/>[hccl_engine.py]"]
  node_packed_tensor["Packed Tensors<br/>[packed_tensor.py]"]
  node_ipc_transfer["NPU IPC Transfer<br/>[npu_ipc_engine.py]"]
  node_memfabric["MemFabric Transfer"]
end

subgraph group_operations["Runtime Operations"]
  node_encoder_cache[("Encoder Cache")]
  node_runtime_guard["Runtime Guard<br/>[manager.py]"]
  node_runtime_config["Guard Configuration<br/>[config.py]"]
end

node_vllm_user(("Inference Client"))

node_vllm_user -->|"uses plugin"| node_plugin
node_plugin -.->|"runs inference"| node_worker
node_worker_batch -->|"uses"| node_rotary
node_worker_batch -->|"uses"| node_attn_utils
node_fusion -->|"checks capability"| node_hardware
node_fusion -->|"reads config"| node_plugin
node_attention -.->|"dispatches"| node_sparse_kernel
node_mla -.->|"dispatches"| node_sparse_kernel
node_sparse_kernel -->|"uses primitives"| node_kernel_common
node_moe_kernel -.->|"uses primitives"| node_kernel_common
node_weight_transfer -->|"uses"| node_packed_tensor
node_ipc_transfer -->|"uses"| node_packed_tensor
node_runtime_guard -->|"reads config"| node_runtime_config
node_engine_patch -->|"selects"| node_balance_patch

click node_plugin "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/platform.py"
click node_worker "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/worker/worker.py"
click node_worker_batch "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/worker/v2/pcp_manager.py"
click node_attn_utils "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/worker/v2/attn_utils.py"
click node_rotary "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/ops/rotary_embedding.py"
click node_fusion "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/compilation/graph_fusion_pass_manager.py"
click node_hardware "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/device/hardware_profile.py"
click node_attention "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/attention/attention_v1.py"
click node_mla "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/attention/mla_v1.py"
click node_sparse_kernel "https://github.com/vllm-project/vllm-ascend/blob/main/csrc/attention/kv_quant_sparse_flash_attention_vllm/op_kernel/kv_quant_sparse_flash_attention_vllm_service_vector_mla.h"
click node_kernel_common "https://github.com/vllm-project/vllm-ascend/blob/main/csrc/attention/common/op_kernel/matmul.h"
click node_moe_kernel "https://github.com/vllm-project/vllm-ascend/blob/main/csrc/gmm/grouped_matmul_swiglu_quant_v2/op_kernel/grouped_matmul_swiglu_quant_v2_a8w4_msd_pipeline.h"
click node_encoder_cache "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/ec_manager/score_ec_manager.py"
click node_weight_transfer "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/distributed/weight_transfer/hccl_engine.py"
click node_packed_tensor "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/distributed/weight_transfer/packed_tensor.py"
click node_ipc_transfer "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py"
click node_memfabric "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/distributed/kv_transfer/utils/memfabric_transfer_engine.py"
click node_runtime_guard "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/observability/runtime_guard/detector/manager.py"
click node_runtime_config "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/observability/runtime_config/config.py"
click node_engine_patch "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/patch/platform/patch_engine_core.py"
click node_balance_patch "https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/patch/platform/patch_balance_schedule.py"

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_plugin,node_worker,node_worker_batch,node_hardware,node_engine_patch,node_balance_patch,node_vllm_user toneBlue
class node_attn_utils,node_rotary,node_fusion,node_attention,node_mla,node_sparse_kernel,node_kernel_common,node_moe_kernel toneAmber
class node_weight_transfer,node_packed_tensor,node_ipc_transfer,node_memfabric toneMint
class node_encoder_cache,node_runtime_guard,node_runtime_config toneRose
```

## Components

### vLLM Integration

- [Ascend Plugin](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/platform.py): `vllm_ascend/platform.py`
- [Ascend Worker](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/worker/worker.py): `vllm_ascend/worker/worker.py`
- [Batch Manager](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/worker/v2/pcp_manager.py): `vllm_ascend/worker/v2/pcp_manager.py`
- [Hardware Profile](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/device/hardware_profile.py): `vllm_ascend/device/hardware_profile.py`
- [Engine Patches](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/patch/platform/patch_engine_core.py): `vllm_ascend/patch/platform/patch_engine_core.py`
- [Balance Scheduling](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/patch/platform/patch_balance_schedule.py): `vllm_ascend/patch/platform/patch_balance_schedule.py`

### Model Computation

- [Attention Utilities](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/worker/v2/attn_utils.py): `vllm_ascend/worker/v2/attn_utils.py`
- [Rotary Embedding](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/ops/rotary_embedding.py): `vllm_ascend/ops/rotary_embedding.py`
- [Graph Fusion](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/compilation/graph_fusion_pass_manager.py): `vllm_ascend/compilation/graph_fusion_pass_manager.py`
- [Attention Backend](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/attention/attention_v1.py): `vllm_ascend/attention/attention_v1.py`
- [MLA Backend](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/attention/mla_v1.py): `vllm_ascend/attention/mla_v1.py`
- [Sparse Attention Kernel](https://github.com/vllm-project/vllm-ascend/blob/main/csrc/attention/kv_quant_sparse_flash_attention_vllm/op_kernel/kv_quant_sparse_flash_attention_vllm_service_vector_mla.h): `csrc/attention/kv_quant_sparse_flash_attention_vllm/op_kernel/kv_quant_sparse_flash_attention_vllm_service_vector_mla.h`
- [Kernel Primitives](https://github.com/vllm-project/vllm-ascend/blob/main/csrc/attention/common/op_kernel/matmul.h): `csrc/attention/common/op_kernel/matmul.h`
- [Quantized MoE Kernel](https://github.com/vllm-project/vllm-ascend/blob/main/csrc/gmm/grouped_matmul_swiglu_quant_v2/op_kernel/grouped_matmul_swiglu_quant_v2_a8w4_msd_pipeline.h): `csrc/gmm/grouped_matmul_swiglu_quant_v2/op_kernel/grouped_matmul_swiglu_quant_v2_a8w4_msd_pipeline.h`

### Distributed Runtime

- [HCCL Weight Transfer](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/distributed/weight_transfer/hccl_engine.py): `vllm_ascend/distributed/weight_transfer/hccl_engine.py`
- [Packed Tensors](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/distributed/weight_transfer/packed_tensor.py): `vllm_ascend/distributed/weight_transfer/packed_tensor.py`
- [NPU IPC Transfer](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py): `vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py`
- [MemFabric Transfer](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/distributed/kv_transfer/utils/memfabric_transfer_engine.py): `vllm_ascend/distributed/kv_transfer/utils/memfabric_transfer_engine.py`

### Runtime Operations

- [Encoder Cache](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/ec_manager/score_ec_manager.py): `vllm_ascend/ec_manager/score_ec_manager.py`
- [Runtime Guard](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/observability/runtime_guard/detector/manager.py): `vllm_ascend/observability/runtime_guard/detector/manager.py`
- [Guard Configuration](https://github.com/vllm-project/vllm-ascend/blob/main/vllm_ascend/observability/runtime_config/config.py): `vllm_ascend/observability/runtime_config/config.py`

### Other components

- **Inference Client**

## Connections

- Inference Client → Ascend Plugin: uses plugin
- Ascend Plugin → Ascend Worker: runs inference
- Batch Manager → Rotary Embedding: uses (evidence: `vllm_ascend/worker/v2/pcp_manager.py`)
- Batch Manager → Attention Utilities: uses (evidence: `vllm_ascend/worker/v2/pcp_manager.py`)
- Graph Fusion → Hardware Profile: checks capability (evidence: `vllm_ascend/compilation/graph_fusion_pass_manager.py`)
- Graph Fusion → Ascend Plugin: reads config (evidence: `vllm_ascend/compilation/graph_fusion_pass_manager.py`)
- Attention Backend → Sparse Attention Kernel: dispatches
- MLA Backend → Sparse Attention Kernel: dispatches
- Sparse Attention Kernel → Kernel Primitives: uses primitives
- Quantized MoE Kernel → Kernel Primitives: uses primitives
- HCCL Weight Transfer → Packed Tensors: uses (evidence: `vllm_ascend/distributed/weight_transfer/hccl_engine.py`)
- NPU IPC Transfer → Packed Tensors: uses (evidence: `vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py`)
- Runtime Guard → Guard Configuration: reads config (evidence: `vllm_ascend/observability/runtime_guard/detector/manager.py`)
- Engine Patches → Balance Scheduling: selects (evidence: `vllm_ascend/patch/platform/patch_engine_core.py`)
