Repository navigation
[https://nvbugs/6796296][fix] Pad DSv4 NVFP4 compressed FP8 scratch by one FMHA KV tile - #20119
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe DeepSeek V4 sparse attention backend now uses padded FP8 scratch storage for NVFP4 generation and context gathers. The related DeepSeek V4 Flash accuracy-test waiver was removed. ChangesDeepSeek V4 NVFP4 scratch handling
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to
|
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
|
/bot run --stage-list "DGX_B300-4_GPUs-PyTorch-1" |
|
PR_Github #77192 [ run ] triggered by Bot. Commit: |
|
PR_Github #77192 [ run ] completed with state
|
a4df3e8 to
89e4ebe
Compare
|
/bot run --stage-list "DGX_B300-4_GPUs-PyTorch-1" |
|
@heyuhhh, could you help to review this PR as trt-llm-torch-attention-devs? Thanks~ Assignment explanation
Affinity and workload are snapshots at selection, not live counters. Existing reservations on this PR are counted once. |
|
PR_Github #79540 [ run ] triggered by Bot. Commit: |
|
PR_Github #79540 [ run ] completed with state |
|
This test passed in post merge, see https://prod.blsm.nvidia.com/sw-tensorrt-top-1/blue/organizations/jenkins/LLM%2Fmain%2FL0_MergeRequest_PR/detail/L0_MergeRequest_PR/65498/tests, no need to run post merge again. |
|
/bot run |
|
/bot run --disable-fail-fast |
|
PR_Github #79605 [ run ] triggered by Bot. Commit: |
|
PR_Github #79606 [ run ] triggered by Bot. Commit: |
|
PR_Github #79605 [ run ] completed with state |
|
PR_Github #79606 [ run ] completed with state
|
…ch by one FMHA KV tile The trtllm-gen DSv4 dynamic sparse MLA FMHA reads its aux KV pool up to one KV tile (128 rows) past the rows named in the sparse indices. With FP8 KV the aux pool is the whole compressed KV pool, so those reads stay in bounds. With NVFP4 KV the aux pool is a per-call FP8 scratch sized to the batch, so the FMHA faults (CUDA 700, KVCM2 poisoned) whenever the caching allocator places that scratch at the end of a mapped segment. Placing every scratch at the end of its own VMM mapping makes the fault deterministic: the first 512-token context warmup faults on every rank, always at scratch row 128 of a 32-row ratio-128 scratch. Allocate the scratch with a zeroed tail of one KV tile in both the generation and context gather paths. Signed-off-by: peaceh <103117813+peaceh-nv@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…4_kv Signed-off-by: peaceh <103117813+peaceh-nv@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89e4ebe to
29dffe7
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #79842 [ run ] triggered by Bot. Commit: |
|
PR_Github #79842 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #80006 [ run ] triggered by Bot. Commit: |
|
PR_Github #80006 [ run ] completed with state |
Description
@coderabbitai summary
Description
Problem.
TestDeepSeekV4Flash::test_nvfp4_kv(DGX_B300-4_GPUs-PyTorch-1) fails intermittently with CUDA 700 (illegal memory access) /KVCM2 poisoned. It usually fails during generation CUDA graph warmup or at the start of GSM8K serving, in about 15% of local runs. It was waived in #19393.Root cause. The trtllm-gen DSv4 dynamic sparse MLA FMHA (
fmhaSm100fKernel_QkvE4m3...DenseDynamicTokenSparse...) reads its aux KV pool up to one KV tile (128 rows x 512 B = 64 KB) past the rows named in the sparse indices, for KV tiles >= 1 (the compressed part). Both the static generation variant and the persistent variant used for context do this. The auxpool is
aux_kv_cache_pool_ptr, whose TMA descriptortmaK_is built withINT_MAXrows.DeepseekV4TrtllmAttention.sparse_attn_predictdequantizes the selected compressed tokens into a per-call FP8 scratch sized to the batch (e.g. 32 rows = 16 KB for a ratio-128 context call) and passes it as the aux pool. When the caching allocator places that scratch at the end of a mapped segment, the over-read hits unmapped VA, which gives an MMUfault (Xid 31) and CUDA 700. Placement depends on allocator history, which is why the failure is intermittent. Syncing before the FMHA, disabling PDL, single-stream execution and fresh workers did not prevent it.
Evidence.
Fix. Allocate the NVFP4 compressed FP8 scratch with a zeroed tail of one FMHA KV tile (128 rows), in both the generation and the context gather paths (
_alloc_nvfp4_compress_fp8_scratch). The gather ops still see exactly the logical scratch shape. The cost is 64 KB per scratch and one small memset per layer call. The kernel-side over-read will be reported tothe trtllm-gen FMHA owners. It could in principle also reach past the end of the FP8 compressed pool; this PR only covers the NVFP4 scratch.
Also unwaives
accuracy/test_llm_api_pytorch.py::TestDeepSeekV4Flash::test_nvfp4_kv.Test Coverage
accuracy/test_llm_api_pytorch.py::TestDeepSeekV4Flash::test_nvfp4_kv(unwaived; DGX_B300-4_GPUs-PyTorch-1).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.