Skip to content

[https://nvbugs/6418103][fix] Clamp the post-allreduce quota by the pre-allreduce quota (`quota = min(quota… - #15991

Merged
jiaganc merged 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6418103
Jul 9, 2026
Merged

[https://nvbugs/6418103][fix] Clamp the post-allreduce quota by the pre-allreduce quota (`quota = min(quota…#15991
jiaganc merged 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6418103

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: _get_max_tokens_from_quota and _get_quota_from_max_tokens are not inverses when full_attn_size_per_token == 0 (all layers SWA per test's max_attention_window=[128, 32768]), so the intended cross-rank normalization inflates the KV cache GPU quota ~10× (115.83 → 1156.5 GiB) and cuMemCreate OOMs.
  • Fix: Clamp the post-allreduce quota by the pre-allreduce quota (quota = min(quota, _get_quota_from_max_tokens(max_tokens))) — allreduce(MIN) must never raise the local quota. Also remove the corresponding waiver from tests/integration/test_lists/waives.txt.
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Summary by CodeRabbit

  • Bug Fixes
    • Improved GPU memory quota calculation for cache management to better handle mixed layer configurations and avoid quota over-allocation.
    • Added safeguards so available token capacity is capped more conservatively, improving stability in edge cases.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 23a086b3-2373-4572-872c-cc3b6874ecec

📥 Commits

Reviewing files that changed from the base of the PR and between 011e849 and 87521a8.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
  • tests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt

📝 Walkthrough

Walkthrough

This PR modifies the GPU quota calculation in KVCacheManagerV2 to clamp quota using min() against a max-token-derived value, guarding against quota inflation when SWA layers dominate. A related test waiver entry is also removed from waives.txt.

Changes

KV Cache Quota Fix

Layer / File(s) Summary
Quota clamping and waiver cleanup
tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py, tests/integration/test_lists/waives.txt
Quota is now clamped via min(quota, _get_quota_from_max_tokens(max_tokens)) instead of direct assignment, with updated comments explaining SWA-related token/quota mismatch; the corresponding test skip entry is removed from the waiver list.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#15959: Both PRs modify tests/integration/test_lists/waives.txt to remove waiver entries for integration tests.
  • NVIDIA/TensorRT-LLM#15960: Directly relates to the same test_kv_cache_v2_nixl_python[cache_mgr_v2] waiver entry being removed here.

Suggested reviewers: yiqingy0, Superjomn, mzweilz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required ticket/type pattern and clearly summarizes the quota-clamping fix.
Description check ✅ Passed The description covers the issue, fix, test plan, and bug link, though the PR checklist section is omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@jiaganc jiaganc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@jiaganc jiaganc assigned jiaganc and unassigned Shixiaowei02 Jul 7, 2026
@jiaganc

jiaganc commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

@yizhang-nv Could you please review this PR?

@jiaganc

jiaganc commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57965 [ run ] triggered by Bot. Commit: 87521a8 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57965 [ run ] completed with state SUCCESS. Commit: 87521a8
/LLM/main/L0_MergeRequest_PR pipeline #46641 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

CI Agent Failure Analysis

Link to invocation

@jiaganc

jiaganc commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

/bot run

1 similar comment
@jiaganc

jiaganc commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58157 [ run ] triggered by Bot. Commit: 87521a8 Link to invocation

@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6418103 branch from 87521a8 to 03be757 Compare July 8, 2026 08:40
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58157 [ run ] completed with state SUCCESS. Commit: 87521a8
/LLM/main/L0_MergeRequest_PR pipeline #46808 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

CI Report

Link to invocation

@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6418103 branch from 03be757 to 5ddd0da Compare July 8, 2026 14:20
Comment thread tests/integration/test_lists/waives.txt
The token<->quota round-trip in KVCacheManagerV2.__init__ is not an
identity when SWA layers dominate the layer set (i.e.
full_attn_size_per_token == 0). For gpt-oss-120b disagg with
max_attention_window=[128, 32768], all layers are treated as SWA and
the reverse map inflates size_per_batch by max_batch_size, blowing
quota from 115.83 GiB up to 1156.5 GiB. cuMemCreate then fails with
CU_ERROR_OUT_OF_MEMORY.

allreduce(MIN) must never raise the local quota. Clamp the post-sync
value by the pre-sync value to preserve that invariant.

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6418103 branch from 5ddd0da to 95dbcc0 Compare July 8, 2026 14:25
@jiaganc

jiaganc commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58246 [ run ] triggered by Bot. Commit: 95dbcc0 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58246 [ run ] completed with state SUCCESS. Commit: 95dbcc0
/LLM/main/L0_MergeRequest_PR pipeline #46887 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

CI Agent Failure Analysis

Link to invocation

@jiaganc

jiaganc commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@jiaganc

jiaganc commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58356 [ run ] triggered by Bot. Commit: 95dbcc0 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58357 [ run ] triggered by Bot. Commit: 95dbcc0 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58356 [ run ] completed with state ABORTED. Commit: 95dbcc0

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58357 [ run ] completed with state SUCCESS. Commit: 95dbcc0
/LLM/main/L0_MergeRequest_PR pipeline #46981 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

CI Agent Failure Analysis

Link to invocation

@nvpohanh
nvpohanh requested a review from yizhang-nv July 9, 2026 06:29
@nvpohanh

nvpohanh commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

[by Codex] @yizhang-nv Could you review this PR? Thanks!

@jiaganc

jiaganc commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Wait for #16186 to waive tests before rerun pipeline.

@jiaganc

jiaganc commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

/bot run --extra-stage "DGX_B300-4_GPUs-PyTorch-Post-Merge-1"

@jiaganc
jiaganc enabled auto-merge (squash) July 9, 2026 15:40
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58484 [ run ] triggered by Bot. Commit: 95dbcc0 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #58484 [ run ] completed with state SUCCESS. Commit: 95dbcc0
/LLM/main/L0_MergeRequest_PR pipeline #47093 completed with status: 'SUCCESS'

CI Report

Link to invocation

@jiaganc
jiaganc merged commit 8e7b98c into NVIDIA:main Jul 9, 2026
8 checks passed
eopXD added a commit to eopXD/TensorRT-LLM that referenced this pull request Jul 10, 2026
The KV Cache Manager V2 quota-inflation OOM on multi-GPU VSWA (variable
sliding-window attention) configurations -- a regression from NVIDIA#15633 -- was
fixed on main by a parallel effort, NVIDIA#15991 (nvbugs/6418103), which clamps the
post-allreduce quota by the pre-allreduce quota so the cross-rank normalization
can only reduce, never over-commit. That fix landed without a test guarding the
V2 + VSWA path.

This change amends the missing coverage. Parametrize
TestGPTOSS::test_eagle3_vswa_reuse_4gpus over v2_kv_cache so the
previously-uncovered V2 path (GPT-OSS-120B, TP=4,
max_attention_window=[128, 32768], free_gpu_memory_fraction=0.4) runs and guards
against regressing the fix -- this variant OOM'd before NVIDIA#15991. The v2_kv_cache +
two-model combination is skipped (V2 is not compatible with two-model overlap
scheduling). Register the new variants in llm_function_core.txt and
llm_function_rtx6k.txt.

Signed-off-by: Yueh-Ting Chen <yuehtingc@nvidia.com>
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.

6 participants