[Fix] fix the mha fwd_v3 segment fault in torch.compile(mode="reduce-overhead", fullgraph=True)#1794
Merged
[Fix] fix the mha fwd_v3 segment fault in torch.compile(mode="reduce-overhead", fullgraph=True)#1794
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds thread safety improvements via a mutex and temporary debug logging to the MHA (Multi-Head Attention) forward pass implementation, while also adjusting test configurations.
Key Changes:
- Added mutex protection for thread-safe access to the kernel implementation pointer map in C++ code
- Added extensive debug logging statements for troubleshooting purposes
- Modified test parameters (GQA head count and test configuration dimensions)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| csrc/cpp_itfs/mha_fwd.cpp | Added mutex for thread-safe kernel pointer map access and debug logging statements throughout |
| op_tests/test_mha.py | Commented out parameter, reduced test dimensions, changed GQA head count, and disabled seq_padding test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…iler from reordering operations
valarLip
approved these changes
Jan 13, 2026
valarLip
approved these changes
Jan 13, 2026
zhuyuhua-v
pushed a commit
that referenced
this pull request
Jan 14, 2026
…overhead", fullgraph=True) (#1794) * add log and mutex for test * add thread_local * value capture args * fix the Explicit assignment forces evaluation order and prevents compiler from reordering operations * delete some logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
fix the mha fwd_v3 segment fault in torch.compile(mode="reduce-overhead", fullgraph=True)
Technical Details
Test Plan
cd /root/rtfm-amd
source ./.venv/bin/activate
python -m wlt.models.rtfm.demo.server.server --model-config rtfm_10_06_512_chonky_meanflow --port 8083
Test Result
Submission Checklist