Skip to content

[TRTLLM-11517][feat] Add TLLM_PROFILE_LOG_RANKS env var to control per-rank step logging#12263

Merged
longlee0622 merged 2 commits intoNVIDIA:mainfrom
longlee0622:log-all-ranks
Mar 18, 2026
Merged

[TRTLLM-11517][feat] Add TLLM_PROFILE_LOG_RANKS env var to control per-rank step logging#12263
longlee0622 merged 2 commits intoNVIDIA:mainfrom
longlee0622:log-all-ranks

Conversation

@longlee0622
Copy link
Collaborator

@longlee0622 longlee0622 commented Mar 17, 2026

Allow step logging in profile_step() to print on ranks other than rank 0 for debugging multi-rank issues. The env var TLLM_PROFILE_LOG_RANKS accepts comma-separated rank IDs (e.g. "0,1,3") or "all". Defaults to "0" to preserve existing behavior.

Summary by CodeRabbit

  • New Features
    • Added TLLM_PROFILE_LOG_RANKS environment variable to control profiling logs across distributed ranks. Set to "all" for all ranks or provide a comma-separated list of specific rank IDs. Default behavior (rank 0 only) is preserved when unset.

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

To see a list of available CI bot commands, please comment /bot help.

@longlee0622 longlee0622 requested a review from a team as a code owner March 17, 2026 01:16
@longlee0622 longlee0622 requested a review from byshiue March 17, 2026 01:16
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

Added configurable profiling log output control via environment variable PROFILE_LOG_RANKS_ENV_VAR_NAME. The profiler can now selectively log across specific ranks or all ranks instead of only rank 0, determined by parsing an environment variable that accepts either "all" or a comma-separated list of rank IDs.

Changes

Cohort / File(s) Summary
Profiler logging configuration
tensorrt_llm/_torch/pyexecutor/py_executor.py
Added PROFILE_LOG_RANKS_ENV_VAR_NAME constant and modified _profiler() function to parse environment variable for selective rank-based logging. Changed condition from rank-zero-only to flexible rank matching while preserving backward compatibility.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning PR description is incomplete. Required sections (Description, Test Coverage, and PR Checklist items) are missing or unfilled. Fill in all required template sections: provide detailed explanation under Description, list test cases under Test Coverage, and complete all PR Checklist items with checkboxes.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main feature being added—an environment variable to control per-rank step logging in profiling.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can use your project's `pylint` configuration to improve the quality of Python code reviews.

Add a pylint configuration file to your project to customize how CodeRabbit runs pylint.

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tensorrt_llm/_torch/pyexecutor/py_executor.py`:
- Around line 867-869: The CI formatting failure is due to YAPF style issues
around the logging conditional in py_executor.py (the block using start_time,
self.print_log, log_all_ranks, and self.dist.rank in log_ranks). Fix by running
the repository pre-commit hooks or YAPF formatter on
tensorrt_llm/_torch/pyexecutor/py_executor.py (or run `yapf -i` / your
configured formatter) so the conditional and surrounding lines are reformatted
to match project style, then commit the formatted file.
- Around line 843-850: The parsing of PROFILE_LOG_RANKS_ENV_VAR_NAME into
log_ranks (using variables log_ranks_str, log_all_ranks, log_ranks) is brittle
and will throw on empty/malformed tokens; update the parsing to trim whitespace,
filter out empty tokens, and validate each remaining token as an integer
(raising a clear ValueError that includes the env var name and the offending
token(s) if any token is not a valid integer), treat the special "all" case
case-insensitively as before, and ensure inputs like "", "0,", or "0,,2" do not
crash silently but either produce a sanitized set of ranks or a descriptive
error tied to PROFILE_LOG_RANKS_ENV_VAR_NAME.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 985f24c4-fb2c-4959-a165-f6a2c19e48e5

📥 Commits

Reviewing files that changed from the base of the PR and between 0eab5b6 and 7c7cf35.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/pyexecutor/py_executor.py

@longlee0622
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39156 [ run ] triggered by Bot. Commit: 8cd1abf Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39156 [ run ] completed with state FAILURE. Commit: 8cd1abf
/LLM/main/L0_MergeRequest_PR pipeline #30415 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

Link to invocation

@longlee0622
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39173 [ run ] triggered by Bot. Commit: 8cd1abf Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39173 [ run ] completed with state SUCCESS. Commit: 8cd1abf
/LLM/main/L0_MergeRequest_PR pipeline #30428 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

Link to invocation

@longlee0622
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39238 [ run ] triggered by Bot. Commit: 8cd1abf Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39238 [ run ] completed with state SUCCESS. Commit: 8cd1abf
/LLM/main/L0_MergeRequest_PR pipeline #30489 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

Link to invocation

@longlee0622
Copy link
Collaborator Author

/bot run --disable-fail-fast

1 similar comment
@longlee0622
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39326 [ run ] triggered by Bot. Commit: 8cd1abf Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39326 [ run ] completed with state ABORTED. Commit: 8cd1abf
/LLM/main/L0_MergeRequest_PR pipeline #30573 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

Link to invocation

…tep logging

Allow step logging in profile_step() to print on ranks other than rank 0
for debugging multi-rank issues. The env var TLLM_PROFILE_LOG_RANKS accepts
comma-separated rank IDs (e.g. "0,1,3") or "all". Defaults to "0" to
preserve existing behavior.

Signed-off-by: Jonas Li <6110159+longlee0622@users.noreply.github.com>
Signed-off-by: Jonas Li <6110159+longlee0622@users.noreply.github.com>
@longlee0622
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39366 [ run ] triggered by Bot. Commit: d424849 Link to invocation

@longlee0622 longlee0622 enabled auto-merge (squash) March 18, 2026 08:55
@tensorrt-cicd
Copy link
Collaborator

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

Link to invocation

@longlee0622
Copy link
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39438 [ run ] triggered by Bot. Commit: d424849 Link to invocation

@tensorrt-cicd
Copy link
Collaborator

PR_Github #39438 [ run ] completed with state SUCCESS. Commit: d424849
/LLM/main/L0_MergeRequest_PR pipeline #30665 completed with status: 'SUCCESS'

CI Report

Link to invocation

@longlee0622 longlee0622 merged commit a00eb0f into NVIDIA:main Mar 18, 2026
5 checks passed
limin2021 pushed a commit to limin2021/TensorRT-LLM that referenced this pull request Mar 19, 2026
…r-rank step logging (NVIDIA#12263)

Signed-off-by: Jonas Li <6110159+longlee0622@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.

3 participants