Skip to content

vllm.model_executor.layers.fused_qk_norm_rope

Fused QK-RMSNorm + (partial) RoPE + gate copy Triton kernel.

Currently used by the Qwen3.5 attention path (attn_output_gate with NeoX-style partial RoPE). The unfused reference sequence is split -> GemmaRMSNorm -> RoPE -> gate chunk; this collapses it into a single Triton launch. See fused_qk_rmsnorm_rope_gate.

Functions:

fused_qk_rmsnorm_rope_gate(q_gate, k, q_weight, k_weight, cos_sin_cache, positions, eps, num_q_heads, num_kv_heads, head_dim, rotary_dim, mrope_section=None, norm_beta=0.0)

Fused split + QK-RMSNorm + (partial) RoPE + gate copy for Qwen attn.

Parameters:

  • q_gate

    (Tensor) –

    (n_tokens, num_q_heads * 2 * head_dim) -- per head: [q|gate]

  • k

    (Tensor) –

    (n_tokens, num_kv_heads * head_dim)

  • q_weight

    (Tensor) –

    (head_dim,) RMSNorm weight

  • k_weight

    (Tensor) –

    (head_dim,) RMSNorm weight

  • cos_sin_cache

    (Tensor) –

    (max_pos, rotary_dim) packed [cos|sin]

  • positions

    (Tensor) –

    (n_tokens,) or (3, n_tokens) int32 or int64

  • eps

    (float) –

    RMSNorm epsilon

  • num_q_heads

    (int) –

    number of Q heads (after TP split)

  • num_kv_heads

    (int) –

    number of KV heads (after TP split)

  • head_dim

    (int) –

    per-head dimension

  • rotary_dim

    (int) –

    rotary dimension; must be even and <= head_dim

  • mrope_section

    (list[int] | tuple[int, int, int] | None, default: None ) –

    interleaved T/H/W frequency counts for 2D positions

  • norm_beta

    (float, default: 0.0 ) –

    scalar added to the RMSNorm weight

Returns:

  • Tensor –

    (q_out, k_out, gate_out) -- all contiguous (n_tokens, heads * head_dim).

  • Tensor –

    gate_out is the raw (pre-sigmoid) gate.