[TRTLLM-12399][fix] Fix KV cache adaptive ratio sampling#13857
Conversation
|
/bot run --disable-fail-fast |
📝 WalkthroughWalkthroughThis PR refactors KVCacheManager's adjustment trigger logic from counting closed KV caches to counting sampled KV caches. _KVCache.close() conditionally updates sampling statistics only when capacity exceeds zero. StorageManager.ratio_from_length validates capacity constraints and enforces minimum block allocations per lifecycle. ChangesKV Cache Sampling-Based Adjustment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tensorrt_llm/runtime/kv_cache_manager_v2/_storage_manager.py`:
- Around line 730-732: The warnings.warn call in _storage_manager.py (the branch
checking if capacity < history_length) needs an explicit stacklevel to satisfy
Ruff B028; update the call to warnings.warn to pass stacklevel=2 (e.g.,
warnings.warn("Bad sampling for capacity and history_length", stacklevel=2)) so
the warning points to the caller rather than the warning site, leaving the
surrounding logic that sets capacity = history_length unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 5add0062-08d1-41d3-9f41-e37c3ad493ec
📒 Files selected for processing (3)
tensorrt_llm/runtime/kv_cache_manager_v2/_core/_kv_cache.pytensorrt_llm/runtime/kv_cache_manager_v2/_core/_kv_cache_manager.pytensorrt_llm/runtime/kv_cache_manager_v2/_storage_manager.py
|
PR_Github #47215 [ run ] triggered by Bot. Commit: |
|
PR_Github #47215 [ run ] completed with state
|
jiaganc
left a comment
There was a problem hiding this comment.
Approved with a nit comment.
|
/bot run --disable-fail-fast |
|
PR_Github #47376 [ run ] triggered by Bot. Commit: |
|
PR_Github #47376 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #47509 [ run ] triggered by Bot. Commit: |
|
PR_Github #47509 [ run ] completed with state
|
Signed-off-by: Yao Yao <lowsfer@users.noreply.github.com>
|
/bot run --disable-fail-fast |
|
PR_Github #47628 [ run ] triggered by Bot. Commit: |
|
PR_Github #47628 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #47824 [ run ] triggered by Bot. Commit: |
|
PR_Github #47824 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #47917 [ run ] triggered by Bot. Commit: |
|
PR_Github #47917 [ run ] completed with state |
Signed-off-by: Yao Yao <lowsfer@users.noreply.github.com>
Summary by CodeRabbit
Description
Test Coverage
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)
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.