[None][feat] Page the DSpark drafter context through the draft KV cache manager - #18343
Conversation
ab3b1c0 to
6f5df55
Compare
bd30278 to
3c6afb9
Compare
…he manager The standalone drafter kept a private context arena, dense in max_seq_len and allocated after the KV pool had been carved, so free_gpu_memory_fraction never bounded it: at max_seq_len 997696 with max_batch 8 it wants 21.4 GiB/rank and the worker cannot start. Read the already-funded draft pool through the manager's per-request block tables instead, so the footprint follows the sequences served, and size what remains from max_seq_len rather than the drafter's advertised max_position_embeddings (1048576 for K3, hundreds of GiB on its own). The pool index space differs between the V1 and V2 managers, so the block-table divisor is derived from stride(0) rather than assumed. Three gates kept an external drafter off that path, each written for a mode it does not describe: - attention DP: the bail suits MTP, whose draft layers are target-shaped and appendable to the target pool. An external drafter has its own architecture, so nothing is appended and it stayed on the arena -- which under attention DP is sized with KV heads unsharded (20480 vs 2560 B/token for K3). - disaggregation: nvbugs/5807902 reported an Eagle3 RMSNorm failure and was worked around by disabling the separate draft KV cache for every speculative mode. Keep the workaround where it was reported. - disagg slot allocation: _store_prefill_context was the only place that assigned a drafter slot, so a generation worker -- which receives prompt KV instead of prefilling -- collapsed every concurrent request onto the single dummy slot. A context-only worker also releases the target's IndexMapper slot after prefill; the draft mirror never got that call and saturated. Accuracy cannot detect a broken drafter: speculative decoding is lossless, so one producing garbage scores the same and only runs slower. The added test therefore asserts on acceptance length. That is not hypothetical -- the slot collapse showed up as AL 1.087 vs 3.441 (decode steps 123860 -> 39072 for the same output length) while every accuracy gate passed. Signed-off-by: Zhenhuan Chen <zhenhuanc@nvidia.com>
6a4e7b0 to
43befee
Compare
|
/bot run --stage-list "GB300-8_GPUs-2_Nodes-PyTorch-SingleNvlinkDomain-Post-Merge-1" |
|
PR_Github #71928 [ run ] triggered by Bot. Commit: |
|
PR_Github #71928 [ run ] completed with state |
|
/bot run |
|
PR_Github #71946 [ run ] triggered by Bot. Commit: |
|
PR_Github #71946 [ run ] completed with state
|
|
/bot run |
|
PR_Github #71982 [ run ] triggered by Bot. Commit: |
|
PR_Github #71982 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #71993 [ run ] triggered by Bot. Commit: |
|
PR_Github #71993 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #72008 [ run ] triggered by Bot. Commit: |
|
PR_Github #72008 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #72131 [ run ] triggered by Bot. Commit: |
|
PR_Github #72131 [ run ] completed with state |
brnguyen2
left a comment
There was a problem hiding this comment.
Approving — the comments below are optional touch-ups, not blockers.
The [None] ticket slot: this is a nontrivial feature (new paging path through the draft KV manager, three gate carve-outs, a new post-merge test) — it should carry a TRTLLM JIRA so the K3 DSpark memory work is traceable.
Two coverage notes, neither blocking:
- The
_util.pyattention-DP carve-out means attention DP + standalone drafter now builds a separate draft manager for the first time, but the new CI test runsenable_attention_dp=Falseand the DEP4 run cited in the description was manual. If a cheap config exists that exercises DP + DSpark with the draft manager bound, it would pin theATTENTION_DP_DUMMY_REQUEST_IDhandling inprepare()and_mirror_draft_kv_cache. - The divisor-from-stride heuristic in
_init_ctx_block_tablesis the piece most likely to silently regress when a manager changes its pool layout (your own description notes wrong-guess = ~20% acceptance, no error). Themin_algate in the new test is the only tripwire; worth a one-line comment in the V1/V2get_buffersimplementations pointing back at this consumer so a layout change reviews against it.
Description matches the diff closely, including the limitation notes.
…om the coordinator send path Follows NVIDIA#18343, whose change landed in the method this PR moved. Signed-off-by: Tingfeng Xian <289617005+nv-xtf@users.noreply.github.com>
…om the coordinator send path Follows NVIDIA#18343, whose change landed in the method this PR moved. Signed-off-by: Tingfeng Xian <289617005+nv-xtf@users.noreply.github.com>
…om the coordinator send path Follows NVIDIA#18343, whose change landed in the method this PR moved. Signed-off-by: Tingfeng Xian <289617005+nv-xtf@users.noreply.github.com>
…om the coordinator send path Follows NVIDIA#18343, whose change landed in the method this PR moved. Signed-off-by: Tingfeng Xian <289617005+nv-xtf@users.noreply.github.com>
Upstream's NVIDIA#18343 clamps to the block-table width and drops _ctx_block_counts, which the MLA port's read-length truncation consumes -- so the managed-pool generation path raised AttributeError. Restore the count and bound both writes. Signed-off-by: Zhenhuan Chen <zhenhuanc@nvidia.com>
Description
The standalone DSpark/DFlash drafter kept its context KV in a private arena: dense in
max_seq_len, allocated after the KV pool was carved (sofree_gpu_memory_fractionnever bounded it), and sized frommax_position_embeddings(1048576 for K3). This pages it through the draft KV cache manager's per-request block tables instead.max_seq_lenmax_position_embeddingsmax_seq_lenThree gates kept an external drafter off that path, each written for a mode it does not describe:
_util.pyattention-DP bailpy_executor_creator.pynvbugs/5807902 WARTrue); standalone drafters exemptdflash.pyslot assignmentrelease_index_slotmirrored to the draft managerV1
get_buffers()returns a per-layer strided slice, V2 a dense view over interleaved pages, so the block-table divisor is derived fromstride(0). Guessing wrong is silent: ~20% acceptance, no error.Test Coverage
TestKimiK3DSpark::test_gsm8k_tep8, on the 2x4 GB300 post-merge stage from #18363 (l0_gb300_multi_nodes_node2_gpu8.yml). ItsSingleNvlinkDomainname forces--segment=2; straddling two NVL domains dies insymm_mem.rendezvous.Spec dec is lossless, so accuracy cannot detect a broken drafter — hence the AL assertion. That is how the slot collapse was found:
Measured on this branch, 8x GB300, 1319 samples, three runs. Target is the NVFP4 requant (nothing else covers K3 NVFP4 end to end), which also fixes the MoE backend: trtllm-gen ships SiTu cubins only for
W4A8_MXFP4_MXFP8.Not about this change, but this is the first real-model accuracy data on
MEGAMOE_CUTEDSL: it lands ~1.0 pt below CUTLASS on identical weights and is not reproducible across greedy runs (0.23 pt spread). AL is flat at 4.32-4.36 across all three, which is what this PR guards. The gsm8k reference stays at 96.5 so the kernel gap is not baked in; the hypothesis-testing threshold (93.297) absorbs it.min_al4.0: a collapse scores 1.09 with every accuracy gate green. AL figures of 5.2-5.9 quoted elsewhere are--apply_chat_templateruns (3.81 plain vs 5.52-5.88 chat, same drafter and samples).Also green on the embedded DSpark path (DeepSeek-V4-Pro DEP4 cutedsl, AL 4.436) — different drafter shape, same shared
kv_cache_manager_v2/py_executorcode.The drafter checkpoint is
RadixArk-Kimi-K3-DSparkon the CI model share (llm-models!596, merged; RadixArk and Inferact both publish a repo namedKimi-K3-DSpark, so both carry their vendor).Not covered: the VANILLA drafter attention backend still uses contiguous
flash_attn_with_kvcache.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.