Repository navigation
Commit 96c0b0e
perf: Flash Next CUDA prefill runs the head on the final chunk only
From #40, which made Flash Next prefill on CUDA about 7x faster than v0.3.4.1, byte-exact. There, prompts
prefilled through the decode kernels in 64-row chunks at 128-145 tok/s on one DGX Spark, and most of that
time was work whose results were never used:
- expert kernels: a member tile with no rows returns before reading its expert, and member tiles are the
fastest grid axis, so one expert's tiles share its weights in L2
- attention: partials and grid sized for the 2,051 keys a QSA row can read instead of the capacity;
programs past a row's keys or complete blocks return
- prefill computes the head only on the prompt's last chunk
- 1,024-row prefill chunks; above 64 rows the distinct experts are grouped by a stable sort
- member-list widths above 16 rows rounded up to a power of two, and the prefill kernels compiled at start
Against v0.3.4.1 on one Spark at a 131,072-token capacity: 8k prompts 142 -> 1,008 tok/s, 32k 132 -> 993,
120k ~123 -> 914; through the server, a 7.7k-token prompt's first token after 7.9 s instead of 53.6 s.
0.3.5 reworked this path: 2,048-row prompt chunks, shared CUDA expert and matmul prefill kernels that
launch only populated member tiles, attention partials capped at the keys a row reads, and expert grouping
on the device. This commit keeps the change that still lands on it: the head runs on the final chunk
alone. Its test checks that any chunking of a prompt past the sparse attention budget gives the one-chunk
prefill's first token and state bit for bit. The start-up compile is ported separately for the current
prompt kernels.1 parent 6ed268b commit 96c0b0e
2 files changed
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
266 | 270 | | |
267 | 271 | | |
268 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
0 commit comments