Skip to content

[https://nvbugs/6248837][fix] Free worker GPU memory on executor shutdown#15099

Merged
pengbowang-nv merged 4 commits into
NVIDIA:mainfrom
tianyuxbear:fix/6248837
Jul 6, 2026
Merged

[https://nvbugs/6248837][fix] Free worker GPU memory on executor shutdown#15099
pengbowang-nv merged 4 commits into
NVIDIA:mainfrom
tianyuxbear:fix/6248837

Conversation

@tianyuxbear

@tianyuxbear tianyuxbear commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Description

accuracy/test_llm_api_pytorch.py::TestKimiK25::test_nvfp4[tp8] intermittently OOMed at executor init (model.to("cuda")) on the GB200-8_GPUs-2_Nodes stage, yet passed when run alone. Root cause: GPU memory was not released between tests that share a CI shard.

A shard runs as one long-lived MPI job (8 ranks / 2 nodes) whose worker processes persist across all tests in the shard. GenerationExecutorWorker.shutdown() dropped the engine reference but never returned its GPU memory to the driver — reference cycles keep the model tensors alive until a later GC, and PyTorch's caching allocator holds the freed blocks as "reserved". So a large predecessor (DeepSeek-R1, ~110 GiB/GPU) left its weights resident in the workers, and the next large model (e.g. Kimi-K2.5, ~76 GiB/GPU) then OOMed on all 8 ranks with only ~73 GiB free. This also explains the flakiness: it only failed when a heavy test ran immediately before in the same shard.

Fix

Force gc.collect() + torch.cuda.empty_cache() in GenerationExecutorWorker.shutdown() (after the engine and torch.distributed process group are torn down), so each worker returns the previous model's memory to the driver before the next LLM is built.

Local vs CI debugging summary

A pre-LLM() nvidia-smi probe (diagnostic only, not in this PR) measured the device state at test start:

Local (run alone) CI (after DeepSeek-R1, same shard)
GPU used before next model loads ~3 MiB ~114 GiB (held by a leftover worker python3 process)
Free before next model loads ~184 GiB ~73 GiB
Result PASS (50/50) OOM on all 8 ranks

After the fix, the worker-shutdown step returns that memory at the test→test handoff (free 72.76 → 169.69 GiB) and the previously-failing tests pass.

Same-root-cause OOM tests

The same worker-shutdown OOM affected several GB200 2-node tests. Status in this PR:

Test nvbug Action
TestKimiK25::test_nvfp4[tp8] 6248837 Unwaived
TestKimiK25::test_nvfp4[dep8] 6260890 Unwaived
TestKimiK25::test_nvfp4[tp8_attn_dp] 6144270 Unwaived
TestDeepSeekR1::test_fp8_blockscale[throughput_mtp] 6281818 / 6293890 Unwaived
TestDeepSeekR1::test_fp8_blockscale[throughput_mtp_trtllm] 6281818 Unwaived
TestDeepSeekR1::test_nvfp4_multi_gpus[throughput_mtp] 6261994 / 6029882 Already unwaived on main by #14852 (6029882) — not touched here

Test Coverage

TestKimiK25::test_nvfp4[tp8|dep8|tp8_attn_dp] and TestDeepSeekR1::test_fp8_blockscale[throughput_mtp|throughput_mtp_trtllm] on the GB200-8_GPUs-2_Nodes-PyTorch-* stages.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates the test waiver list to change which parameterization of the Kimi K25 NVFP4 test is exempted from running. The waiver for the tp8 tensor parallelism configuration is replaced with a waiver for the tp8_attn_dp configuration.

Changes

Test Waiver Parameterization Update

Layer / File(s) Summary
Test waiver parameterization swap
tests/integration/test_lists/waives.txt
Removed waiver for accuracy/test_llm_api_pytorch.py::TestKimiK25::test_nvfp4[tp8] and added waiver for the tp8_attn_dp parameterization.

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested reviewers

  • jieli-matrix
  • xinhe-nv
  • nvchenghaoz
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title does not match the actual changes: it claims to fix GPU memory on executor shutdown, but the changeset only removes a waiver from a test file. Update the PR title to accurately reflect the change: '[https://nvbugs/6248837][fix] Free worker GPU memory on executor shutdown' or '[https://nvbugs/6248837][test] Remove waiver for test_nvfp4[tp8]' to match the actual file modifications.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description check ✅ Passed The PR description is comprehensive and well-structured, explaining the root cause, the fix, test coverage, and related issues with clear context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52747 [ run ] triggered by Bot. Commit: a020a51 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #52747 [ run ] completed with state SUCCESS. Commit: a020a51
/LLM/main/L0_MergeRequest_PR pipeline #42008 (Partly Tested) 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

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53037 [ run ] triggered by Bot. Commit: a020a51 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53037 [ run ] completed with state SUCCESS. Commit: a020a51
/LLM/main/L0_MergeRequest_PR pipeline #42257 (Partly Tested) completed with status: 'SUCCESS'

CI Report

Link to invocation

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53231 [ run ] triggered by Bot. Commit: a020a51 Link to invocation

@tianyuxbear
tianyuxbear requested a review from a team as a code owner June 10, 2026 09:14
@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53291 [ run ] triggered by Bot. Commit: 6808edf Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53291 [ run ] completed with state SUCCESS. Commit: 6808edf
/LLM/main/L0_MergeRequest_PR pipeline #42480 (Partly Tested) 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

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53518 [ run ] triggered by Bot. Commit: 6df1865 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53518 [ run ] completed with state SUCCESS. Commit: 6df1865
/LLM/main/L0_MergeRequest_PR pipeline #42676 (Partly Tested) 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

@tianyuxbear
tianyuxbear requested a review from a team as a code owner June 11, 2026 10:19
@tianyuxbear
tianyuxbear requested a review from schetlur-nv June 11, 2026 10:19
@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53552 [ run ] triggered by Bot. Commit: afcec95 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53552 [ run ] completed with state SUCCESS. Commit: afcec95
/LLM/main/L0_MergeRequest_PR pipeline #42705 (Partly Tested) 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

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53604 [ run ] triggered by Bot. Commit: 119a54b Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #53604 [ run ] completed with state SUCCESS. Commit: 119a54b
/LLM/main/L0_MergeRequest_PR pipeline #42750 (Partly Tested) completed with status: 'SUCCESS'

CI Report

Link to invocation

@tianyuxbear tianyuxbear changed the title [https://nvbugs/6248837][test] Unwaive TestKimiK25::test_nvfp4[tp8] [https://nvbugs/6248837][fix] Free worker GPU memory on executor shutdown Jun 12, 2026
@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56905 [ run ] triggered by Bot. Commit: 11bbba5 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56905 [ run ] completed with state SUCCESS. Commit: 11bbba5
/LLM/main/L0_MergeRequest_PR pipeline #45712 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

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56947 [ run ] triggered by Bot. Commit: 11bbba5 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #56947 [ run ] completed with state SUCCESS. Commit: 11bbba5
/LLM/main/L0_MergeRequest_PR pipeline #45752 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

…down

GenerationExecutorWorker.shutdown() dropped the engine reference but
never returned the engine's GPU memory to the driver. Reference cycles
keep the model tensors alive until a later GC, and PyTorch's caching
allocator holds the freed blocks as "reserved" instead of releasing them.

In a persistent worker process that is reused to build another LLM --
successive multi-GPU tests in one CI shard, or any long-running process
that reloads models -- this leftover, roughly weights-sized reservation
can exhaust the device and OOM the next model load at model.to("cuda").
This is why TestKimiK25::test_nvfp4[tp8] OOMed on all ranks when it ran
after a large model (DeepSeek-R1) in the same shard, yet passed in
isolation.

Force gc.collect() + torch.cuda.empty_cache() in
GenerationExecutorWorker.shutdown(), after the engine and the
torch.distributed process group are torn down, so each worker returns
the previous model's memory to the driver before the next LLM is built.

Signed-off-by: Tianyu Xiong <117647511+tianyuxbear@users.noreply.github.com>
Signed-off-by: Tianyu Xiong <117647511+tianyuxbear@users.noreply.github.com>
Signed-off-by: Tianyu Xiong <117647511+tianyuxbear@users.noreply.github.com>
…le cases

Signed-off-by: Tianyu Xiong <117647511+tianyuxbear@users.noreply.github.com>
@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57004 [ run ] triggered by Bot. Commit: 92045db Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57004 [ run ] completed with state SUCCESS. Commit: 92045db
/LLM/main/L0_MergeRequest_PR pipeline #45803 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

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

1 similar comment
@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57312 [ run ] triggered by Bot. Commit: 92045db Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57312 [ run ] completed with state FAILURE. Commit: 92045db
/LLM/main/L0_MergeRequest_PR pipeline #46070 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

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

1 similar comment
@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57561 [ run ] triggered by Bot. Commit: 92045db Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57561 [ run ] completed with state SUCCESS. Commit: 92045db
/LLM/main/L0_MergeRequest_PR pipeline #46289 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

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57682 [ run ] triggered by Bot. Commit: 92045db Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57682 [ run ] completed with state SUCCESS. Commit: 92045db
/LLM/main/L0_MergeRequest_PR pipeline #46402 completed with status: 'SUCCESS'

CI Report

Link to invocation

@tianyuxbear

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57696 [ run ] triggered by Bot. Commit: 92045db Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #57696 [ run ] completed with state SUCCESS. Commit: 92045db
/LLM/main/L0_MergeRequest_PR pipeline #46413 completed with status: 'SUCCESS'

CI Report

Link to invocation

@pengbowang-nv
pengbowang-nv merged commit 605dd00 into NVIDIA:main Jul 6, 2026
7 checks passed
BrianLi23 pushed a commit to BrianLi23/TensorRT-LLM that referenced this pull request Jul 9, 2026
…down (NVIDIA#15099)

Signed-off-by: Tianyu Xiong <117647511+tianyuxbear@users.noreply.github.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.

5 participants