Repository navigation
[None][perf] autotuner: share one CUDA graph pool per tuning pass - #21419
Conversation
…s's profiling captures Each profiling capture used a new graph pool and reset it right after the measurement. With expandable segments the reset unmaps the pool's pages, so the next capture maps them again, once per tactic and profile. The captures of one choose_one() tuning pass now share one torch.cuda.MemPool, which keeps the freed blocks mapped for the next capture. The pool is dropped when the pass ends, so its memory is not held across forward passes. Each capture still gets and releases its own NCCL-window owner, and a failed capture abandons its owner and moves the rest of the pass to a new pool. Tests: one pool per tuning pass and a new pool per pass; a failed capture moves the rest of the pass to a fresh pool. Signed-off-by: Xin Guan <[email protected]>
|
No actionable comments were generated in the recent review. WalkthroughAutoTuner shares a CUDA graph memory pool across captures in a profiling pass. It clears the shared pool when the outermost profiling scope exits or when a capture fails. Tests cover pool reuse and capture failure handling. ChangesProfiling graph-pool lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Sequence Diagram(s)sequenceDiagram
participant AutoTuner
participant ProfilingPool
participant GraphCapture
AutoTuner->>ProfilingPool: Enter profiling scope
AutoTuner->>ProfilingPool: Get shared pool handle
ProfilingPool-->>AutoTuner: Return pool handle
AutoTuner->>GraphCapture: Capture graph with pool handle
alt Capture succeeds
GraphCapture-->>AutoTuner: Release graph owner
else Capture fails
GraphCapture-->>AutoTuner: Abandon graph owner
GraphCapture->>ProfilingPool: Clear shared pool reference
end
AutoTuner->>ProfilingPool: Clear pool at outermost scope exit
Suggested reviewers: Merge Risk:
|
JunyiXu-nv
left a comment
There was a problem hiding this comment.
Runtime part LGTM: the shared pool is reset between captures, dropped after the pass and after a failed capture, and the default path is unchanged.
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
|
/bot run --disable-fail-fast |
|
PR_Github #82203 [ run ] triggered by Bot. Commit: |
|
PR_Github #82203 [ run ] completed with state
|
|
/bot run |
|
PR_Github #82378 [ run ] triggered by Bot. Commit: |
|
PR_Github #82378 [ run ] completed with state |
Dev Engineer Review
choose_one()shares a CUDA graph memory pool across profiling captures in one tuning pass. The pool is cleared when the pass ends.QA Engineer Review
tests/unittest/_torch/misc/test_autotuner.py. The added tests aretest_profiling_captures_share_one_graph_pool_per_tuning_passandtest_failed_profiling_capture_moves_to_a_fresh_graph_pool.test_autotuner_distributed_strategy.main; testing on this PR’s base was not done.Per-File QA Perspective
tensorrt_llm/_torch/autotuner.py: Verify that captures share a pool only within onechoose_one()pass, that the pool is cleared after the pass, and that a failed capture leads to a fresh pool without changing per-capture NCCL-window owner handling.tests/unittest/_torch/misc/test_autotuner.py: Tests shared-pool lifecycle and recovery after capture failure. The added test cases are not listed in CI or manual-QA lists; the CI list includes a different selector from this file.Description
During autotuning, each tactic's profiling capture used a new CUDA graph pool (
torch.cuda.graph_pool_handle()) and reset the graph right after the measurement. Withexpandable_segments, the reset unmaps the pool's pages, so the next capture maps them again, once per tactic and profile.The captures of one
choose_one()tuning pass now share onetorch.cuda.MemPool, which keeps the freed blocks mapped for the next capture. The pool is dropped when the pass ends. It is not kept across passes because the warmup forwards between them would otherwise see its memory on top of their own peak. Each capture still gets and releases its own NCCL-window owner, and a failed capture abandons its owner and moves the rest of the pass to a new pool.Measurements:
GB300, expandable segments, capture + replay + reset of a graph with a 1.5 GiB output: 13 ms per capture with a new pool each time, 0.13 ms with one shared pool. Over 50 captures,
num_device_allocgoes from 50 to 1. Dropping the shared pool returns reserved memory to 0; the old code kept the last pool's 1.5 GiB until the next capture.Rubin (SM107), Kimi K3 disaggregated context workers (16 ranks; before and after are in different allocations):
cuMemCreatecallsTest Coverage
tests/unittest/_torch/misc/test_autotuner.py:test_profiling_captures_share_one_graph_pool_per_tuning_pass: all captures of a tuning pass use one pool, and the next pass uses another.test_failed_profiling_capture_moves_to_a_fresh_graph_pool: after a failed capture, the rest of the pass uses a fresh pool.test_autotuner.py+test_nccl_window_graph.py98 passed. With the oldautotuner.py, both new tests fail on their assertions (for example, 24 captures in 24 pools). Not yet run on this base; CI will cover it.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)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.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.