Skip to content

Comments

[TRTLLM-10851][feat] Add line_profiler tool for host overhead analysis.#11232

Merged
hyukn merged 3 commits intoNVIDIA:mainfrom
hyukn:feat/host_line_profiler
Feb 15, 2026
Merged

[TRTLLM-10851][feat] Add line_profiler tool for host overhead analysis.#11232
hyukn merged 3 commits intoNVIDIA:mainfrom
hyukn:feat/host_line_profiler

Conversation

@hyukn
Copy link
Collaborator

@hyukn hyukn commented Feb 3, 2026

Summary by CodeRabbit

  • New Features
    • Added comprehensive host-side performance profiling capabilities with line-level CPU overhead measurement.
    • Enabled profiling configuration through environment variables for flexible performance analysis.
    • Extended profiler functionality with stack trace support for enhanced performance debugging.

Description

This is an integrated host time analysis tool based on line_profiler Python tool, used to investigate the host bottleneck for modules invoked in py_executor loop.

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.

@hyukn hyukn requested review from QiJune and longlee0622 February 3, 2026 10:44
@hyukn hyukn requested a review from a team as a code owner February 3, 2026 10:44
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

This PR introduces host-side line-by-line profiling capabilities to measure CPU overhead in PyExecutor. It adds a comprehensive HostProfiler utility with configurable profiling targets, introspection-driven expansion logic, and lifecycle management. The PyExecutor integrates this profiler into its event loop wrapper to enable profiling during execution when enabled.

Changes

Cohort / File(s) Summary
PyExecutor Integration
tensorrt_llm/_torch/pyexecutor/py_executor.py
Added host_profiler_context import and integrated profiling into event loop wrapper. Configured enable_profiler based on TLLM_LINE_PROFILER_PATH environment variable during non-warmup execution. Extended PyTorch profiler with stack trace collection via with_stack=True.
Host Profiling Module
tensorrt_llm/tools/profiler/host_profile_tools/host_profiler.py
New module implementing comprehensive host profiling utility. Introduces ProfileTarget dataclass, default profiling configuration for PyExecutor components, introspection helpers to enumerate module functions and class methods, and HostProfiler class managing profiler lifecycle. Includes global profiler utilities and environment-driven configuration via LINE_PROFILER_FUNCTIONS variable.

Sequence Diagram

sequenceDiagram
    participant PyExecutor as PyExecutor Event Loop
    participant ProfilingContext as host_profiler_context
    participant HostProfiler
    participant LineProfiler as line_profiler
    participant TargetFunctions as Target Functions

    PyExecutor->>ProfilingContext: enter context (enable=enable_profiler)
    ProfilingContext->>HostProfiler: get_global_profiler()
    HostProfiler->>LineProfiler: start() profiling
    PyExecutor->>TargetFunctions: execute profiled code
    TargetFunctions->>LineProfiler: measure line-by-line overhead
    PyExecutor->>LineProfiler: collect execution data
    ProfilingContext->>HostProfiler: stop() profiling
    HostProfiler->>HostProfiler: save results to output_path
    ProfilingContext-->>PyExecutor: exit context
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning PR description includes a brief explanation of the feature but lacks critical sections. The 'Test Coverage' section is empty, and the PR title is missing (uses template placeholder). No ticket/issue reference is provided. Add PR title following format [TRTLLM-10851][feat] Add line_profiler tool for host overhead analysis, fill 'Test Coverage' section with relevant test information, and provide more detail on implementation specifics and design decisions.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding a line_profiler tool for host overhead analysis, with appropriate ticket reference and feature type indicator.
Docstring Coverage ✅ Passed Docstring coverage is 88.46% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

🤖 Fix all issues with AI agents
In `@tensorrt_llm/tools/profiler/host_profile_tools/host_profiler.py`:
- Line 1: Update the SPDX copyright header in host_profiler.py to reflect the
correct year 2026 instead of 2025; locate the top-of-file header comment
containing "Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES" and change the
year to 2026 so the SPDX header matches the latest modification year.
🧹 Nitpick comments (4)
tensorrt_llm/tools/profiler/host_profile_tools/host_profiler.py (4)

545-548: is_available property is misleading.

This property always returns True, but line_profiler may not be installed. The actual availability check happens in start() when importing. Consider checking if line_profiler can be imported.

♻️ Proposed fix
     `@property`
     def is_available(self) -> bool:
         """Check if line_profiler is available."""
-        return True
+        try:
+            import line_profiler  # noqa: F401
+            return True
+        except ImportError:
+            return False

628-630: Specify encoding when opening file.

When opening files for writing text, explicitly specify the encoding to ensure consistent behavior across platforms.

♻️ Proposed fix
-            with open(self.output_path, "w") as f:
+            with open(self.output_path, "w", encoding="utf-8") as f:
                 self._line_profiler.print_stats(stream=f)

610-613: Consider narrowing exception handling.

Static analysis flags catching blind Exception. While broad exception handling provides robustness here, consider logging the exception type or narrowing to expected exceptions (e.g., ImportError, AttributeError).


681-682: Global variable naming convention.

Per coding guidelines, Python global variables should use upper snake_case with prefix G. Consider renaming _global_profiler to G_GLOBAL_PROFILER or add a comment explaining the intentional deviation (e.g., if this is meant to be module-private).

♻️ Proposed fix
 # Global profiler instance for use in worker thread
-_global_profiler: Optional[HostProfiler] = None
+G_GLOBAL_PROFILER: Optional[HostProfiler] = None


 def get_global_profiler() -> Optional[HostProfiler]:
     """Get the global profiler instance."""
-    return _global_profiler
+    return G_GLOBAL_PROFILER

And update set_global_profiler and dump_profiler_functions accordingly.

@hyukn hyukn force-pushed the feat/host_line_profiler branch 2 times, most recently from a8029a8 to cf5833a Compare February 6, 2026 05:36
@hyukn
Copy link
Collaborator Author

hyukn commented Feb 6, 2026

/bot run --disable-fail-fast

@hyukn hyukn requested a review from kaiyux February 6, 2026 05:40
@tensorrt-cicd
Copy link
Collaborator

PR_Github #35070 [ run ] triggered by Bot. Commit: cf5833a

@tensorrt-cicd
Copy link
Collaborator

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

@hyukn hyukn requested a review from a team as a code owner February 6, 2026 08:59
@hyukn
Copy link
Collaborator Author

hyukn commented Feb 6, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35094 [ run ] triggered by Bot. Commit: 97a814d

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35094 [ run ] completed with state SUCCESS. Commit: 97a814d
/LLM/main/L0_MergeRequest_PR pipeline #27089 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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 9, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35273 [ run ] triggered by Bot. Commit: 9596f5a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35273 [ run ] completed with state SUCCESS. Commit: 9596f5a
/LLM/main/L0_MergeRequest_PR pipeline #27237 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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 9, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35341 [ run ] triggered by Bot. Commit: 9596f5a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35341 [ run ] completed with state SUCCESS. Commit: 9596f5a
/LLM/main/L0_MergeRequest_PR pipeline #27293 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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 10, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35385 [ run ] triggered by Bot. Commit: 5670101

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 10, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35432 [ run ] triggered by Bot. Commit: 62e2d5a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35432 [ run ] completed with state SUCCESS. Commit: 62e2d5a
/LLM/main/L0_MergeRequest_PR pipeline #27376 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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 10, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35511 [ run ] triggered by Bot. Commit: 62e2d5a

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35511 [ run ] completed with state SUCCESS. Commit: 62e2d5a
/LLM/main/L0_MergeRequest_PR pipeline #27418 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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 11, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35615 [ run ] triggered by Bot. Commit: dd12168

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 11, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35620 [ run ] triggered by Bot. Commit: 9972c74

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35620 [ run ] completed with state SUCCESS. Commit: 9972c74
/LLM/main/L0_MergeRequest_PR pipeline #27514 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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 11, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35640 [ run ] triggered by Bot. Commit: 9972c74

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35640 [ run ] completed with state DISABLED
CI server is currently disabled for unplanned maintenance. Estimated completion time: 8 AM PST on 2/11.

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 11, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35655 [ run ] triggered by Bot. Commit: 9972c74

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35655 [ run ] completed with state SUCCESS. Commit: 9972c74
/LLM/main/L0_MergeRequest_PR pipeline #27534 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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 11, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35675 [ run ] triggered by Bot. Commit: 9972c74

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35675 [ run ] completed with state SUCCESS. Commit: 9972c74
/LLM/main/L0_MergeRequest_PR pipeline #27554 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

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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 12, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35704 [ run ] triggered by Bot. Commit: 9972c74

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 12, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35704 [ run ] completed with state SUCCESS. Commit: 9972c74
/LLM/main/L0_MergeRequest_PR pipeline #27578 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

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35724 [ run ] triggered by Bot. Commit: 91c0973

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35724 [ run ] completed with state SUCCESS. Commit: 91c0973
/LLM/main/L0_MergeRequest_PR pipeline #27602 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

@hyukn
Copy link
Collaborator Author

hyukn commented Feb 12, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35785 [ run ] triggered by Bot. Commit: 91c0973

@tensorrt-cicd
Copy link
Collaborator

PR_Github #35785 [ run ] completed with state SUCCESS. Commit: 91c0973
/LLM/main/L0_MergeRequest_PR pipeline #27643 completed with status: 'SUCCESS'

@hyukn hyukn requested a review from chzblych February 13, 2026 01:56
@hyukn hyukn merged commit ed404f9 into NVIDIA:main Feb 15, 2026
5 checks passed
peihu-nv pushed a commit to peihu-nv/TensorRT-LLM that referenced this pull request Feb 19, 2026
…s. (NVIDIA#11232)

Signed-off-by: Yukun He <23156053+hyukn@users.noreply.github.com>
Signed-off-by: peihu-nv <259410613+peihu-nv@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