[https://nvbugs/6546909][fix] Make the handle's lifetime match its graphs — lazy… - #17313
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe GB300 skip waiver is removed for the Llama 3.1 8B FP8 integration test configuration using ChangesIntegration test waiver update
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tensorrt_llm/_torch/compilation/backend.py (1)
124-138: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd docstrings for the graph-pool lifecycle methods.
get_graph_pool_handle()andretire_graph_pool_handle()are used across module boundaries. Replace the implementation comments with Google-style docstrings that define their lifecycle contract.🤖 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/compilation/backend.py` around lines 124 - 138, Replace the inline comments in get_graph_pool_handle() and retire_graph_pool_handle() with Google-style docstrings documenting lazy handle creation, replacement after retirement, and the requirement to retire only after captured graphs are reset. Preserve the existing implementation behavior.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/compilation/backend.py`:
- Around line 124-138: Replace the inline comments in get_graph_pool_handle()
and retire_graph_pool_handle() with Google-style docstrings documenting lazy
handle creation, replacement after retirement, and the requirement to retire
only after captured graphs are reset. Preserve the existing implementation
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0b58bdab-da34-4805-bbb4-fc4b75c759e0
📒 Files selected for processing (3)
tensorrt_llm/_torch/compilation/backend.pytensorrt_llm/_torch/pyexecutor/model_engine.pytests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
- tests/integration/test_lists/waives.txt
brnguyen2
left a comment
There was a problem hiding this comment.
Root cause analysis looks right, but the retirement is at the wrong granularity. Backend._graph_pool_handle is class-level and shared by every Backend/PyTorchModelEngine in the process, while retire_graph_pool_handle() is called from a per-engine _release_cuda_graphs(). If two engines coexist (e.g. draft + target model for spec decoding, or an encoder engine), tearing down one nulls the handle that the other's still-live graphs were captured into; the next capture in the surviving engine mints a fresh pool and silently loses memory sharing, and any code still holding the old handle in _cuda_graph_mem_pool passes a retired pool to capture_begin — the exact assert this PR fixes.
Either refcount the handle (number of engines that took it) and retire on the last release, or move the handle to per-Backend-instance state.
Also: the description says self._cuda_graph_mem_pool is nulled, but the diff never does that. And there's no regression test for the build → shutdown → rebuild sequence, which is the whole failure mode; the unwaived integration test only covers a single-engine run.
9a4ea0a to
55ddcea
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
737ce9a to
c4e6599
Compare
|
The current diff only removes the waiver. The |
c4e6599 to
d45008f
Compare
bac49d7 to
65a889e
Compare
|
/bot run |
|
PR_Github #68845 [ run ] triggered by Bot. Commit: |
|
PR_Github #68845 [ run ] completed with state |
|
/bot run |
|
PR_Github #68874 [ run ] triggered by Bot. Commit: |
…eleased Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
Head branch was pushed to by a user without write access
0e2c03f to
a2d4fb0
Compare
|
PR_Github #68874 [ run ] completed with state |
|
/bot run |
|
PR_Github #68913 [ run ] triggered by Bot. Commit: |
|
PR_Github #68913 [ run ] completed with state |
Summary
Backend._graph_pool_handleis a process-wide class attribute never retired when_release_cuda_graphs()resets the graphs captured into it, so a later engine in the same reused MPI worker passes the now-dead private pool tocapture_beginand trips the allocator'suse_count > 0assert.Backend.get_graph_pool_handle()plusBackend.retire_graph_pool_handle()invoked at the end of_release_cuda_graphs()(also nullingself._cuda_graph_mem_pool), so the next capture generation mints a fresh handle; removed the obsolete waiver.pytest "tests/integration/defs/accuracy/test_llm_api_pytorch.py::TestLlama3_1_8BInstruct::test_fp8[fp8kv=False-attn_backend=FLASHINFER-torch_compile=True]" "tests/integration/defs/accuracy/test_llm_api_pytorch.py::TestLlama3_1_8BInstruct::test_fp8[fp8kv=False-attn_backend=TRTLLM-torch_compile=True]" -vTest plan
Links
Dev Engineer Review
TestLlama3_1_8BInstruct::test_fp8withfp8kv=False, TRTLLM attention, and Torch Compile.QA Engineer Review
tests/integration/test_lists/waives.txt.