vllm.v1.attention.backends.mla.cpu_mla
¶
CPU MLA backend.
This is a reference-quality MLA backend for the CPU platform. It is
intended to make DeepSeek-V2/V3 style models runnable on CPU (for
functional verification, tiny-model smoke tests and CI), not to be
performant. The prefill path is a plain PyTorch SDPA and the decode
path forwards to the existing CPU decode kernel
torch.ops._C.mla_decode_kvcache (see csrc/cpu/mla_decode.cpp).
Key design points:
- We inherit the shared MLA scaffolding (
MLACommonBackend,MLACommonImpl,MLACommonMetadata) so that the sameforward_implinMLAAttentionorchestrates weight-absorbed decode (MQA) and non-absorbed prefill (MHA) for us. - The parent
MLACommonImpl.__init__tries to pick a GPU prefill kernel (flash_attn / flashinfer / cudnn / trtllm) and raises when none of them are available. On CPU none of them apply, so we bypass that logic and set the attributes ourselves. - Chunked prefill and prefix caching are disabled by the CPU platform
when
use_mlais set. - The CPU decode kernel only supports
head_dim=576,v_head_dim=512andblock_size=16today; the platform layer forcesblock_size=16for MLA models.
Classes:
-
CPUMLABackend–Attention backend descriptor for CPU MLA.
-
CPUMLAImpl–CPU implementation of MLA attention.
CPUMLABackend
¶
CPUMLAImpl
¶
Bases: MLACommonImpl[MLACommonMetadata]
CPU implementation of MLA attention.
See module docstring for the overall design. This class only overrides the parts of the parent that would otherwise pull in CUDA-only dependencies.