Initial Windows ROCm build support for FlashAttention-2 ROCm/aiter Triton backend#2428
Closed
Initial Windows ROCm build support for FlashAttention-2 ROCm/aiter Triton backend#2428
Conversation
astrelsky
reviewed
Mar 23, 2026
Comment on lines
+31
to
+34
| if sys.platform == "win32": | ||
| if " " in s: | ||
| return '"' + s.replace('"', '\\"') + '"' | ||
| return s |
There was a problem hiding this comment.
There is an undocumented function in subprocess for this that will handle all cases. Find my open pull request in pytorch, I used it there.
59de888 to
059ebbf
Compare
059ebbf to
3720731
Compare
1 task
Contributor
Author
|
Closing this in favor of the continuation PR by @micmelesse. Thanks for picking it up - I’m happy to help with anything if needed. |
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
Since AMD migrated FlashAttention-2's Triton backend to
ROCm/aiter, Windows users with AMD GPUs have been unable to build FA-2 at all - the entire build pipeline assumes Linux. This PR adds the necessary platform support so FA-2 can be built and used on Windows via the ROCm/HIP SDK.Note
This PR depends on Windows build support being merged in
Dao-AILab/flash-attentionfirst (or applied locally). See the corresponding PR: Dao-AILab/flash-attention#2384Technical Details
cpp_extension.pyHIP_PATH, bundled venv SDK packages (_rocm_sdk_devel,_rocm_sdk_core), and standard install paths (C:\Program Files\AMD\ROCm\*)-fPIC,-mcmodel=large, ELF linker flags) behindsys.platform != "win32"checksE:/foo→E$:/foo).pyd/.dllextensions and correct Windows linker flags (/SUBSYSTEM:WINDOWS,/DLL) for Python extension modules_quote()helper that uses double-quotes on Windows instead ofshlex.quote()(single quotes break hipcc include paths)chip_info.pyhipinfofallback alongsiderocminfofor GPU/CU detection (rocminfois not shipped with the Windows ROCm SDK)_extract_gfx_from_output()/_extract_cu_from_output()helperslibamdhip64ctypes probe is Linux-only)core.py--offload-arch=nativeon Windows (hipcc.exedoes not support it; replace with detected gfx string)/dev/nulland shell pipes inhip_flag_checker()andcheck_LLVM_MAIN_REVISION()/proc/sys/kernel/numa_balancingcheck on Windowsos.system("rm -rf ...")withshutil.rmtree/glob+os.removeparallel_state.pytorch.distributedimport for Windows ROCm builds where it may be unavailablesetup.pyhsa/assembly blobs on WindowsNinjaBuildExtension.run()to defer heavy imports until build timeTest Plan
from flash_attn import flash_attn_func.Test Result
gfx1200), ROCm7.13.0a20260321, PyTorch2.12.0a0+rocm7.13.0a20260321, Python3.12.Discovery
aiter.ops.triton.attention.mha.flash_attn_funcworks directly on Windows when a tuned config JSON is placed ataiter/ops/triton/configs/gfxNNNN-MHA-DEFAULT.json. Benchmarking againstflash_attn.flash_attn_funcongfx1200shows a 1.5x geomean speedup in favor of the aiter Triton kernel.Used this benchmark script with this file placed in:
aiter/ops/triton/configs/(otherwise it won’t find the config file and will error out).Results: