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 :func:fused_qk_rmsnorm_rope_gate.
Functions:
-
fused_qk_rmsnorm_rope_gate–Fused split + QK-RMSNorm + (partial) RoPE + gate copy for Qwen3.5 attn.
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) ¶
Fused split + QK-RMSNorm + (partial) RoPE + gate copy for Qwen3.5 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,) GemmaRMSNorm effective weight (already +1)
-
(k_weight¶Tensor) –(head_dim,) GemmaRMSNorm effective weight (already +1)
-
(cos_sin_cache¶Tensor) –(max_pos, rotary_dim) packed [cos|sin]
-
(positions¶Tensor) –(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
Returns:
-
Tensor–(q_out, k_out, gate_out) -- all contiguous (n_tokens, heads * head_dim).
-
Tensor–gate_outis the raw (pre-sigmoid) gate.
Source code in vllm/model_executor/layers/fused_qk_norm_rope.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |