vllm.models.step5.nvidia.ops.swa_decode
¶
Sliding-window GQA decode with split KV and a fused headwise gate.
FA2 runs one CTA per query head and scans the whole window serially; its Python wrapper rejects split KV, and FA4 has no head_dim 192 on SM100. Here one program handles all query heads of a KV head (the GQA group) for one window split, and a combine kernel merges splits and applies the gate.
Functions:
-
swa_decode_gated–Decode rows of
query_lentokens per request over a causal window. -
swa_decode_plan–Return (pack, splits) for a decode batch.
-
swa_decode_splits–Split the window until (token, KV head) programs reach ~2 waves.
swa_decode_gated(query, key_cache, value_cache, block_table, seq_lens, gate, output, *, scale, window, query_len, splits, pack=1)
¶
Decode rows of query_len tokens per request over a causal window.
query/output: [tokens, heads, 192]; key_cache/value_cache:
[pages, block, kv_heads, 192] views; gate: [tokens, heads]. Rows of
requests with no visible keys (padding) produce zeros.
Source code in vllm/models/step5/nvidia/ops/swa_decode.py
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 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
swa_decode_plan(tokens, kv_heads, group, query_len, num_sms, window)
¶
Return (pack, splits) for a decode batch.
MTP verify tokens of a request are packed into one program when (token, KV head) programs already fill about a wave, since their windows overlap; the window is then split to fill the GPU.
Source code in vllm/models/step5/nvidia/ops/swa_decode.py
swa_decode_splits(programs, num_sms, window)
¶
Split the window until (token, KV head) programs reach ~2 waves.