vllm.compilation.passes.fusion.qk_norm_rope_fusion
¶
Classes:
-
QKNormRoPEFusionPass–Fuse Q/K RMSNorm + RoPE into fused_qk_norm_rope when the custom op exists.
-
QkNormRopePattern–Match the unfused sequence in attention blocks and replace with the fused op.
QKNormRoPEFusionPass
¶
Bases: VllmPatternMatcherPass
Fuse Q/K RMSNorm + RoPE into fused_qk_norm_rope when the custom op exists.
Registers patterns for both standard vLLM ops and ROCm AITER ops (when AITER is enabled), so the fusion fires regardless of which RMSNorm/RoPE implementation the graph uses.
QkNormRopePattern
¶
Match the unfused sequence in attention blocks and replace with the fused op.
Unfused (conceptually): q, k, v = split(qkv, [qsz, kvsz, kvsz], -1) qh = reshape(q, [-1, num_heads, head_dim]) kh = reshape(k, [-1, num_kv_heads, head_dim]) qn = rms_norm(qh, q_weight, eps) kn = rms_norm(kh, k_weight, eps) qf = reshape(qn, [-1, num_heads * head_dim]) kf = reshape(kn, [-1, num_kv_heads * head_dim]) qf, kf = rotary_embedding(positions, qf, kf, head_dim, cos_sin_cache, is_neox) return qf, kf, v
Fused replacement
fused_qk_norm_rope(qkv, num_heads, num_kv_heads, num_kv_heads, head_dim, eps, q_weight, k_weight, cos_sin_cache, is_neox, positions.view(-1)) return split(qkv, [qsz, kvsz, kvsz], -1)