Skip to content

[https://nvbugs/7139159][fix] Release failed parallel JIT probe tensors - #22848

Merged
trtllm-agent merged 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-v2/nvbug-7139159-r641
Nov 24, 2026
Merged

trtllm-agent merged 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-v2/nvbug-7139159-r641

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

AutoTuner._parallel_jit_warmup only needs the number of failed probes and the
first failure's type/message, but retains the exception objects themselves.
Their tracebacks keep failed-probe input tensors and any runner workspace
allocated before an error alive into serial profiling; the strengthened
test_parallel_jit_warmup_worker_failure_is_left_to_profiling reproduces this
with cyclic GC disabled.

Count failed probes without storing exceptions. Format only the first
failure's type/message, as the diagnostic already does; later failures
contribute to the count without rendering their messages. Keep serial fallback
without changing the warmup sweep, thread configuration or profiling criteria.

Fixes https://nvbugs/7139159

Test Coverage

  • Strengthen
    tests/unittest/_torch/misc/test_autotuner.py::test_parallel_jit_warmup_worker_failure_is_left_to_profiling
    through the real AutoTuner.choose_one caller. Verify that failed worker inputs
    and a temporary CUDA workspace are released before serial profiling without
    cyclic GC. Also exercise a later failure with an unprintable message, keeping
    serial fallback, the complete failure count and the first diagnostic.
  • Local verification through the existing unit-test launcher:
    the original baseline failed the strengthened lifetime assertion with 11
    controls passing (before the later-error parameter was added). With the final
    fixture, a two-case focused run of the all-exceptions-formatting control
    passed the printable parameter but failed the later-unprintable-error
    parameter with ReferenceError. The candidate passed both focused cases
    and all 13 cases in a separate nearby batch, with no skips. The nearby
    controls cover successful and disabled warmup, the environment override,
    default thread selection, shared-build selection and excluded-op cache reuse.
  • The existing unittest/_torch/misc entry in
    tests/integration/test_lists/test-db/l0_h100.yml selects this GPU test in
    pre-merge CI. Strengthening the existing test adds no CI stage or test process.

These are local verification results, not a claim about this PR's CI.

Dev Engineer Review

  • _parallel_jit_warmup now counts failures under a lock and formats only the first failure. This avoids retaining exception objects during serial profiling.
  • Risk: if str(exc) raises for the first failure, the exception escapes warm(). The count is already incremented, but first_failure stays empty, so the log line shows an empty detail. This is a minor edge case.
  • Thread count, warmup sweep, profiling criteria, and serial fallback are unchanged.

QA Engineer Review

  • Modified: tests/unittest/_torch/misc/test_autotuner.py. Test function test_parallel_jit_warmup_worker_failure_is_left_to_profiling is now parametrized over unprintable_later (False, True).
  • Coverage: failed warmup inputs and a temporary workspace are released before profiling with GC disabled. A later unprintable failure does not break the flow. Profiling runs on the caller thread, and the first-failure log line is checked.
  • No test-list files changed. The objectives say the unittest/_torch/misc entry in l0_h100.yml already selects this test.
  • Coverage verdict: sufficient.

Per-File QA Perspective

  • tensorrt_llm/_torch/autotuner.py: Failure log now reports a count and the first failure only. Verify the log line format and that serial fallback still runs.
  • tests/unittest/_torch/misc/test_autotuner.py: Adds a lifetime check and an unprintable later-failure case. Already covered by the existing CI test-db entry, per the objectives.

AutoTuner._parallel_jit_warmup only uses failures for their count and
type/message summary. Retaining exception objects also retains traceback
frames, including profile inputs and runner temporaries. Count failures
without storing exceptions, and format only the first diagnostic so later
unprintable errors do not interrupt serial profiling.

Extend test_parallel_jit_warmup_worker_failure_is_left_to_profiling in
tests/unittest/_torch/misc/test_autotuner.py to check that failed probe
inputs and workspaces are released before serial profiling without cyclic
GC. Cover a later unprintable failure and retain the serial fallback and
first-failure diagnostic assertions.

Fixes https://nvbugs/7139159

Signed-off-by: trtllm-agent <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Parallel JIT warmup now counts worker failures and retains the formatted type and message of the first failure instead of storing exception objects. The expanded test checks exception formatting, tensor release before profiling, caller-thread profiling, and failure logging.

Changes

Warmup failure handling

Layer / File(s) Summary
Track and verify warmup failures
tensorrt_llm/_torch/autotuner.py, tests/unittest/_torch/misc/test_autotuner.py
Warmup workers count failures under a lock and format only the first exception for the completion log. Tests cover printable and unprintable exceptions, tensor release before profiling, caller-thread profiling, and failure logging.

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

Change: Bug fix

Merge Risk: Minimal · up to 54f91

This change stops parallel JIT warmup from keeping failed probe inputs and temporary workspaces alive into serial profiling. The fallback behavior and the first-failure log message are preserved. No actionable merge-blocking risk remains.

Security architecture risk: Minimal · up to 54f91

The fix lets temporary GPU memory from failed warmup attempts become reusable before profiling, without changing how callers invoke tuning or when ordinary failures fall back to profiling. No material security or isolation regression was identified in the changed code.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the NVBugs ID and type, and it states the main change: the failed parallel JIT probe tensors are released. The raw summary confirms that _parallel_jit_warmup now keeps only the failure…
Description check Passed The description follows the repository template's main content. It explains the issue (retained exceptions keep probe tensors and workspaces alive), the solution (count failures and format only the fi…
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.
Full details: Title check

Explanation

The title names the NVBugs ID and type, and it states the main change: the failed parallel JIT probe tensors are released. The raw summary confirms that _parallel_jit_warmup now keeps only the failure count and the first failure's formatted type and message, instead of exception objects. The title follows the repository template for an NVBugs ID with the [fix] type.

Full details: Description check

Explanation

The description follows the repository template's main content. It explains the issue (retained exceptions keep probe tensors and workspaces alive), the solution (count failures and format only the first failure), and the test coverage (the strengthened test, the local verification, and the CI selection). The template's PR checklist is not filled in, and the Description section does not restate the NVBugs ID as a template heading. The Fixes line does include the NVBugs link. These gaps are minor.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bd0f4f9 and 54f911d.

Files selected for processing: 2

  • tensorrt_llm/_torch/autotuner.py
  • tests/unittest/_torch/misc/test_autotuner.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@trtllm-agent-review trtllm-agent-review 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.

Thanks for the PR. Stops the autotuner's parallel JIT warmup from keeping the exception objects of failed probes, so their input tensors and workspaces are freed before serial profiling, and strengthens the worker-failure test to check that release with cyclic GC disabled.

Reviewed at commit 54f911d344 (2 files, +68/−18).

The overlap with #22374 and #21628 was checked against their heads as of 2026-11-24.

Approve: no Blocker found. 3 suggestions below are nice to have.

Nice to have (3): 3 inline, 0 below
  • (N2: Test design and organization) The [False] case runs the same changed lines as [True] and checks nothing [True] misses, so the parametrization only adds a second sweep. (test_autotuner.py:3485)
  • (R1: PR process) Open PR #22374 (and #21628 on top of it) rewrites these same warmup lines and still does failures.append(e); whichever merges second must keep the counter. (autotuner.py:2010)
  • (N5: Code tidiness) Nothing in the code says why no exception object may be kept here; a short comment would stop a later edit from collecting exceptions again. (autotuner.py:1993)
What this review checked
  • Dropping the stored exceptions breaks the reference cycle (failures list -> exception -> traceback -> warm frame -> closure cell -> list) that kept every failed probe's input and workspace alive until cyclic GC. With GC disabled, a torch-free replica of both versions keeps 12 of 12 probe objects alive after the old warmup returns and 0 of 12 after the new one, and the log message is unchanged.
  • The strengthened test fails on the old code. With one runner and one tactic, profiling takes the single-pair shortcut (tensorrt_llm/_torch/autotuner.py:1785), so the first caller-thread forward runs eagerly, and the autotuner never calls gc.collect(); the old cycle is still alive when retained_while_profiling is first recorded. The test runs pre-merge through the unittest/_torch/misc entry in tests/integration/test_lists/test-db/l0_h100.yml.
  • Freeing a failed probe's blocks without stream.synchronize() is safe. All workers allocate on the one shared stream (tensorrt_llm/_torch/autotuner.py:1992), which the profiling loop also uses, so the caching allocator reuses those blocks in stream order. failure_count only changes under the lock, and first_failure has a single writer and is read after the pool joins.
  • Not covered: No GPU run: the changed test was not executed.
  • Not covered: No CI results for this PR yet.
  • Not covered: Overlapping open PRs were found by keyword search only.

Automated review by trtllm-agent-review. If a point is wrong, reply in its thread. Once you have pushed code changes and replied in every Blocker thread, the bot re-checks the Blockers within a few hours.

Comment thread tensorrt_llm/_torch/autotuner.py Resolved
Comment thread tensorrt_llm/_torch/autotuner.py Resolved
@trtllm-agent

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87022 [ run ] triggered by Bot. Commit: 54f911d Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #87022 [ run ] completed with state SUCCESS. Commit: 54f911d
/LLM/main/L0_MergeRequest_PR pipeline #72178 completed with status: 'SUCCESS'

CI Report

Link to invocation

@trtllm-agent
trtllm-agent merged commit 898b4b0 into NVIDIA:main Nov 24, 2026
24 checks passed
chenfeiz0326 added a commit to chenfeiz0326/TensorRT-LLM that referenced this pull request Nov 25, 2026
Conflicts:
- autotuner.py: _parallel_jit_warmup keeps this branch's shared-sweep claims
  and its count of the profiles it ran, with main's failure count and first
  failure message in place of the list of exceptions (NVIDIA#22848).

Signed-off-by: chenfeiz0326 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants