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 Qwen 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, 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_outis the raw (pre-sigmoid) gate.
Source code in vllm/model_executor/layers/fused_qk_norm_rope.py
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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |