[#15178][fix] Fix unified-memory Mamba KV estimation - #15215
Conversation
Signed-off-by: peter941221 <peter941221@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR fixes KV-cache token estimation on integrated/unified-memory GPUs by importing a device detection utility and conditionally zeroing the affine cost intercept during dry-run sizing, preventing token-cap collapse. A regression test validates the fix. ChangesKV-cache Estimation for Integrated GPUs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
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.Summary by CodeRabbit
Bug Fixes
Tests