Skip to content

[https://nvbugs/6013562][fix] fix kv cache allocation is double the budget for vswa + eagle#12855

Merged
dongfengy merged 1 commit intoNVIDIA:mainfrom
dongfengy:user/dongfengy/kvcachealloc
Apr 19, 2026
Merged

[https://nvbugs/6013562][fix] fix kv cache allocation is double the budget for vswa + eagle#12855
dongfengy merged 1 commit intoNVIDIA:mainfrom
dongfengy:user/dongfengy/kvcachealloc

Conversation

@dongfengy
Copy link
Copy Markdown
Collaborator

@dongfengy dongfengy commented Apr 8, 2026

…udget for vswa

Summary by CodeRabbit

  • Bug Fixes
    • Improved KV cache memory budget allocation for speculative decoding with draft models
    • Enhanced support for draft model configurations across different KV cache manager types

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.

@dongfengy dongfengy requested a review from a team as a code owner April 8, 2026 19:02
@dongfengy dongfengy requested a review from shaharmor98 April 8, 2026 19:02
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

The KvCacheCreator.build_managers() method extends KV-budget splitting logic to handle additional draft KV cache scenarios. For V1 KV cache managers with VSWA enabled, the method now applies budget splitting and temporarily overrides the KV cache configuration during draft manager creation. For two-model speculative decoding, a previous assertion is relaxed to gate only on KVCacheManagerV2.

Changes

Cohort / File(s) Summary
KV Cache Budget Splitting Logic
tensorrt_llm/_torch/pyexecutor/_util.py
Extended budget splitting to cover V1 VSWA with draft KV cache by introducing conditional gating on manager version and draft presence; relaxed two-model speculative decoding assertion to only apply for V2; added temporary budget override mechanism for draft cache manager creation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is mostly a template with placeholders; the Description and Test Coverage sections are empty, and the PR Checklist lacks substantive completion details. Provide a clear description of the issue and solution, list relevant test cases, and ensure all PR checklist items are properly addressed with specific details rather than only a checkbox mark.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix for KV cache allocation doubling budget for VSWA with Eagle, directly matching the main code change in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tensorrt_llm/_torch/pyexecutor/_util.py`:
- Around line 783-790: Resolve the draft manager class before mutating shared
budget and only override max_gpu_total_bytes when the draft manager is
V1-compatible; wrap the temporary override in try/finally to always restore the
original budget. Concretely: in the logic that decides draft_kv_cache_config
(the branch using self._kv_cache_manager_cls, is_vswa_enabled, and calling
_split_kv_cache_budget_for_draft()), first compute the class that would be used
for the draft (by invoking the same resolution used in
_create_kv_cache_manager() or otherwise deriving the draft manager class from
self._draft_model_engine), check whether that class is NOT a subclass of
KVCacheManagerV2, and only then set the shared
self._kv_cache_config.max_gpu_total_bytes override; perform the override inside
a try/finally so the original max_gpu_total_bytes is restored even if creating
the draft manager or computing draft_kv_cache_config raises. Apply the same
pattern to the other identical block handling draft budget (the second
occurrence referenced in the review).
🪄 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: Pro

Run ID: 087c7dc6-7041-4d8a-aced-1b58d18e9cbc

📥 Commits

Reviewing files that changed from the base of the PR and between 2fe39c1 and 5a5bfe2.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/pyexecutor/_util.py

Comment thread tensorrt_llm/_torch/pyexecutor/_util.py
@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42387 [ run ] triggered by Bot. Commit: 5a5bfe2 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42387 [ run ] completed with state SUCCESS. Commit: 5a5bfe2
/LLM/main/L0_MergeRequest_PR pipeline #33164 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy dongfengy force-pushed the user/dongfengy/kvcachealloc branch from 5a5bfe2 to ab9dafd Compare April 9, 2026 00:53
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42417 [ run ] triggered by Bot. Commit: ab9dafd Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42417 [ run ] completed with state SUCCESS. Commit: ab9dafd
/LLM/main/L0_MergeRequest_PR pipeline #33187 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy dongfengy force-pushed the user/dongfengy/kvcachealloc branch from ab9dafd to bc673b7 Compare April 9, 2026 05:43
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42474 [ run ] triggered by Bot. Commit: bc673b7 Link to invocation

@dongfengy dongfengy requested a review from mikeiovine April 9, 2026 06:21
@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42474 [ run ] completed with state SUCCESS. Commit: bc673b7
/LLM/main/L0_MergeRequest_PR pipeline #33228 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy dongfengy force-pushed the user/dongfengy/kvcachealloc branch 2 times, most recently from 5eadb9e to 240420f Compare April 9, 2026 18:43
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42567 [ run ] triggered by Bot. Commit: 240420f Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42567 [ run ] completed with state SUCCESS. Commit: 240420f
/LLM/main/L0_MergeRequest_PR pipeline #33300 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42587 [ run ] triggered by Bot. Commit: 240420f Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42587 [ run ] completed with state SUCCESS. Commit: 240420f
/LLM/main/L0_MergeRequest_PR pipeline #33313 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy dongfengy force-pushed the user/dongfengy/kvcachealloc branch from 240420f to a52ea30 Compare April 10, 2026 17:55
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

1 similar comment
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42734 [ run ] triggered by Bot. Commit: a52ea30 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43594 [ run ] completed with state SUCCESS. Commit: 153ca92
/LLM/main/L0_MergeRequest_PR pipeline #34087 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy dongfengy force-pushed the user/dongfengy/kvcachealloc branch from 153ca92 to 8fcdfda Compare April 16, 2026 05:18
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43659 [ run ] triggered by Bot. Commit: 8fcdfda Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43659 [ run ] completed with state FAILURE. Commit: 8fcdfda
/LLM/main/L0_MergeRequest_PR pipeline #34146 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

1 similar comment
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43670 [ run ] triggered by Bot. Commit: 8fcdfda Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43670 [ run ] completed with state FAILURE. Commit: 8fcdfda
/LLM/main/L0_MergeRequest_PR pipeline #34156 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy dongfengy force-pushed the user/dongfengy/kvcachealloc branch from 8fcdfda to fb6184c Compare April 16, 2026 15:03
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43788 [ run ] triggered by Bot. Commit: fb6184c Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43788 [ run ] completed with state FAILURE. Commit: fb6184c
/LLM/main/L0_MergeRequest_PR pipeline #34269 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43834 [ run ] triggered by Bot. Commit: fb6184c Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43834 [ run ] completed with state FAILURE. Commit: fb6184c
/LLM/main/L0_MergeRequest_PR pipeline #34301 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy dongfengy force-pushed the user/dongfengy/kvcachealloc branch from fb6184c to e40f8ef Compare April 17, 2026 03:31
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43936 [ run ] triggered by Bot. Commit: e40f8ef Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #43936 [ run ] completed with state FAILURE. Commit: e40f8ef
/LLM/main/L0_MergeRequest_PR pipeline #34383 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

…udget for vswa

Signed-off-by: Dongfeng Yu <dongfengy@nvidia.com>
@dongfengy dongfengy force-pushed the user/dongfengy/kvcachealloc branch from e40f8ef to 6f7432c Compare April 17, 2026 14:46
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

1 similar comment
@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44045 [ run ] triggered by Bot. Commit: 6f7432c Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44045 [ run ] completed with state FAILURE. Commit: 6f7432c
/LLM/main/L0_MergeRequest_PR pipeline #34481 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@dongfengy
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44134 [ run ] triggered by Bot. Commit: 6f7432c Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #44134 [ run ] completed with state SUCCESS. Commit: 6f7432c
/LLM/main/L0_MergeRequest_PR pipeline #34561 completed with status: 'SUCCESS'

CI Report

Link to invocation

@dongfengy dongfengy merged commit fc9d130 into NVIDIA:main Apr 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants