Skip to content

[https://nvbugs/6525011][fix] Store the owning output tensor in _graph_output_refs for each graph's lifetime… - #17010

Open
trtllm-agent wants to merge 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6525011
Open

[https://nvbugs/6525011][fix] Store the owning output tensor in _graph_output_refs for each graph's lifetime…#17010
trtllm-agent wants to merge 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6525011

Conversation

@trtllm-agent

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

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: capture() kept the graph output only as a non-owning weak ref, so its storage was free while the graph stayed replayable, letting a shared-graph-pool allocation land on top of a live graph's output.
  • Fix: Store the owning output tensor in _graph_output_refs for each graph's lifetime in both runners, cleared in clear() before graph.reset() so buffers drain into a still-live pool; callers still get the weak ref.
  • 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

Dev Engineer Review

  • Fixed CUDA graph output lifetime in both CUDAGraphRunner and EncoderCUDAGraphRunner by introducing _graph_output_refs: Dict[graph_key, Any] to hold strong references to capture-time outputs for each graph’s replayable lifetime.
  • Preserved existing weak-reference behavior for callers (graph_outputs continues to store weak refs), while ensuring the underlying storage cannot be returned to/reused by the shared CUDA graph memory pool prematurely.
  • Updated clear() to clear _graph_output_refs before resetting captured graphs and releasing the memory pool, preventing allocator/use-count-related failures.

QA Engineer Review

  • Updated tests/integration/test_lists/waives.txt:
    • Removed SKIP waivers for multiple DeepSeekV3Lite bfloat16/nvfp4 configurations and several cute_dsl_nvfp4_4gpus variants across full:* targets.
    • Removed full:B200/accuracy/test_llm_api_pytorch.py::TestLagunaXS::test_fp8 (nvbugs 6525011).
    • Removed additional waivers including full:DGX_H100/unittest/scaffolding (nvbugs 6529626) and full:L40S/accuracy/test_llm_api_pytorch.py::TestQwen3_30B_A3B::test_fp8[latency-torch_compile=True] (nvbugs 6276841).
    • Added new SKIP waivers for:
      • TestNemotronV3Ultra/TestQwen3NextInstruct and TestQwen3_5_397B_A17B nvfp4/bf16 variants,
      • examples/visual_gen WAN22 LPIPS (single- and multi-GPU),
      • H100 TestQwen3_30B_A3B_Instruct softmax-skip,
      • H20 MoE multi-Lora cudagraph,
      • perf/test_perf_sanity.py fp4 dep8/mmtp/tp4 scenarios (Qwen3_5_397B),
      • unittest/_torch/speculative/hw_agnostic/test_dflash.py Qwen3_5_4b waivers (both parameterizations).
  • No test-db/ or qa/ files were modified.
  • Verdict: needs follow-up (CBTS coverage data not provided).

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

CUDA graph runners now retain captured decoder and encoder outputs until graph cleanup. The integration waiver list removes obsolete skips and adds skips for additional model, hardware, performance, visual-generation, and speculative-decoding configurations.

Changes

CUDA graph output lifetime and integration waiver updates

Layer / File(s) Summary
Retain captured graph outputs
tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py
Both graph runners store capture-time outputs in strong-reference dictionaries alongside existing weak-reference tracking.
Release outputs during graph cleanup
tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py
Cleanup clears strong output references before resetting graphs and releasing CUDA graph pools.
Update integration test waivers
tests/integration/test_lists/waives.txt
Removes obsolete skip entries and adds skips for newly covered test configurations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: qijune, schetlur-nv, bowenfu, niukuo, allisonlim-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is specific, concise, and accurately reflects the main CUDA graph lifetime fix with the linked bug ID.
Description check ✅ Passed The description clearly summarizes the root cause, fix, test plan, and bug link, so it mostly matches the required template.
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py (1)

142-145: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid Any in both strong-reference dictionaries.

These maps only retain captured outputs and do not inspect their values; use object or a precise output type alias at both sites.

  • tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py#L142-L145: replace Any in _graph_output_refs.
  • tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py#L769-L770: apply the same non-Any annotation to the encoder runner.
🤖 Prompt for 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.

In `@tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py` around lines 142 - 145,
Replace the Any value annotations in both strong-reference dictionaries with
object or an appropriate precise output type: update _graph_output_refs at
tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py:142-145 and the encoder
runner dictionary at
tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py:769-770. Keep the existing
key types and retention behavior unchanged.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py`:
- Around line 142-145: Replace the Any value annotations in both
strong-reference dictionaries with object or an appropriate precise output type:
update _graph_output_refs at
tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py:142-145 and the encoder
runner dictionary at
tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py:769-770. Keep the existing
key types and retention behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a4af3cf6-a7f9-44fe-9e52-9d6fb212ecfb

📥 Commits

Reviewing files that changed from the base of the PR and between 2e1a997 and 92a4844.

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

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62569 [ run ] triggered by Bot. Commit: 92a4844 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62569 [ run ] completed with state SUCCESS. Commit: 92a4844
/LLM/main/L0_MergeRequest_PR pipeline #50713 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

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62585 [ run ] triggered by Bot. Commit: 92a4844 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62585 [ run ] completed with state FAILURE. Commit: 92a4844
/LLM/main/L0_MergeRequest_PR pipeline #50727 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

HandongLi-01 and others added 2 commits July 30, 2026 01:32
… outputs

CUDAGraphRunner.capture() retained the captured output only through
make_weak_ref, which is a non-owning pointer/shape view. The output
storage was therefore free the instant capture() returned, even though
the graph stayed replayable and its kernels still wrote to those
addresses. Any allocation on the shared graph pool could then be placed
on top of a live graph's output -- including the persistent, graph-read
workspaces Buffers.get_buffer takes from get_shared_pool() -- surfacing
as an illegal memory access at graph.replay() during generation CUDA
graph capture on B200.

Hold the output tensors for the lifetime of each graph and release them
in clear() before the graphs and their pool are torn down, so the
buffers drain into a still-live pool. Callers still receive the weak
reference, so the graph output contract is unchanged. This restores the
same ownership invariant visual_gen/cuda_graph_runner.py already keeps.

The retained buffers scale with (number of captured graph shapes x
output size), and are allocated during the KV-cache estimation dry run,
so they are accounted for in the profiled peak rather than escaping it:
peak moved 36.70 -> 36.89 GiB and estimated KV cache 128.04 -> 127.87
GiB on this config. Large-vocab, large-max-batch models will see a
proportionally larger shift.

Unwaives B200 TestLagunaXS::test_fp8. That test is not in l0_b200.yml
(only test_nvfp4 is; test_fp8 lives in qa/llm_function_core.txt), so
unwaiving does not restore it to pre-merge CI. Verified directly on a
B200: TestLagunaXS::test_fp8 passes (GSM8K 84.344 vs threshold 83.947)
and TestLagunaXS_2_1::test_bf16_dflash passes (87.718 vs 87.000).

Signed-off-by: handongl <handongl@nvidia.com>
Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6525011 branch from 92a4844 to a34f87d Compare July 30, 2026 08:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/integration/test_lists/waives.txt (1)

37-37: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Confirm every waiver is backed by a failed test before merging.

Test coverage summary:

  • Modified list: tests/integration/test_lists/waives.txt.
  • Added 17 SKIP entries across accuracy, visual-generation, performance, H20 LoRA, and speculative-decoding tests.
  • Removed 8 existing SKIP entries.
  • No test functions changed, and no test-db/ or qa/ list files were modified.
  • Coverage verdict: needs follow-up because neither cbts_touchmap.sqlite nor a CBTS coverage report is provided.

Given the two failed L0 pipelines, verify that each new waiver corresponds to an observed failure; otherwise these broad additions may mask regressions. Also split entries unrelated to the CUDA graph fix into a separate waiver update if they are not caused by this PR.

Also applies to: 58-58, 88-96, 139-141, 150-152, 174-175, 194-194, 217-217, 235-235, 252-252, 337-339, 367-368

🤖 Prompt for 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.

In `@tests/integration/test_lists/waives.txt` at line 37, Verify every newly added
SKIP entry in tests/integration/test_lists/waives.txt against a corresponding
failed L0 test, and remove any waiver without observed failure evidence.
Separate waivers unrelated to the CUDA graph fix into an independent update,
preserving only entries caused by this PR.

Source: Path instructions

🤖 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.

Nitpick comments:
In `@tests/integration/test_lists/waives.txt`:
- Line 37: Verify every newly added SKIP entry in
tests/integration/test_lists/waives.txt against a corresponding failed L0 test,
and remove any waiver without observed failure evidence. Separate waivers
unrelated to the CUDA graph fix into an independent update, preserving only
entries caused by this PR.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9cae8f57-7dda-4187-a4e0-1be57636a832

📥 Commits

Reviewing files that changed from the base of the PR and between 92a4844 and a34f87d.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py
  • tests/integration/test_lists/waives.txt

@fredricz-20070104 fredricz-20070104 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.

Review summary - Approve

Reviewed the full diff; no blocking or major issues found.

Minor, non-blocking notes:

  • tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py: Any annotation on strong-ref dicts
  • tensorrt_llm/_torch/pyexecutor/cuda_graph_runner.py: No per-key cleanup of _graph_output_refs on graph eviction/recapture

Automated review by NVCortex Lite, run by @fredricz-20070104.

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62763 [ run ] triggered by Bot. Commit: a34f87d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62763 [ run ] completed with state SUCCESS. Commit: a34f87d
/LLM/main/L0_MergeRequest_PR pipeline #50894 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

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62772 [ run ] triggered by Bot. Commit: a34f87d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62772 [ run ] completed with state SUCCESS. Commit: a34f87d
/LLM/main/L0_MergeRequest_PR pipeline #50901 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

@DomBrown

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62809 [ run ] triggered by Bot. Commit: a34f87d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #62809 [ run ] completed with state SUCCESS. Commit: a34f87d
/LLM/main/L0_MergeRequest_PR pipeline #50934 completed with status: 'SUCCESS'

CI Report

Link to invocation

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.

7 participants