Skip to content

Conversation

QiJune
Copy link
Collaborator

@QiJune QiJune commented Jul 25, 2025

Summary by CodeRabbit

  • Refactor
    • Improved internal batch preparation and scheduling logic for request processing, resulting in a more streamlined and maintainable execution flow.

@QiJune QiJune requested a review from a team as a code owner July 25, 2025 10:02
@QiJune QiJune requested a review from Naveassaf July 25, 2025 10:02
Copy link
Contributor

coderabbitai bot commented Jul 25, 2025

📝 Walkthrough

Walkthrough

A new private method _prepare_and_schedule_batch was added to the PyExecutor class to consolidate batch preparation and scheduling logic. The main executor loops now delegate these responsibilities to this method, simplifying their flow. No changes were made to the pipeline parallel executor loop.

Changes

File(s) Change Summary
tensorrt_llm/_torch/pyexecutor/py_executor.py Added _prepare_and_schedule_batch method; refactored _executor_loop and _executor_loop_overlap to call it; no changes to _executor_loop_pp.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 725e206 and 1280cf3.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/pyexecutor/py_executor.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tensorrt_llm/_torch/pyexecutor/py_executor.py
⏰ 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
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@QiJune
Copy link
Collaborator Author

QiJune commented Jul 25, 2025

/bot run

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

🧹 Nitpick comments (1)
tensorrt_llm/_torch/pyexecutor/py_executor.py (1)

803-845: Good consolidation of batch preparation logic with room for improvement

The new method effectively consolidates duplicate logic from the executor loops, reducing code duplication and improving maintainability. The early return pattern and error handling are well implemented.

Consider adding a docstring to document this critical method:

+    def _prepare_and_schedule_batch(self):
+        """
+        Prepares and schedules a batch of requests for processing.
+        
+        Returns:
+            tuple: (scheduled_batch, iter_stats) if processing should continue,
+                   (None, None) if processing should stop.
+        """
-    def _prepare_and_schedule_batch(self):

Also consider making the warning message more descriptive:

-                logger.warning(
-                    "num_fitting_reqs=0 and fitting_disagg_gen_init_requests is empty, may not have enough kvCache"
-                )
+                logger.warning(
+                    "No fitting requests and no disaggregated generation init requests available. "
+                    "This may indicate insufficient KV cache resources or all requests are waiting for resources."
+                )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0aecf0 and 725e206.

📒 Files selected for processing (1)
  • tensorrt_llm/_torch/pyexecutor/py_executor.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

**/*.py: Python code 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 filenames should use snake_case (e.g., some_file.py).
Python classes should use PascalCase (e.g., class SomeClass).
Python functions and methods should use snake_case (e.g., def my_awesome_function():).
Python local variables should use snake_case. Prefix k for variable names that start with a number (e.g., k_99th_percentile).
Python global variables should use upper snake_case and prefix G (e.g., G_MY_GLOBAL).
Python constants should use upper snake_case (e.g., 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 interfaces that may be used outside a Python file, prefer docstrings over comments.
Comments in Python should be reserved for code within a function, or interfaces that are local to a file.
Use Google style docstrings for Python classes and functions, which can be parsed by Sphinx.
Attributes and variables in Python can be documented inline; attribute docstrings will be rendered under the docstring for the class.
Avoid using reflection in Python when functionality can be easily achieved without it.
When using try-except blocks in Python, limit the except to the smallest set of errors possible.
When using try-except blocks to handle multiple possible variable types in Python, keep the body of the try as small as possible, using the else block to implement the logic.

Files:

  • tensorrt_llm/_torch/pyexecutor/py_executor.py
**/*.{cpp,h,hpp,cc,cxx,cu,py}

📄 CodeRabbit Inference Engine (CODING_GUIDELINES.md)

All TensorRT-LLM Open Source Software code should contain an NVIDIA copyright header that includes the current year. This includes .cpp, .h, .cu, .py, and any other source files which are compiled or interpreted.

Files:

  • tensorrt_llm/_torch/pyexecutor/py_executor.py
🔇 Additional comments (2)
tensorrt_llm/_torch/pyexecutor/py_executor.py (2)

858-860: Clean integration of the consolidated method

The replacement of complex inline logic with the new _prepare_and_schedule_batch method call is well executed. The proper handling of return values and early exit condition maintains the existing behavior while improving code readability.


964-966: Consistent integration pattern maintained

The integration follows the same clean pattern as in _executor_loop, ensuring consistency across both executor implementations. The refactoring successfully eliminates code duplication while preserving existing functionality.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13001 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13001 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #9703 completed with status: 'FAILURE'

@QiJune
Copy link
Collaborator Author

QiJune commented Jul 28, 2025

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13121 [ run ] triggered by Bot

@QiJune QiJune enabled auto-merge (squash) July 28, 2025 02:29
@tensorrt-cicd
Copy link
Collaborator

PR_Github #13121 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #9818 completed with status: 'FAILURE'

@QiJune
Copy link
Collaborator Author

QiJune commented Jul 28, 2025

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13137 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #13137 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #9832 completed with status: 'SUCCESS'

@QiJune QiJune merged commit 4efc649 into NVIDIA:main Jul 28, 2025
3 checks passed
NVShreyas pushed a commit to NVShreyas/TensorRT-LLM that referenced this pull request Jul 28, 2025
Ransiki pushed a commit to Ransiki/TensorRT-LLM that referenced this pull request Jul 29, 2025
lancelly pushed a commit to lancelly/TensorRT-LLM that referenced this pull request Aug 6, 2025
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