Skip to content

vllm.model_executor.layers.mla

Classes:

MLAModules dataclass

Modules used in MLA.

MultiHeadLatentAttentionWrapper

Bases: PluggableLayer

Pluggable MLA layer which allows OOT backends to add custom implementations of the outer MLA layer (including rope & o_proj). Note that currently oot platforms can still use CustomOp.register_oot to replace MLA layer entirely, although we use PluggableLayer to register this layer now.

This class takes positions and hidden_states as input. The input tensors can either contain prefill tokens or decode tokens. The class does the following:

  1. MLA Preprocess.
  2. Perform multi-head attention to prefill tokens and multi-query attention to decode tokens separately.
  3. Return the output tensor.