Skip to content

vllm.model_executor.models.transformers.fusers.qkv

QKV projection fuser: q(x), k(x), v(x) -> a fused qkv linear + split.

Classes:

  • QKVFuser –

    Fuser for the attention QKV pattern q(x), k(x), v(x).

QKVFuser dataclass

Bases: StackedFuser

Fuser for the attention QKV pattern q(x), k(x), v(x).

Methods:

  • update_forward –

    Replace q(x), k(x), v(x) with qkv(x).split(sizes, -1) in source.

  • validate –

    Shapes must be compatible for a single merged, head-sharded GEMM.

_get_qkv_nodes(graph, module) classmethod

Search graph for the QKV pattern q(x), k(x), v(x).

update_forward(module)

Replace q(x), k(x), v(x) with qkv(x).split(sizes, -1) in source.

A projection may be guarded by an existence check -- a self.<proj> is (not) None comparison (e.g. Gemma 4's v_proj) or a bare truthiness test -- which is folded to its constant value (see bypass_existence_guard). The calls may sit in different branches, so the fused GEMM is inserted before the earliest of them, in the innermost block that dominates all three.

validate(module, vllm_config)

Shapes must be compatible for a single merged, head-sharded GEMM.