Skip to content

Conversation

@HuiGao-NV
Copy link
Collaborator

@HuiGao-NV HuiGao-NV commented Dec 28, 2025

Summary by CodeRabbit

  • Tests

    • Enhanced test infrastructure with GPU memory diagnostics and monitoring capabilities
    • Added parametrized test coverage for expanded scenario testing
    • Updated test skip configurations for improved test isolation
  • Chores

    • Added diagnostic logging throughout shutdown processes for improved troubleshooting and system observability

✏️ Tip: You can customize this high-level summary in your review settings.

Description

Test Coverage

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)

  • 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

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

Details

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

@HuiGao-NV HuiGao-NV requested review from a team as code owners December 28, 2025 06:44
@HuiGao-NV HuiGao-NV marked this pull request as draft December 28, 2025 06:44
@HuiGao-NV
Copy link
Collaborator Author

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

This PR adds runtime diagnostics and debug logging across shutdown methods and lifecycle events in executor, LLM API, and test infrastructure components. Changes include printing process IDs, stack traces, and diagnostic banners without modifying control flow. Test infrastructure updates add memory monitoring utilities and test parameterization.

Changes

Cohort / File(s) Summary
Executor shutdown diagnostics
tensorrt_llm/_torch/pyexecutor/py_executor.py, tensorrt_llm/executor/base_worker.py, tensorrt_llm/executor/proxy.py, tensorrt_llm/executor/ray_executor.py, tensorrt_llm/executor/ray_gpu_worker.py, tensorrt_llm/executor/rpc_server.py, tensorrt_llm/executor/rpc_worker.py, tensorrt_llm/executor/utils.py
Added print statements logging process PIDs and shutdown state during shutdown methods. No control-flow changes.
LLM API lifecycle logging
tensorrt_llm/llmapi/llm.py, tensorrt_llm/llmapi/mpi_session.py
Added diagnostic print statements and traceback output during initialization, shutdown, and cleanup lifecycle events. No functional changes to processing logic.
Advanced RPC proxy diagnostics
tensorrt_llm/executor/rpc_proxy.py
Added stack trace and process PID prints before/after shutdown event checks, with imported traceback and os modules. Maintains existing shutdown semantics.
Worker shutdown and notify flow logging
tensorrt_llm/executor/worker.py
Added multiple debug prints across shutdown, notify, and worker_main flows to trace lifecycle events and shutdown signal reception. Final logger_debug added on exit.
Signal handler logging
tensorrt_llm/commands/serve.py
Added signal name logging in cleanup signal handler before existing cleanup logic.
Debug scaffolding
tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
Added commented-out debug import and print statements with no runtime effect.
Test memory instrumentation
tests/integration/defs/conftest.py
Added new public functions get_device_memory_str() and print_device_memory() for GPU memory diagnostics. Reworked get_device_memory() with fallback logic and enhanced error handling.
Test infrastructure updates
tests/integration/defs/accuracy/test_llm_api_pytorch.py
Added time import and GPU memory check calls. Parameterized TestLlama3_2_1B.test_auto_dtype with pp_size parameter (values 2, 4). Added sleep calls between test steps.
Test list configuration
tests/integration/test_lists/test-db/l0_gb200_multi_nodes.yml
Added " ISOLATION" suffix to four test entries for throughput and latency benchmarks.
Test skip list update
tests/integration/test_lists/waives.txt
Replaced set of skipped tests; alters test selection without touching test logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.95% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ⚠️ Warning The PR description is incomplete. The template sections for 'Description' and 'Test Coverage' are empty (containing only HTML comments without actual content), though the PR checklist was marked as complete. Fill in the 'Description' section explaining the issue and solution, and the 'Test Coverage' section listing relevant tests that validate the memory release changes.
Title check ⚠️ Warning The title claims to fix torch memory release when LLM is destroyed, but the changeset primarily adds diagnostic print statements and logging across shutdown paths without substantive memory management changes. Update the title to accurately reflect the main changes, such as '[chore] Add diagnostic logging during shutdown and memory diagnostics' or similar, as the changeset focuses on instrumentation rather than fixing memory release behavior.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tensorrt_llm/executor/rpc_worker.py (1)

101-107: Fix undefined os in RpcWorker.shutdown

shutdown prints the PID via os.getpid(), but this module never imports os, so calling shutdown() will raise NameError.

Proposed patch
-from pathlib import Path
-from queue import Queue
-from threading import Event
-from typing import Optional, Union
-
-import nvtx
+from pathlib import Path
+from queue import Queue
+from threading import Event
+from typing import Optional, Union
+
+import os
+import nvtx
@@
     def shutdown(self):
         logger_debug(f"[worker] RpcWorker #{mpi_rank()} is shutting down",
                      color="yellow")
         self.shutdown_event.set()
-        print(
-            f"====================== shutdown in RpcWorker is called pid:  {os.getpid()}"
-        )
+        print(
+            f"====================== shutdown in RpcWorker is called pid:  {os.getpid()}"
+        )
tests/integration/defs/accuracy/test_llm_api_pytorch.py (1)

1418-1444: Remove commented-out diagnostic code and fix f-string usage.

This section contains:

  1. Commented-out code (lines 1419, 1436, 1442-1444) that should be removed
  2. f-strings without placeholders (lines 1420, 1433, 1437, 1440) that should use regular strings
  3. Inconsistent diagnostic prints - some are active, some are commented out

As per the coding guidelines: "Avoid using... commented-out code" and static analysis correctly flags the unnecessary f-string prefixes.

🔎 Proposed cleanup
-        #time.sleep(5)
-        print(f"================= print mem before testing")
-        print_device_memory()
+        # Remove commented-out diagnostic code or make it conditional

For active diagnostic prints, fix f-strings:

-            print(f"================= print mem after testing")
+            print("================= print mem after testing")
             print_device_memory()
 
-        #time.sleep(5)
-        print(f"================= print mem after testing outside")
-        print_device_memory()
-
-        print(f"++++++++++++++++++++++++++++++++++++++++\n\n\n")
-
-        #time.sleep(60)
-        #print(f"================= print mem after 60s")
-        #print_device_memory()
+        # Remove or make conditional as suggested in previous comment
🧹 Nitpick comments (10)
tensorrt_llm/commands/serve.py (1)

47-49: Consider using consistent logging approach throughout the signal handler.

This print() statement is inconsistent with the logger.info() calls used throughout the rest of this signal handler (lines 53-54, 61-62, 68-69, 73-74, 77-78).

The comment on line 52 mentions "Using print for safety in signal handlers," but if logger.info() is acceptable for the existing logging statements, consider using it here as well for consistency. Alternatively, if signal safety is a genuine concern, all logging in this handler should use print().

🔎 Suggested fix for consistency
-    print(
-        f"================================================ server received signal {signal.Signals(signum).name}"
-    )
+    logger.info(
+        f"Server received signal {signal.Signals(signum).name}. Initiating cleanup."
+    )
tensorrt_llm/_torch/pyexecutor/py_executor_creator.py (1)

224-227: Remove commented-out debug prints or convert to gated logging

The commented import/print/traceback.print_stack() lines in create_py_executor look like temporary debugging artifacts. Either remove them, or if you still need this information, reintroduce it via logger/logger_debug and gate it behind an env flag or enable_llm_debug().

tensorrt_llm/_torch/pyexecutor/py_executor.py (1)

451-460: Gate shutdown stack/ PID diagnostics behind debug controls

PyExecutor.shutdown() now always prints a full stack trace and PID to stdout. That’s useful for debugging but very noisy in normal runs, especially since this path is hit on every executor teardown. Consider:

  • Using logger/logger_debug instead of bare print/traceback.print_stack().
  • Gating these diagnostics behind enable_llm_debug() or a dedicated env flag so production users don’t get unexpected console spam.
tensorrt_llm/executor/base_worker.py (1)

640-641: Route worker shutdown banner through logger or debug flag

BaseWorker.shutdown() now unconditionally prints a banner to stdout. For consistency with the rest of the executor stack and to avoid polluting user stdout (especially since shutdown() can be called from __del__), consider switching this to logger.debug/logger.info (or logger_debug) and/or gating it behind a debug flag.

tensorrt_llm/executor/proxy.py (1)

293-295: Avoid unconditional stdout prints in GenerationExecutorProxy.shutdown

The shutdown path now prints PID banners to stdout at both the beginning and end. This is helpful when debugging but can be quite noisy for normal users and in multi-process setups.

Consider:

  • Replacing these with logger_debug / logger.info messages, or
  • Wrapping them in a debug check (e.g., enable_llm_debug() or an env flag),

so that default behavior relies on the existing logging/tracing stack instead of raw print.

Also applies to: 331-333

tensorrt_llm/executor/rpc/rpc_server.py (1)

137-139: Use logger for RPCServer shutdown diagnostics instead of bare print

RPCServer.shutdown() now prints a banner with is_remote_call directly to stdout. Since this class already uses logger_debug, and shutdown can be triggered frequently (including via remote calls), it would be cleaner to:

  • Log this via logger_debug (or logger.info) with the same message, and/or
  • Guard the extra logging behind a debug flag.

That keeps diagnostics while avoiding unconditional stdout noise.

tensorrt_llm/executor/ray_executor.py (1)

296-299: Prefer logger-based shutdown diagnostics in RayExecutor.shutdown

The Ray executor now prints the PID directly in shutdown(). Since you already log "Shutting down RayExecutor" via logger_debug, consider folding the PID into that log (or another logger call) and/or guarding it behind a debug flag instead of using print, to avoid cluttering stdout in Ray applications.

tensorrt_llm/llmapi/mpi_session.py (1)

162-167: Consider simplifying diagnostic prints (f-strings without interpolation)

Both MpiPoolSession.shutdown and MpiCommSession.shutdown add plain banner prints using f-strings but without any placeholders. This is harmless but trips Ruff’s F541 and is slightly noisy.

If you want to keep linters quiet while retaining the diagnostics, you can drop the f prefix:

print("==================================== shutdown MPI pool session")
...
print("==================================== shutdown is called MPI comm session")

Also applies to: 238-249

tensorrt_llm/llmapi/llm.py (1)

175-178: Diagnostics are very verbose and repeatedly import os/traceback

These additions provide helpful visibility (PID and stack traces) around LLM lifecycle and shutdown, but a few caveats:

  • shutdown, _shutdown_wrapper, __exit__, and __del__ will now always print stack traces and banners, which can be quite noisy in normal usage and in libraries embedded in larger apps.
  • os (and traceback) are re-imported inside methods even though os is already imported at module level; this is harmless but unnecessary.

If these are primarily for debugging OOM or CI issues, consider:

  • Guarding them behind an env flag or enable_llm_debug()-style switch.
  • Reusing the module-level os import and a single import traceback at top of file.

Also applies to: 821-829, 854-859, 871-876, 883-886

tensorrt_llm/executor/rpc_proxy.py (1)

189-200: Shutdown debug prints may be excessively noisy

GenerationExecutorRpcProxy.shutdown now always:

  • Dumps a full stack trace, and
  • Prints PID banners twice per shutdown.

Behavior is unchanged, but for regular runs this may clutter logs significantly.

If these are for targeted debugging, consider gating them behind a debug env variable or using logger_debug instead of unconditional print/traceback.print_stack().

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 270be80 and 617296a.

📒 Files selected for processing (18)
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
  • tensorrt_llm/commands/serve.py
  • tensorrt_llm/executor/base_worker.py
  • tensorrt_llm/executor/proxy.py
  • tensorrt_llm/executor/ray_executor.py
  • tensorrt_llm/executor/ray_gpu_worker.py
  • tensorrt_llm/executor/rpc/rpc_server.py
  • tensorrt_llm/executor/rpc_proxy.py
  • tensorrt_llm/executor/rpc_worker.py
  • tensorrt_llm/executor/utils.py
  • tensorrt_llm/executor/worker.py
  • tensorrt_llm/llmapi/llm.py
  • tensorrt_llm/llmapi/mpi_session.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
  • tests/integration/defs/conftest.py
  • tests/integration/test_lists/test-db/l0_gb200_multi_nodes.yml
  • tests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces. Do not use tabs
Always maintain the namespace when importing in Python, even if only one class or function from a module is used
Python files should use snake_case naming: some_file.py
Python classes should use PascalCase naming: class SomeClass
Python functions and methods should use snake_case naming: def my_awesome_function():
Python local variables should use snake_case naming: my_variable = ...
Python variable names that start with a number should be prefixed with 'k': k_99th_percentile = ...
Python global variables should use upper snake_case with prefix 'G': G_MY_GLOBAL = ...
Python constants should use upper snake_case naming: MY_CONSTANT = ...
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Python comments should be reserved for code within a function, or interfaces that are local to a file
Use Google style docstrings in Python for classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with type and description
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except to the smallest set of errors possible
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible, using the else block for logic

Files:

  • tensorrt_llm/executor/rpc_proxy.py
  • tensorrt_llm/executor/proxy.py
  • tensorrt_llm/executor/utils.py
  • tensorrt_llm/executor/base_worker.py
  • tensorrt_llm/executor/worker.py
  • tensorrt_llm/llmapi/llm.py
  • tensorrt_llm/commands/serve.py
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
  • tensorrt_llm/executor/rpc/rpc_server.py
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
  • tensorrt_llm/llmapi/mpi_session.py
  • tests/integration/defs/conftest.py
  • tensorrt_llm/executor/ray_executor.py
  • tensorrt_llm/executor/ray_gpu_worker.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
  • tensorrt_llm/executor/rpc_worker.py
**/*.{cpp,h,cu,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code should contain an NVIDIA copyright header that includes the year of its latest meaningful modification

Files:

  • tensorrt_llm/executor/rpc_proxy.py
  • tensorrt_llm/executor/proxy.py
  • tensorrt_llm/executor/utils.py
  • tensorrt_llm/executor/base_worker.py
  • tensorrt_llm/executor/worker.py
  • tensorrt_llm/llmapi/llm.py
  • tensorrt_llm/commands/serve.py
  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
  • tensorrt_llm/executor/rpc/rpc_server.py
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
  • tensorrt_llm/llmapi/mpi_session.py
  • tests/integration/defs/conftest.py
  • tensorrt_llm/executor/ray_executor.py
  • tensorrt_llm/executor/ray_gpu_worker.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
  • tensorrt_llm/executor/rpc_worker.py
🧠 Learnings (10)
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
Repo: NVIDIA/TensorRT-LLM PR: 6487
File: tests/unittest/_torch/auto_deploy/unit/singlegpu/test_ad_trtllm_bench.py:1-12
Timestamp: 2025-08-06T13:58:07.506Z
Learning: In TensorRT-LLM, test files (files under tests/ directories) do not require NVIDIA copyright headers, unlike production source code files. Test files typically start directly with imports, docstrings, or code.

Applied to files:

  • tensorrt_llm/llmapi/llm.py
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
Repo: NVIDIA/TensorRT-LLM PR: 6303
File: tests/integration/test_lists/qa/examples_test_list.txt:494-494
Timestamp: 2025-07-28T17:06:08.621Z
Learning: In TensorRT-LLM testing, it's common to have both CLI flow tests (test_cli_flow.py) and PyTorch API tests (test_llm_api_pytorch.py) for the same model. These serve different purposes: CLI flow tests validate the traditional command-line workflow, while PyTorch API tests validate the newer LLM API backend. Both are legitimate and should coexist.

Applied to files:

  • tensorrt_llm/llmapi/llm.py
  • tests/integration/test_lists/test-db/l0_gb200_multi_nodes.yml
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-09-09T09:40:45.658Z
Learnt from: fredricz-20070104
Repo: NVIDIA/TensorRT-LLM PR: 7645
File: tests/integration/test_lists/qa/llm_function_core.txt:648-648
Timestamp: 2025-09-09T09:40:45.658Z
Learning: In TensorRT-LLM test lists, it's common and intentional for the same test to appear in multiple test list files when they serve different purposes (e.g., llm_function_core.txt for comprehensive core functionality testing and llm_function_core_sanity.txt for quick sanity checks). This duplication allows tests to be run in different testing contexts.

Applied to files:

  • tensorrt_llm/llmapi/llm.py
  • tests/integration/test_lists/test-db/l0_gb200_multi_nodes.yml
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-19T12:45:11.997Z
Learnt from: amitz-nv
Repo: NVIDIA/TensorRT-LLM PR: 7033
File: tensorrt_llm/_torch/pyexecutor/model_engine.py:0-0
Timestamp: 2025-08-19T12:45:11.997Z
Learning: In tensorrt_llm/_torch/pyexecutor/model_engine.py, DoRA (Delta Orthogonal Rank Adaptation) functionality was removed from the PyTorch flow to eliminate issues with inverted DoRA detection logic. The original is_dora condition was checking if scaling_vec_pointer == 0, which was potentially incorrect.

Applied to files:

  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
📚 Learning: 2025-12-12T03:27:08.565Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 9655
File: tensorrt_llm/_torch/pyexecutor/sampler.py:3031-3031
Timestamp: 2025-12-12T03:27:08.565Z
Learning: In files under tensorrt_llm/_torch/pyexecutor, avoid accessing torch.Tensor objects inside for-loops when iterating over requests. Convert batched tensors to Python lists beforehand using tensor.tolist(), and then iterate over those lists. This improves performance by reducing tensor-bound operations inside hot loops. Apply this pattern to similar code paths that process batches to access simple Python data structures (lists) inside loops.

Applied to files:

  • tensorrt_llm/_torch/pyexecutor/py_executor_creator.py
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
📚 Learning: 2025-09-17T02:48:52.732Z
Learnt from: tongyuantongyu
Repo: NVIDIA/TensorRT-LLM PR: 7781
File: tests/integration/test_lists/waives.txt:313-313
Timestamp: 2025-09-17T02:48:52.732Z
Learning: In TensorRT-LLM, `tests/integration/test_lists/waives.txt` is specifically for waiving/skipping tests, while other test list files like those in `test-db/` and `qa/` directories are for different test execution contexts (pre-merge, post-merge, QA tests). The same test appearing in both waives.txt and execution list files is intentional - the test is part of test suites but will be skipped due to the waiver.

Applied to files:

  • tests/integration/test_lists/test-db/l0_gb200_multi_nodes.yml
📚 Learning: 2025-08-26T09:49:04.956Z
Learnt from: pengbowang-nv
Repo: NVIDIA/TensorRT-LLM PR: 7192
File: tests/integration/test_lists/test-db/l0_dgx_b200.yml:56-72
Timestamp: 2025-08-26T09:49:04.956Z
Learning: In TensorRT-LLM test configuration files, the test scheduling system handles wildcard matching with special rules that prevent duplicate test execution even when the same tests appear in multiple yaml files with overlapping GPU wildcards (e.g., "*b200*" and "*gb200*").

Applied to files:

  • tests/integration/test_lists/test-db/l0_gb200_multi_nodes.yml
  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-13T11:07:11.772Z
Learnt from: Funatiq
Repo: NVIDIA/TensorRT-LLM PR: 6754
File: tests/integration/test_lists/test-db/l0_a30.yml:41-47
Timestamp: 2025-08-13T11:07:11.772Z
Learning: In TensorRT-LLM test configuration files like tests/integration/test_lists/test-db/l0_a30.yml, TIMEOUT values are specified in minutes, not seconds.

Applied to files:

  • tests/integration/test_lists/test-db/l0_gb200_multi_nodes.yml
📚 Learning: 2025-08-29T14:07:45.863Z
Learnt from: EmmaQiaoCh
Repo: NVIDIA/TensorRT-LLM PR: 7370
File: tests/unittest/trt/model_api/test_model_quantization.py:24-27
Timestamp: 2025-08-29T14:07:45.863Z
Learning: In TensorRT-LLM's CI infrastructure, pytest skip markers (pytest.mark.skip) are properly honored even when test files have __main__ blocks that call test functions directly. The testing system correctly skips tests without requiring modifications to the __main__ block execution pattern.

Applied to files:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
📚 Learning: 2025-08-11T20:09:24.389Z
Learnt from: achartier
Repo: NVIDIA/TensorRT-LLM PR: 6763
File: tests/integration/defs/triton_server/conftest.py:16-22
Timestamp: 2025-08-11T20:09:24.389Z
Learning: In the TensorRT-LLM test infrastructure, the team prefers simple, direct solutions (like hard-coding directory traversal counts) over more complex but robust approaches when dealing with stable directory structures. They accept the maintenance cost of updating tests if the layout changes.

Applied to files:

  • tests/integration/defs/accuracy/test_llm_api_pytorch.py
🧬 Code graph analysis (4)
tensorrt_llm/executor/base_worker.py (3)
tensorrt_llm/_torch/device_mesh.py (1)
  • rank (36-37)
tensorrt_llm/mapping.py (2)
  • rank (199-200)
  • rank (203-210)
tensorrt_llm/_torch/distributed/communicator.py (2)
  • rank (40-41)
  • rank (451-452)
tensorrt_llm/executor/worker.py (2)
tensorrt_llm/_utils.py (1)
  • mpi_rank (537-544)
tensorrt_llm/llmapi/utils.py (1)
  • logger_debug (106-120)
tensorrt_llm/llmapi/llm.py (10)
tensorrt_llm/executor/base_worker.py (1)
  • shutdown (640-649)
tensorrt_llm/executor/proxy.py (1)
  • shutdown (292-341)
tensorrt_llm/executor/ray_executor.py (1)
  • shutdown (290-345)
tensorrt_llm/executor/ray_gpu_worker.py (2)
  • shutdown (153-158)
  • shutdown (298-339)
tensorrt_llm/executor/rpc_proxy.py (1)
  • shutdown (189-235)
tensorrt_llm/executor/rpc_worker.py (1)
  • shutdown (101-110)
tensorrt_llm/executor/utils.py (1)
  • shutdown (103-107)
tensorrt_llm/executor/worker.py (1)
  • shutdown (86-127)
tensorrt_llm/llmapi/mpi_session.py (2)
  • shutdown (100-101)
  • shutdown (162-166)
tensorrt_llm/scaffolding/worker.py (3)
  • shutdown (35-36)
  • shutdown (118-120)
  • shutdown (260-262)
tests/integration/defs/accuracy/test_llm_api_pytorch.py (1)
tests/integration/defs/conftest.py (2)
  • parametrize_with_ids (1832-1858)
  • print_device_memory (2046-2063)
🪛 Ruff (0.14.10)
tensorrt_llm/executor/utils.py

105-105: f-string without any placeholders

Remove extraneous f prefix

(F541)

tensorrt_llm/executor/worker.py

343-343: Use raise without specifying exception name

Remove exception name

(TRY201)

tensorrt_llm/llmapi/llm.py

881-881: Avoid specifying long messages outside the exception class

(TRY003)

tensorrt_llm/llmapi/mpi_session.py

163-163: f-string without any placeholders

Remove extraneous f prefix

(F541)


242-242: f-string without any placeholders

Remove extraneous f prefix

(F541)

tests/integration/defs/conftest.py

2015-2015: Function call with shell=True parameter identified, security issue

(S604)


2029-2029: Abstract raise to an inner function

(TRY301)


2029-2029: Avoid specifying long messages outside the exception class

(TRY003)


2040-2040: Do not use bare except

(E722)


2056-2056: f-string without any placeholders

Remove extraneous f prefix

(F541)


2057-2057: Starting a process with a partial executable path

(S607)

tests/integration/defs/accuracy/test_llm_api_pytorch.py

538-538: Unused method argument: pp_size

(ARG002)


1361-1361: f-string without any placeholders

Remove extraneous f prefix

(F541)


1420-1420: f-string without any placeholders

Remove extraneous f prefix

(F541)


1433-1433: f-string without any placeholders

Remove extraneous f prefix

(F541)


1437-1437: f-string without any placeholders

Remove extraneous f prefix

(F541)


1440-1440: f-string without any placeholders

Remove extraneous f prefix

(F541)


2295-2295: f-string without any placeholders

Remove extraneous f prefix

(F541)


2343-2343: f-string without any placeholders

Remove extraneous f prefix

(F541)

tensorrt_llm/executor/rpc_worker.py

106-106: Undefined name os

(F821)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (4)
tensorrt_llm/executor/worker.py (2)

86-128: Additional shutdown diagnostics in GenerationExecutorWorker look safe

The new PID-annotated prints around worker and engine shutdown are side-effect-only and don’t alter the existing shutdown sequencing or guards (doing_shutdown, engine cleanup). Safe to keep for troubleshooting.


175-176: Worker main-loop diagnostics are reasonable

The extra log/print when:

  • entering/exiting worker_main, and
  • exiting the request loop or error path,

help clarify shutdown paths without changing control flow. The final logger_debug on exit is also low-risk.

Also applies to: 326-344

tests/integration/test_lists/test-db/l0_gb200_multi_nodes.yml (1)

35-38: Isolated scheduling flags for DeepSeekR1 multi-node tests look consistent

Adding ISOLATION to these long-running test_nvfp4_multi_gpus[...] cases under the post_merge block matches the existing TIMEOUT-style syntax and should help keep them from overlapping with other heavy jobs. No functional impact on the tests themselves.

tests/integration/defs/accuracy/test_llm_api_pytorch.py (1)

17-17: Consider the intended lifespan of this diagnostic code.

Based on the PR title "Test oom case" and the commit messages about logging device memory, this appears to be diagnostic code for investigating OOM scenarios. However, the current implementation has several concerns for production use:

  1. Performance impact: Sleep times totaling 240+ seconds per test run
  2. Incomplete implementation: Unused pp_size parameter (line 538)
  3. Code quality: Commented-out code, f-strings without placeholders
  4. Manual resource management: Unusual gc.collect() patterns

Recommendations:

If this is temporary debugging:

  • Consider keeping in a separate branch or behind a feature flag
  • Document in the PR description that it's for diagnostic purposes only
  • Plan for cleanup before merge

If this needs to be permanent:

  • Make all diagnostics conditional via environment variable
  • Fix the unused pp_size parameter
  • Remove commented-out code and fix f-strings
  • Investigate why manual GC is needed and fix root cause
  • Reduce or make sleep times configurable

Would you like help refactoring this to use conditional diagnostics or pytest fixtures for cleaner integration?

Also applies to: 63-65

⛔ Skipped due to learnings
Learnt from: djns99
Repo: NVIDIA/TensorRT-LLM PR: 6915
File: cpp/tensorrt_llm/kernels/cutlass_kernels/moe_gemm/moe_kernels.cu:4010-4012
Timestamp: 2025-08-14T23:23:27.449Z
Learning: For MOE (Mixture of Experts) code reviews in TensorRT-LLM, avoid repeatedly suggesting finalize fusion validation checks and safety assertions. The user djns99 has indicated these suggestions are repetitive and unwanted across multiple MOE-related changes.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30048 [ run ] triggered by Bot. Commit: 617296a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30048 [ run ] completed with state FAILURE. Commit: 617296a
/LLM/main/L0_MergeRequest_PR pipeline #23124 (Partly Tested) completed with status: 'FAILURE'

⚠️ 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

@HuiGao-NV
Copy link
Collaborator Author

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

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30061 [ run ] triggered by Bot. Commit: 617296a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30061 [ run ] completed with state FAILURE. Commit: 617296a
/LLM/main/L0_MergeRequest_PR pipeline #23137 (Partly Tested) completed with status: 'FAILURE'

⚠️ 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

@HuiGao-NV
Copy link
Collaborator Author

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

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30099 [ run ] triggered by Bot. Commit: 617296a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30099 [ run ] completed with state FAILURE. Commit: 617296a
/LLM/main/L0_MergeRequest_PR pipeline #23160 (Partly Tested) completed with status: 'FAILURE'

⚠️ 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

@HuiGao-NV
Copy link
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1,GB200-4_GPUs-PyTorch-2" --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30126 [ run ] triggered by Bot. Commit: 617296a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30126 [ run ] completed with state SUCCESS. Commit: 617296a
/LLM/main/L0_MergeRequest_PR pipeline #23184 (Partly Tested) completed with status: 'FAILURE'

⚠️ 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

@HuiGao-NV
Copy link
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1,GB200-4_GPUs-PyTorch-2" --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30151 [ run ] triggered by Bot. Commit: 851f657

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30151 [ run ] completed with state SUCCESS. Commit: 851f657
/LLM/main/L0_MergeRequest_PR pipeline #23201 (Partly Tested) completed with status: 'FAILURE'

⚠️ 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

@HuiGao-NV
Copy link
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1,GB200-4_GPUs-PyTorch-2" --disable-fail-fast

@HuiGao-NV
Copy link
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1,GB200-4_GPUs-PyTorch-2" --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30390 [ run ] triggered by Bot. Commit: 5f03844

@HuiGao-NV
Copy link
Collaborator Author

/bot run --stage-list "GB200-8_GPUs-2_Nodes-PyTorch-1,GB200-4_GPUs-PyTorch-2" --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30419 [ run ] triggered by Bot. Commit: 57a10ee

@cordialbear
Copy link

/bot run --disable-fail-fast

1 similar comment
@cordialbear
Copy link

/bot run --disable-fail-fast

@cordialbear
Copy link

/bot run

@HuiGao-NV HuiGao-NV marked this pull request as ready for review January 4, 2026 13:32
@HuiGao-NV HuiGao-NV changed the title Test oom case [https://nvbugs/5715568][fix] Force release torch memory when LLM is destroyed Jan 4, 2026
@HuiGao-NV HuiGao-NV enabled auto-merge (squash) January 4, 2026 13:36
@HuiGao-NV
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30502 [ run ] triggered by Bot. Commit: bbf4646

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30502 [ run ] completed with state SUCCESS. Commit: bbf4646
/LLM/main/L0_MergeRequest_PR pipeline #23523 completed with status: 'SUCCESS'

Signed-off-by: Hui Gao <[email protected]>
@HuiGao-NV HuiGao-NV requested a review from QiJune January 5, 2026 01:18
@HuiGao-NV HuiGao-NV changed the title [https://nvbugs/5715568][fix] Force release torch memory when LLM is destroyed [https://nvbugs/5715568][fix] Force to release torch memory when LLM is destroyed Jan 5, 2026
Signed-off-by: Hui Gao <[email protected]>
Copy link
Collaborator

@Superjomn Superjomn left a comment

Choose a reason for hiding this comment

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

LGTM

@HuiGao-NV
Copy link
Collaborator Author

/bot reuse-pipeline

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30519 [ reuse-pipeline ] triggered by Bot. Commit: 024ce3b

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30519 [ reuse-pipeline ] completed with state SUCCESS. Commit: 024ce3b
Reusing PR_Github #30502 for commit 024ce3b

Signed-off-by: Hui Gao <[email protected]>
@HuiGao-NV
Copy link
Collaborator Author

/bot reuse-pipeline

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30541 [ reuse-pipeline ] triggered by Bot. Commit: 747c095

@tensorrt-cicd
Copy link
Collaborator

PR_Github #30541 [ reuse-pipeline ] completed with state SUCCESS. Commit: 747c095
Reusing PR_Github #30502 for commit 747c095

Copy link
Collaborator

@QiJune QiJune left a comment

Choose a reason for hiding this comment

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

LGTM

@HuiGao-NV HuiGao-NV merged commit 2f768b7 into NVIDIA:main Jan 5, 2026
5 checks passed
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