Skip to content

Conversation

PerkzZheng
Copy link
Collaborator

@PerkzZheng PerkzZheng commented Jul 22, 2025

this MR fixes the deadlocks due to insufficient numSemaphores (for the multi-block mode in attention kernels). The trtllm-gen kernels might split the head into multiple CTAs, so more semaphores are needed actually.

Summary by CodeRabbit

  • New Features

    • Added a way to retrieve the number of multiprocessors available for attention operations.
  • Bug Fixes

    • Improved resource allocation for attention operations to better handle cases where computation is split across multiple processing units, enhancing stability and efficiency.

Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

Walkthrough

A new public accessor method was added to the AttentionOp class to expose the multiprocessor count. In the attention operation runner, the semaphore reservation logic was updated to consider both the number of attention heads and the device's multiprocessor count, ensuring sufficient semaphore allocation for kernel execution.

Changes

File(s) Change Summary
cpp/tensorrt_llm/common/attentionOp.h Added public getMultiProcessorCount() accessor to AttentionOp class.
cpp/tensorrt_llm/thop/attentionOp.cpp Updated semaphore reservation in Runner<T, AttentionOutT>::prepare to reserve max(heads × requests, multiprocessors).

Estimated code review effort

1 (~2 minutes)

Poem

In the warren of code, a new path appears,
Multiprocessor counts now calm our fears.
Semaphores line up, in orderly rows,
For each head and block, the right number grows.
With careful attention, our kernels take flight—
The rabbits approve, all semaphores right!
🐇✨


📜 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 8dc2506 and 6da0ae5.

📒 Files selected for processing (2)
  • cpp/tensorrt_llm/common/attentionOp.h (1 hunks)
  • cpp/tensorrt_llm/thop/attentionOp.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cpp/tensorrt_llm/common/attentionOp.h
  • cpp/tensorrt_llm/thop/attentionOp.cpp
✨ Finishing Touches
  • 📝 Generate Docstrings

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

@PerkzZheng PerkzZheng force-pushed the user/perkzz/mtp-deadlock branch from 8dc2506 to 6da0ae5 Compare July 22, 2025 15:36
@PerkzZheng
Copy link
Collaborator Author

/bot run

@PerkzZheng PerkzZheng requested review from yweng0828 and lfr-0531 July 22, 2025 15:39
@tensorrt-cicd
Copy link
Collaborator

PR_Github #12587 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #12587 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #9365 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

@PerkzZheng PerkzZheng merged commit 2193ad3 into NVIDIA:main Jul 23, 2025
3 checks passed
@PerkzZheng PerkzZheng deleted the user/perkzz/mtp-deadlock branch July 23, 2025 03:21
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