Skip to content

fix(dsv41): warm small prefill tails before serving - #1

Closed
JoelAHilliard wants to merge 1 commit into
bertholomus:deepseek-v41-tp2from
JoelAHilliard:fix/deepseek-prefill-tail-warmup
Closed

JoelAHilliard wants to merge 1 commit into
bertholomus:deepseek-v41-tp2from
JoelAHilliard:fix/deepseek-prefill-tail-warmup

Conversation

@JoelAHilliard

Copy link
Copy Markdown

With TF_DS_PREFILL_CHUNK=2048 and TF_DS_WARM_LENGTHS=1,17,33,131,514,1024,2113, a 20,493-token request can first load the 13-row prefill indexer kernel during serving. The observed deployment ran for about 15.5 hours before rank 0 failed at Triton load_binary with CUDA: operation not permitted; the lane then required restarting every rank.

Decode warmup does not cover this specialization: its indexer uses the fused rowmm_wts path, while prefill uses rowmm2 / _rowmm2r. Prompts shorter than a compression block can also skip the prefill indexer entirely. The failing request had 12,288 cached tokens and a 13-token final chunk (20493 % 2048).

This change adds every small row count and PREFILL_CHUNK + row_count to the configured warmup prompts, bounded by min(PREFILL_CHUNK, DECODE_ROWS). It preserves configured order, removes duplicates, retains the existing context/decode headroom check, and reports the number of eligible warmup prompts. TF_DS_WARM=0 retains its existing behavior. The second-chunk cases exercise the prefill indexer with compressed keys present.

The fix closes the verified warmup coverage gap. It does not establish the underlying cause of the intermittent CUDA 800 binary-load rejection. Isolated cold 13-row loading, cold loading inside graph capture, and preloaded graph replay all passed on the same hardware after unloading the model; graph capture alone did not reproduce the failure.

Validation receipt:

  • Regression tests invoke the real DsEngine.warm method with CPU doubles for CUDA, caches and forward calls. They cover serial/concurrent serving, the failing 13-row tail, custom chunk sizes and row bounds, deduplication, context headroom and the reported warmup count. Before: 8 failed, 3 passed. After: 11 passed.
  • Focused CUDA host checks including the new tests: 49 passed, 37 skipped, 2 subtests passed. New test file lint and git diff --check pass. The engine retains the same two baseline lint findings (UP035, SIM115); checking with those inherited findings excluded passes.
  • Broad host-suite attempt was interrupted after 434 passed, 126 skipped, 8 failed, 11 errors. This Linux host lacks MLX for several tests. An unchanged-base checkout reproduced the TUI snapshot failure, three CUDA tokenizer-fixture failures and all eleven affine-row setup errors (132 passed, 4 failed, 11 errors in that comparison). This is not a full-suite pass.

Environment: two DGX Sparks / NVIDIA GB10, TensorFold 0.6.6 at 808eb4a1090ca7b79173cc2c799de16da5f923e3, with the exact candidate engine file overlaid on both ranks. The base engine file is identical to this PR's parent 90b68e063a0b8bba59aaf13340ef16619e751195. PyTorch 2.13.0a0+9186a08b2c.nv26.07, Triton 3.7.1, CUDA 13.3; kernel driver 580.159.03, CUDA compatibility driver 610.43.02. The existing active-MTU RDMA patch was retained.

Checkpoint: Mia-AiLab/DeepSeek-V4.1-Flash-EXL3-2.9bpw revision 64ba41b6c916a587db06eae2e19b7845f7be6e6b; original DeepSeek Engram shards at 2cba9e42aa026125f3ed06c6d98c1db82f7ca027, with original vision gate biases. Serving: tensor parallel 2, context 262,144, parallel 4, MTP drafts 5, vision enabled, TF_DS_REPLAY=1, prefill chunk 2,048.

Full 2k/8k/16k/32k/64k prompt benchmarks, sustained decode performance measurements, and the full newer fork revision were not run. This change adds startup work; it does not change model arithmetic or the serving forward paths. The original long-uptime failure has not been reproduced after the fix.

Live GPU verification used the original seven configured warmup lengths and the exact candidate engine file on both ranks (SHA-256 ed2a0d72b10ddc0c485a86c81a2a928b405d8bbed32ea0b705a4a98369ff8895):

  • Each rank loaded 14 _rowmm2r variants during startup, including the exact previously failing binary (a514c90f155e9c3687cc40bc1964e36f25c27c8fe69e4802d9b3ae9c9f34a9ed), with zero _rowmm2r loads during serving throughout the probes below.
  • Token prompts of lengths 12946, 20493, 20491, 20484, 20495 and 20496 each generated eight tokens successfully. Synthetic IDs: [1000 + (i * 7919) % 60000 for i in range(n)]. The 20493-token request reused 12288 cached tokens, matching the observed failure's cache boundary.
  • Using tools/bench_concurrent.py request helpers and its public code/chat prompts, 16-token replies at temperatures 0 and 1 passed 10 drafted-vs-serial token-hash comparisons and 16 concurrent-vs-solo comparisons, with all four streams active. Hashes were present and explicitly compared, rather than accepting missing hashes as equal.
  • Chat and SSE smoke checks passed with the 262144 context and four-stream configuration.

Two single-run cold-prompt timing probes used distinct prefixes, one generated token and zero cached tokens:

Prompt tokens Before prefill seconds Candidate prefill seconds
8192 6.3947 6.9512
20480 14.2451 10.9265

These single-run probes are diagnostic checks, not a statistically controlled performance comparison.

@bertholomus

Copy link
Copy Markdown
Owner

Thank you @JoelAHilliard — a really careful catch. ELI5: a request whose last prefill chunk is 13 rows asks the GPU for a kernel size that was never loaded at warmup, so the first such request pays a cold load (in your log, a load crash that took the lane down).

We're not merging it right now: the repo is in maintenance mode and this changes serving behavior (extra warmup prompts), so we're only taking small fixes that leave existing behavior untouched. Your analysis of the gap — decode warms the fused path, prefill uses rowmm2/_rowmm2r, short prompts can skip the prefill indexer — will make this easy to pick up in a development window. Thanks again for the clean receipt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants