Commit 9a2c39d
fix mamba metadata prefill bubble in chunked prefill serving
Three optimizations to eliminate GPU idle bubbles during prefill in
Mamba2Metadata.prepare() for hybrid GDN models (e.g. Qwen3.5):
1. Remove tl.constexpr from num_seqs and N in _cu_seqlens_triton_kernel.
Triton JIT recompiles for each unique constexpr value (~120ms each).
In serving, num_seqs varies every prefill step, causing repeated
recompilation. With dynamic parameters, only one compilation occurs.
2. Accept total_seqlens from caller to skip first GPU->CPU sync.
cu_seqlens[-1].item() blocked on all pending GPU work. The caller
(Mamba2Metadata.prepare) already has num_ctx_tokens on CPU.
3. Compute extra_chunks with pure Python arithmetic on CPU seq_lens
to eliminate the second GPU->CPU sync (cumsum + p[-1].item()).
Before: _prepare_inputs ~120-460ms per prefill step (Triton recompile +
GPU sync bubbles)
After: _prepare_inputs ~1-2ms steady state
Verified: 9200+ random equivalence tests + e2e serving assertion with
1000 requests (0 mismatches). GSM8K accuracy unchanged (90.07% on full
1319 samples).
Signed-off-by: Shijie Wang <jaywan@nvidia.com>1 parent 0b5c0e1 commit 9a2c39d
1 file changed
Lines changed: 35 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
72 | 82 | | |
73 | 83 | | |
74 | 84 | | |
| |||
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
80 | | - | |
| 90 | + | |
| 91 | + | |
81 | 92 | | |
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
87 | 98 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
| |||
282 | 294 | | |
283 | 295 | | |
284 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
285 | 307 | | |
286 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
287 | 312 | | |
288 | 313 | | |
289 | 314 | | |
| |||
0 commit comments