KEMBAR78
[TRTLLM-6295][test] Exit as early as possible and propagate exit status correctly for multi-node testing by chzblych · Pull Request #7739 · NVIDIA/TensorRT-LLM · GitHub
Skip to content

Conversation

@chzblych
Copy link
Collaborator

@chzblych chzblych commented Sep 15, 2025

…us correctly for multi-node testing

Summary by CodeRabbit

  • Bug Fixes

    • More reliable exit-status propagation across background tasks and leader/worker runs.
    • Improved cleanup behavior to avoid premature termination on errors.
  • Refactor

    • Enhanced error handling with stricter shell options for greater robustness.
    • Standardized log labels and added diagnostic logs (subprocess PID and exit codes) for easier troubleshooting.
  • Chores

    • Updated launcher path to the current maintained location.
    • Removed an obsolete launcher script.

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

  • 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.

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.

…us correctly for multi-node testing

Signed-off-by: Yanchao Lu <yanchaol@nvidia.com>
@chzblych chzblych requested review from a team as code owners September 15, 2025 14:21
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 15, 2025

📝 Walkthrough

Walkthrough

The TRT-LLM launcher script was relocated from jenkins/scripts to tensorrt_llm/llmapi, with slurm_run.sh updated to use the new path. The old launcher in jenkins/scripts was removed. The new launcher adds explicit exit-code handling, enhanced logging, and uses stricter shell options.

Changes

Cohort / File(s) Summary of Changes
Launcher relocation and Jenkins integration
jenkins/scripts/slurm_run.sh, jenkins/scripts/trtllm-llmapi-launch
Updated llmapiLaunchScript path to tensorrt_llm/llmapi/trtllm-llmapi-launch. Removed the old launcher script from jenkins/scripts. No other logic changes in slurm_run.sh.
New launcher implementation
tensorrt_llm/llmapi/trtllm-llmapi-launch
Introduced enhanced shell safety (set -Eeo pipefail), standardized log labels, and explicit exit-code capture/propagation for user task, leader, and worker paths. Added detailed diagnostics (subshell PID, exit codes) and ensured cleanup phases by temporarily disabling immediate exit on error where needed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor SLURM as SLURM/MPI
  participant L as Launcher (trtllm-llmapi-launch)
  participant Task as User Task (cmd)
  participant Leader as mgmn_leader_node
  participant Worker as mgmn_worker_node

  SLURM->>L: Start launcher with MPI env
  Note over L: Detect mpi_rank / mpi_size<br/>Set spawn proxy + IPC addr

  alt mpi_rank == 0 (Rank0)
    par Background subshell
      L->>Task: Run user task (capture task_exit_code)
      Task-->>L: Exit code
      L->>Leader: Stop MPI server (capture mpi_exit_code)
      Leader-->>L: Exit code
      L-->>L: Exit with task_exit_code if non-zero<br/>else mpi_exit_code
    and Leader path
      L->>Leader: Start mgmn_leader_node
      Leader-->>L: mgmn_leader_node_exit_code
      L->>L: Wait for subshell (capture subshell_exit_code)
      L-->>SLURM: Exit with subshell_exit_code if non-zero<br/>else mgmn_leader_node_exit_code
    end
  else mpi_rank > 0 (Workers)
    L->>Worker: Start mgmn_worker_node
    Worker-->>L: mgmn_worker_node_exit_code
    L-->>SLURM: Exit with worker code
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent 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 0c9430e and fdddff2.

📒 Files selected for processing (3)
  • jenkins/scripts/slurm_run.sh (1 hunks)
  • jenkins/scripts/trtllm-llmapi-launch (0 hunks)
  • tensorrt_llm/llmapi/trtllm-llmapi-launch (3 hunks)
💤 Files with no reviewable changes (1)
  • jenkins/scripts/trtllm-llmapi-launch
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: achartier
PR: NVIDIA/TensorRT-LLM#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.
Learnt from: moraxu
PR: NVIDIA/TensorRT-LLM#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.
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#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.
Learnt from: fredricz-20070104
PR: NVIDIA/TensorRT-LLM#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.
Learnt from: yibinl-nvidia
PR: NVIDIA/TensorRT-LLM#6506
File: examples/models/core/mixtral/requirements.txt:3-3
Timestamp: 2025-08-01T15:14:45.673Z
Learning: In TensorRT-LLM, examples directory can have different dependency versions than the root requirements.txt file. Version conflicts between root and examples dependencies are acceptable because examples are designed to be standalone and self-contained.
📚 Learning: 2025-07-28T17:06:08.621Z
Learnt from: moraxu
PR: NVIDIA/TensorRT-LLM#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:

  • jenkins/scripts/slurm_run.sh
  • tensorrt_llm/llmapi/trtllm-llmapi-launch
📚 Learning: 2025-08-06T13:58:07.506Z
Learnt from: galagam
PR: NVIDIA/TensorRT-LLM#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:

  • jenkins/scripts/slurm_run.sh
  • tensorrt_llm/llmapi/trtllm-llmapi-launch
📚 Learning: 2025-09-09T09:40:45.658Z
Learnt from: fredricz-20070104
PR: NVIDIA/TensorRT-LLM#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:

  • jenkins/scripts/slurm_run.sh
  • tensorrt_llm/llmapi/trtllm-llmapi-launch
📚 Learning: 2025-08-11T20:09:24.389Z
Learnt from: achartier
PR: NVIDIA/TensorRT-LLM#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:

  • jenkins/scripts/slurm_run.sh
  • tensorrt_llm/llmapi/trtllm-llmapi-launch
📚 Learning: 2025-08-21T00:16:56.457Z
Learnt from: farshadghodsian
PR: NVIDIA/TensorRT-LLM#7101
File: docs/source/blogs/tech_blog/blog9_Deploying_GPT_OSS_on_TRTLLM.md:36-36
Timestamp: 2025-08-21T00:16:56.457Z
Learning: TensorRT-LLM container release tags in documentation should only reference published NGC container images. The README badge version may be ahead of the actual published container versions.

Applied to files:

  • tensorrt_llm/llmapi/trtllm-llmapi-launch
⏰ 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 (6)
jenkins/scripts/slurm_run.sh (1)

48-48: LGTM! Path update aligns with launcher relocation.

The update to reference the launcher from its new location in tensorrt_llm/llmapi/ is correct and consistent with the architectural decision to move testing utilities closer to the code they support.

tensorrt_llm/llmapi/trtllm-llmapi-launch (5)

2-2: Excellent improvement to shell error handling!

The upgrade from basic error handling to set -Eeo pipefail provides comprehensive failure detection:

  • -E: Ensures ERR trap is inherited by shell functions
  • -e: Exits on any command failure
  • -o pipefail: Propagates failures from any command in a pipeline

This is particularly important for multi-node testing where silent failures could lead to incorrect test results.


73-91: Well-structured exit code propagation for rank 0 process.

The implementation correctly prioritizes task exit code over MPI server exit code, ensuring that test failures are properly reported even if the MPI server shuts down cleanly. The explicit logging of both exit codes aids in debugging multi-node test failures.


94-118: Robust leader node exit handling with proper subshell management.

The code correctly:

  1. Captures and logs the subshell PID for tracking
  2. Waits for the subshell to complete before exiting
  3. Prioritizes subshell exit code (which contains the task exit code) over MGMN leader node exit code
  4. Provides comprehensive logging at each step

This ensures that test failures from the background task are properly propagated through the MPI infrastructure.


120-128: Clean worker node exit code handling.

The worker node implementation appropriately captures and propagates the MGMN worker node exit code with clear logging for debugging purposes.


50-50: Consistent logging improvements enhance observability.

The standardization of log prefixes from mixed case (rank${mpi_rank}, rank0) to consistent title case (Rank${mpi_rank}, Rank0) improves log readability. The addition of explicit exit code logging at each critical point provides excellent visibility into multi-node test execution flow.

Also applies to: 79-79, 84-84, 99-99, 102-102, 105-105, 111-111, 123-123, 126-126

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description contains the repository template and placeholder text but lacks substantive content: the Description and Test Coverage sections are effectively empty and do not explain what was changed, why, or which tests validate the change beyond a brief fragment. Because required template fields are not populated with details, the description is incomplete and not review-ready. Please update the PR Description with a concise problem statement and summary of the implemented changes, add a Test Coverage section listing the relevant tests or reproduction steps (including multi-node test commands and expected outcomes), and complete the PR Checklist items (CODEOWNERS, docs, and test coverage) so reviewers can validate and approve the change.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Title Check ✅ Passed The PR title "[TRTLLM-6295][test] Exit as early as possible and propagate exit status correctly for multi-node testing" succinctly and accurately describes the main intent of the changeset — improving early exit and exit-code propagation for multi-node test launchers — and follows the repository's ticket/type prefix convention. It is specific, relevant to the modified/deleted launcher scripts, and clear for a reviewer scanning history.

@chzblych
Copy link
Collaborator Author

The modified script (jenkins/scripts/trtllm-llmapi-launch) has been already tested here. The exit status was propagated correctly, and the test could be exited as early as possible.

@chzblych chzblych changed the title [TRTLLM-6295][test] Exit as early as possible and propagate exit stat… [TRTLLM-6295][test] Exit as early as possible and propagate exit status correctly for multi-node testing Sep 15, 2025
@chzblych
Copy link
Collaborator Author

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

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18651 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #18651 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #14008 (Partly Tested) completed with status: 'SUCCESS'

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

@chzblych chzblych merged commit e5cead1 into NVIDIA:main Sep 16, 2025
9 of 11 checks passed
@chzblych chzblych deleted the exit-code branch September 16, 2025 01:59
Wong4j pushed a commit to Wong4j/TensorRT-LLM that referenced this pull request Sep 20, 2025
…us correctly for multi-node testing (NVIDIA#7739)

Signed-off-by: Yanchao Lu <yanchaol@nvidia.com>
MrGeva pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request Sep 21, 2025
…us correctly for multi-node testing (NVIDIA#7739)

Signed-off-by: Yanchao Lu <yanchaol@nvidia.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.

4 participants