How vllm-project/vllm-ascend works
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: platform.py Ascend Plugin · kv_quant_sparse_flash_attention_vllm_service_vector_mla.h Sparse Attention Kernel · pcp_manager.py Batch Manager · graph_fusion_pass_manager.py Graph Fusion
Components 22
vLLM Integration
- Ascend Plugin
vllm_ascend/platform.py - Ascend Worker
vllm_ascend/worker/worker.py - Batch Manager
vllm_ascend/worker/v2/pcp_manager.py - Hardware Profile
vllm_ascend/device/hardware_profile.py - Engine Patches
vllm_ascend/patch/platform/patch_engine_core.py - Balance Scheduling
vllm_ascend/patch/platform/patch_balance_schedule.py
Model Computation
- Attention Utilities
vllm_ascend/worker/v2/attn_utils.py - Rotary Embedding
vllm_ascend/ops/rotary_embedding.py - Graph Fusion
vllm_ascend/compilation/graph_fusion_pass_manager.py - Attention Backend
vllm_ascend/attention/attention_v1.py - MLA Backend
vllm_ascend/attention/mla_v1.py - Sparse Attention Kernel
csrc/attention/kv_quant_sparse_flash_attention_vllm/op_kernel/kv_quant_sparse_flash_attention_vllm_service_vector_mla.h - Kernel Primitives
csrc/attention/common/op_kernel/matmul.h - Quantized MoE Kernel
csrc/gmm/grouped_matmul_swiglu_quant_v2/op_kernel/grouped_matmul_swiglu_quant_v2_a8w4_msd_pipeline.h
Distributed Runtime
- HCCL Weight Transfer
vllm_ascend/distributed/weight_transfer/hccl_engine.py - Packed Tensors
vllm_ascend/distributed/weight_transfer/packed_tensor.py - NPU IPC Transfer
vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py - MemFabric Transfer
vllm_ascend/distributed/kv_transfer/utils/memfabric_transfer_engine.py
Runtime Operations
- Encoder Cache
vllm_ascend/ec_manager/score_ec_manager.py - Runtime Guard
vllm_ascend/observability/runtime_guard/detector/manager.py - Guard Configuration
vllm_ascend/observability/runtime_config/config.py
Other components
- Inference Client
Connections 14
- Inference Client → Ascend Plugin: uses plugin
- Ascend Plugin → Ascend Worker: runs inference
- Batch Manager → Rotary Embedding: uses
vllm_ascend/worker/v2/pcp_manager.py - Batch Manager → Attention Utilities: uses
vllm_ascend/worker/v2/pcp_manager.py - Graph Fusion → Hardware Profile: checks capability
vllm_ascend/compilation/graph_fusion_pass_manager.py - Graph Fusion → Ascend Plugin: reads config
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
vllm_ascend/distributed/weight_transfer/hccl_engine.py - NPU IPC Transfer → Packed Tensors: uses
vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py - Runtime Guard → Guard Configuration: reads config
vllm_ascend/observability/runtime_guard/detector/manager.py - Engine Patches → Balance Scheduling: selects
vllm_ascend/patch/platform/patch_engine_core.py