Skip to content

vllm.model_executor.layers.attention.prefill_prefix_lm_attention

Classes:

PrefillPrefixLMAttention

Bases: Attention

Decoder attention that runs non-causally (Prefix LM).

This reuses the encoder-only backend wrapper, which forces causal=False on every metadata build (prefill and decode alike), while keeping attn_type=DECODER so a KV cache is still allocated.

Effect by phase: - Prefill: query tokens attend to each other bidirectionally -- this is where the Prefix LM (non-causal) behavior actually takes effect. - Single-token decode: causal=False is a no-op. The one new query attends to the whole (frozen) KV cache exactly as a causal decode would, and cached tokens cannot attend back to it, so the output is identical to a causal decoder.