Fix Windows import errors by guarding torch.distributed with hasattr checks#172
Open
0xDELUXA wants to merge 1 commit intoROCm:main_perffrom
Open
Fix Windows import errors by guarding torch.distributed with hasattr checks#1720xDELUXA wants to merge 1 commit intoROCm:main_perffrom
torch.distributed with hasattr checks#1720xDELUXA wants to merge 1 commit intoROCm:main_perffrom
Conversation
Author
|
Just giving this PR a friendly nudge - it’s been hopping from I've reached out to TheRock as well, but it seems that, at least for now, they can't build Torch with full distributed support. In the meantime, we do need this change. This change is important for Windows compatibility, and we would appreciate a review from the |
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
On Windows ROCm,
torch.distributeddoes not expose certain internal attributes (e.g._all_gather_base).This causes an
AttributeErrorduring import inflash_attn.utils.distributed.Example (when loading a custom node in ComfyUI):
This PR guards access to these attributes using
hasattrchecks, preventing the import failure.This change is not expected to affect Linux behavior.
Technical Details
Adds hasattr checks before accessing private
torch.distributedattributes inflash_attn.utils.distributed.This improves ROCm compatibility for FlashAttention-2 on Windows.
Specifications:
OS: Windows 11
GPU: AMD Radeon RX 9060 XT (gfx1200)
Python: 3.12.10
PyTorch: 2.12.0a0+rocm7.12.0a20260218 (TheRock)
Triton: 3.6.0a0.post25 (triton-windows)
Test Plan
Functional testing on AMD Radeon RX 9060 XT (gfx1200)
Verified that FlashAttention-2 loads successfully
Ran existing Triton Flash Attention tests
Test Result
All existing Triton Flash Attention tests pass on gfx1200.
Submission Checklist