Skip to content

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 same forward_impl in MLAAttention orchestrates 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_mla is set.
  • The CPU decode kernel only supports head_dim=576, v_head_dim=512 and block_size=16 today; the platform layer forces block_size=16 for MLA models.

Classes:

CPUMLABackend

Bases: MLACommonBackend

Attention backend descriptor for CPU MLA.

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.