[#15178][fix] Fix unified-memory Mamba KV estimation - #15215
peter941221 wants to merge 5 commits into
Conversation
Signed-off-by: peter941221 <peter941221@gmail.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: NVIDIA/TensorRT-LLM/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughKV-cache token estimation now ignores the fixed-cost intercept on integrated devices during provisional capacity calculation. A regression test verifies a 64-token estimate when the intercept exceeds available memory. ChangesIntegrated GPU KV-cache Estimation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change prevents integrated-GPU KV-cache estimation from collapsing to zero while preserving final sizing behavior; the supplied regression coverage leaves no merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
🧪 Generate unit tests (beta)
Comment |
|
Confirmed on hardware — this fixes #15178 for us. We applied this exact change on top of
Discrete-GPU (RTX Pro 6000) runs were never affected, consistent with the integrated-memory root cause. Thanks for the fix @peter941221 — would be great to land this. Happy to test a candidate build on DGX Spark if useful. cc @joyang-nv |
|
Thanks for testing this on DGX Spark and confirming that it fixes the rc18 unified-memory KV-cache failure while leaving the final affine sizing unchanged. |
|
@VALLIS-NERIA this seems to related to your #12896. Could you take a look? |
|
Hi @peter941221 , thank you for the fix. It looks good to me but I'm not quite clear about the cause. My understanding is: |
|
/bot run |
|
PR_Github #55449 [ run ] triggered by Bot. Commit: |
@VALLIS-NERIA Yes — on integrated/unified-memory devices, the dry-run sees a temporarily depressed |
|
PR_Github #55449 [ run ] completed with state
|
Signed-off-by: peter941221 <peter941221@gmail.com>
|
/bot run |
|
PR_Github #55471 [ run ] triggered by Bot. Commit: |
|
PR_Github #55471 [ run ] completed with state
|
|
The public GitHub checks are green on the current head. The remaining failure is the internal |
|
@peter941221 nice catch on the affine-intercept clamp. fyi #12301 is sitting in the same UMA-detection territory — different files (cpp kvCacheManager + llm_args.py) so no merge conflict, but same symptom (zero/negative caps on UMA) from a different angle. Forces host_cache_size=0 via cudaDevAttrIntegrated. Probably complementary with yours, worth looking at together if a reviewer picks one up. |
|
@mihai-chiorean |
|
@peter941221 can you maybe merge main / rebase so that we can try to get this finally merged. THX |
Signed-off-by: Peter Chen J. <peter941221@gmail.com>
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Merged the latest main into this branch in commit �fe52a0bd6. Resolved the _util.py import conflict by preserving both the current main imports and the integrated-device fix, and moved the regression coverage to the current ests/unittest/_torch/executor/kv_cache/test_kv_cache_estimation.py path. The diff against current main remains limited to the intended two files. The merge commit is GPG-signed and DCO-signed. |
|
Thanks @peter941221 for refreshing this PR! One follow-up for #15178: our testing on newer releases still encounters This PR addresses the provisional token-cap calculation in the V1 estimation path. With NemotronH using Could a KV-cache owner advise whether to cover V2 here or track it in a linked follow-up? It would be helpful to make that scope explicit while moving this fix toward merge. Happy to help validate a candidate on Spark. Thanks! Prepared with assistance from Codex (GPT-6). |
|
@peter941221 can you address the pre-commit ci failures? THX |
Signed-off-by: Peter Chen J. <peter941221@gmail.com>
|
Applied the pre-commit fix in d2f6f56. The only failing hook on the previous head was ruff-format; the formatted test file now passes the full pre-commit suite locally. Please trigger CI again on the new head. |
Description
Refs #15178.
On integrated GPUs, the estimation dry run can start from a
mem_get_info()budget that is already depressed by mmap-backed weights sharing the same physical memory pool.When hybrid Mamba models use an affine
CacheCost,_get_token_num_for_estimation()subtracts the recurrent-state intercept from that reduced budget and can clamp the provisional token cap to zero. That is enough to tripassert max_blocks_per_seq > 0in the attention-window path even though the later affine sizing still succeeds.This change keeps the final affine sizing unchanged. It only relaxes the provisional estimation cap on integrated GPUs by dropping the affine intercept from the dry-run budget calculation.
The regression test covers the zero-clamp case by mocking an affine
CacheCost, a smallmem_get_info()budget, and an integrated device.Test Coverage
Validated in the matching TensorRT-LLM 1.3.0rc18 CUDA 13 / PyTorch 2.10 runtime with:
python -m pytest tests/unittest/_torch/executor/test_kv_cache_estimation.py -k integrated_gpu_estimation_ignores_affine_intercept -qpython -m pytest tests/unittest/_torch/executor/test_kv_cache_estimation.py -qPR 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.Dev Engineer Review
CacheCostintercept only during provisional token-cap calculation.MambaHybridCacheManagerV2quota error.QA Engineer Review
tests/unittest/_torch/executor/kv_cache/test_kv_cache_estimation.py.test_integrated_gpu_estimation_ignores_affine_intercept().CacheCostintercept that exceeds the available budget.test-db/orqa/entry was found.Per-File QA Perspective
tensorrt_llm/_torch/pyexecutor/_util.py: Verify that only the provisional integrated-GPU calculation omits the intercept. Verify that final sizing and discrete-GPU behavior remain unchanged.tests/unittest/_torch/executor/kv_cache/test_kv_cache_estimation.py: Covers the integrated-GPU zero-token-clamp regression. No matchingtest-db/orqa/list entry was found.