You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HIP] [FlyDSL] [JIT] Add Windows RDNA CK FMHA support - #4340
After #2699 supplied the Windows JIT infrastructure, CK FMHA still needs RDNA targets and safe blob-generation arguments. This PR now keeps that CK/RDNA increment on current main.
Preserve main's Windows builder and FileBaton liveness implementation.
Stage CK generation with Windows argument lists, including paths with spaces, while retaining transactional rollback.
Normalize Windows RDNA WGP counts to physical CUs, supply gfx1100/1101/1102/1103/1150/1151/1200/1201 offline defaults, and pass targets to the existing FMHA recipes.
Keep optional dtype imports independent of the native toolchain, guard FlyDSL dispatch when FlyDSL is unavailable, and honor explicit MAX_JOBS.
Remove the redundant _USE_MATH_DEFINES block from activation_kernels.cu; the Windows HIP compiler flags already define it globally.
Use package imports in the CPU target tests.
Merge upstream main at e6ded21 in 518c3e6 to preserve its prequantized FP8 Q/K/V descale routing through native CK; skip FlyDSL for descale inputs.
Preserve multiple option values and generate every requested GPU_ARCHS target in JIT and static PREBUILD_KERNELS recipes; reject unsupported runtime batch-prefill and exclude its prebuild recipes.
Windows native mode follows main's automatic ROCm-toolchain detection; AITER_TRITON_ONLY=1 opts out of native imports and builds.
Validation: focused target and optional FlyDSL-dispatch CPU tests pass (18 tests, 26 target subtests; the standalone dispatch test passes 11 cases). The pinned CK commit af9e1d1f1ae347c22feeb08fd2d42645075e0c5d generated gfx1150/gfx1200 forward instances for FP16 and BF16; this is code generation, not device compilation. On gfx1151, the public aiter.flash_attn_func passed FP16/BF16 comparisons against FP32 MATH SDPA for B=1, S=64, H=4, D=64 (seed 4340), with FlyDSL discovery forced absent and imports guarded in the test process. That absence was simulated on the local environment. Ragua1 also reported gfx1150 Radeon 890M FP16/BF16 correctness in the review thread, before this import guard was added. gfx1200 hardware runtime validation remains welcome.
Windows native FMHA validation used a separate CK checkout carrying the two __builtin_memcpy substitutions from closed, unmerged CK PR 10067. The unmodified CK pin fails Windows device compilation. Use a short AITER_JIT_DIR to avoid Windows path-length failures.
The full transaction suite retains the same 14 failures and one error as unmodified main on this Windows host. gfx10 FMHA and RDNA batch-prefill have no instances in the current CK generator, so they are not advertised as supported.
Native FP16 attention (B=1, H=16, D=64, S=128/512/1024) is finite and matches an FP32 reference within 0.0004883 absolute error. It is 2.03x/1.11x/1.15x faster than default PyTorch SDPA by median GPU-event latency; profiling confirms SDPA selects Flash Attention. ComfyUI SDXL (1024x1024, 20 steps, three alternating pairs) completed through an explicit temporary ModelPatcher attention adapter: median sampler time 15.257 s Aiter versus 15.513 s Flash SDPA, with 8,400 timed native calls and zero adapter fallbacks. The observed 1.7% difference is too small to claim a general speedup; stock ComfyUI does not select Aiter automatically. Full conditions and output checks are in the validation comment.
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds an opt-in native HIP + Composable Kernel (CK) build/runtime path for Windows RDNA GPUs while keeping the default Windows experience as Triton-only, and updates JIT/build utilities to follow Windows toolchain and binary conventions.
Changes:
Introduce AITER_ENABLE_HIP=1 as the Windows opt-in gate for building/using native HIP/CK, and adjust packaging to avoid Linux/CDNA-only artifacts on Windows.
Port/adjust JIT extension build + GPU detection to work on Windows (MSVC env setup, .pyd naming, temp paths, rocminfo replacements via PyTorch where needed).
Ensure CK FMHA codegen receives explicit RDNA targets and add regression tests for target/default selection.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
File
Description
setup.py
Adds Windows opt-in gating for HIP/CK, skips FlyDSL + HSA bundling on Windows, and includes .pyd artifacts in package data.
README.md
Documents the experimental native Windows ROCm flow and the AITER_ENABLE_HIP opt-in.
pyproject.toml
Makes flydsl a non-Windows-only build requirement via environment marker.
op_tests/test_windows_rdna_ck_targets.py
Adds regression tests validating RDNA offline defaults and CK --targets propagation behavior.
csrc/kernels/activation_kernels.cu
Adds Windows-specific math header handling for hipcc/UCRT.
aiter/utility/dtypes.py
Uses PyTorch-based arch detection on Windows for FP8 dtype selection and defers some imports.
aiter/ops/mha.py
Passes runtime-derived CK --targets into FMHA codegen commands.
aiter/jit/utils/torch_guard.py
Adjusts torch.library registration naming to match fragment-library conventions.
aiter/jit/utils/mha_recipes.py
Adds helper to emit CK --targets for non-gfx9 arch at runtime.
aiter/jit/utils/file_baton.py
Handles Windows PID liveness checks where WinError behavior differs from POSIX.
aiter/jit/utils/cpp_extension.py
Adds Windows-aware extension/link conventions and ninja rule differences for MSVC/hipcc builds.
aiter/jit/utils/chip_info.py
Adds Windows GPU arch/CU detection via PyTorch and supports direct-import patterns.
aiter/jit/utils/build_targets.py
Adds RDNA arch → default CU mappings for offline/cross builds.
aiter/jit/core.py
Uses cross-platform temp dirs, updates module filename handling to use platform extension, and removes POSIX-only shell/file ops.
aiter/init.py
Makes Windows native enablement opt-in (or auto-on if bundled .pyd exists) and adjusts imports for Windows distributed availability.
I have the hardware this PR lists but could not test on, so here is a build-and-run report.
✅ It builds and runs. CK FMHA forward compiles clean (105 TUs, 109 objects, 4.0 MB .pyd) and the kernels execute correctly — max_rel_err 4.2e-04 … 7.6e-04 vs scaled_dot_product_attention, identical to the Triton flash-attention path to every significant digit.
✅ Your --targets diagnosis is exactly right. Measured: the ck-tile default emits 0 gfx11 kernels, --targets gfx1101 emits 5 888.
✅ Your performance claim holds on a second RDNA GPU. You report 1.14–1.28× over SDPA on gfx1151; I get 1.10–3.24× on gfx1101, and 1.15–1.76× over Triton flash-attention.
⚠️But a stock TheRock-on-Windows box cannot get to any of it — four reasons in this PR, three outside it.
❓ One design question: GFX_CU_NUM_MAP mixes CU and WGP counts.
Environment: RX 7800 XT (gfx1101, 60 CU / 30 WGP), Windows 11 26200, torch 2.10.0+rocm7.14.0a20260611 (HIP 7.14.60850, TheRock gfx110X-all wheels), MSVC 14.51.36231, Windows SDK 10.0.26100, bundled clang 23, CK submodule f33252c, PR head 71bda0e.
shape (b, q, kv, heads, dim)
CK FMHA
Triton FA 2.8.3.post1
torch SDPA
CK vs Triton
CK vs SDPA
(2, 4096, 4096, 10, 64)
2.449 ms
2.813 ms
6.070 ms
1.15×
2.48×
(2, 1024, 1024, 20, 64)
0.423 ms
0.616 ms
0.936 ms
1.46×
2.21×
(2, 4096, 77, 10, 64)
0.267 ms
0.468 ms
0.294 ms
1.76×
1.10×
(1, 4608, 4608, 24, 128)
5.598 ms
7.301 ms
18.117 ms
1.30×
3.24×
Cross-attention is the one shape where CK's margin over SDPA nearly vanishes, and it is also the shape where SDPA beats Triton flash-attention outright — worth knowing if you tune per-shape.
Measurement protocol, correctness, and one caveat about the SDPA column
Median of 20 iterations after 5 warmups, torch.cuda.synchronize() per iteration, fp16, fixed seed, all three implementations in one process. Correctness reference is scaled_dot_product_attention forced to the MATH backend (fp32 accumulation) — never another flash implementation, since that cannot catch a shared bug.
The SDPA column requires TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1. Without it, can_use_flash_attention and can_use_efficient_attention both return False on this build and SDPA silently resolves to MATH — which is 6.6–9.5× slower and would inflate the ratios above to 6–54×. Those numbers would be meaningless, so the flag is on. Flagging it because it is easy to benchmark against the wrong baseline here by accident.
Ratios reproduce across three runs including one with the measurement order reversed (CK last instead of first): CK vs Triton 1.21/1.20/1.15 · 1.50/1.46/1.46 · 1.76/1.77/1.76 · 1.30/1.27/1.30.
First-call JIT cost is 341.8 s for mha_fwd_fp16_nbias_nmask_nlse_ndropout_nqscale (105 CK TUs at -j 12). Since the module name encodes dtype/bias/mask/lse/dropout/qscale, each distinct combination is a separate ~6-minute build, cached on disk afterwards. Not a defect, but it is the number that decides adoptability for interactive workloads, so it may be worth putting in the README next to the perf figures.
This is op-level only — no end-to-end diffusion number yet.
Four things in this PR that block a stock box
(a) _find_rocm_home() does not recognise TheRock's runtime wheels. Guess #2 in jit/utils/cpp_extension.py probes only _rocm_sdk_devel, but TheRock's Windows nightlies install _rocm_sdk_core, which already contains bin/hipconfig.exe, bin/hipcc.exe, include/hip/ and lib/llvm/amdgcn/bitcode/. On a default install get_hip_version() raises RuntimeError: ROCm version file not found, so import aiter fails outright with AITER_ENABLE_HIP=1. Guess #3 (shutil.which("hipcc")) cannot rescue it either — TheRock's hipcc lives inside site-packages and is not on PATH. Adding _rocm_sdk_core to the probed list fixes it: _rocm_sdk_core/.info/version and include/hip/hip_version.h are both present and parse with the existing code.
(b) check_compiler_ok_for_platform() lost torch's Windows early-return, so every JIT build fails. The vendored copy's docstring still promises "and always True for Windows", but the implementation no longer does it. TORCH_DONT_CHECK_COMPILER_ABI=1 works around it; restoring the two-line guard looks like the actual fix.
Why it fails rather than degrading
Compare torch/utils/cpp_extension.py (lines 411–412 on main):
ifIS_WINDOWS:
returnTrue
Without it, cl is not in _accepted_compilers_for_platform(), so control reaches subprocess.check_output([compiler, "-v"]). MSVC exits 2 on -v, and that call sits outside the try block in get_compiler_abi_compatibility_and_version(), so an uncaught CalledProcessError propagates:
subprocess.CalledProcessError: Command '['cl', '-v']' returned non-zero exit status 2.
RuntimeError: [aiter] build [module_aiter_core] ... failed !!!!!!
(c) --offload-arch is emitted twice. The generated build.ninja contains --offload-arch=gfx1101 -fno-gpu-rdc --offload-arch=native — the arch flags derived from torch, plus an appended native. Every TU compiles the same architecture twice. Harmless, but it doubles an already long CK build.
(d) A question rather than a defect report: GFX_CU_NUM_MAP mixes CU and WGP counts. The new Windows branch in get_cu_num_custom_op() returns torch.cuda.get_device_properties(0).multi_processor_count, which on RDNA is the WGP count, while the rocminfo path used elsewhere reports CU. Same physical GPU, all three numbers measured:
source
value for gfx1101 (RX 7800 XT)
rocminfo
60
torch.multi_processor_count (new Windows path)
30
GFX_CU_NUM_MAP["gfx1101"]
60
So get_build_targets() yields ('gfx1101', 30) on a live Windows box but ('gfx1101', 60) for the same target built offline, while build_tune_dict() keys its dispatch table on (gfx, cu_num, M, N, K). The table also looks internally inconsistent: gfx1151: 20 is the WGP number for the 40-CU Radeon 8060S, whereas gfx1100: 96, gfx1101: 60, gfx1102: 32, gfx1103: 12 and gfx1201: 64 are all CU numbers — i.e. only the row you had hardware for matches what the code detects. FMHA has no cu_num-keyed tuning so it is unaffected, but the CK GEMM modules would be.
Which convention do you want to be canonical? Happy to send a PR either way, but normalising the table to WGP and normalising the Linux path to CU are very different changes and it is your call.
Three blockers outside this PR, for context — none of them yours to fix
Listed only so that "it builds for me" and "it does not build for them" can both be true. I am filing these separately.
HIP_PATH hijack. The legacy AMD HIP SDK installers set HIP_PATH machine-wide (mine pointed at …\ROCm\6.4\, with 6.2 and 7.1 also installed). clang honours it over --rocm-path, so the JIT compiles against ROCm 6.4 headers while linking torch's 7.14 runtime — here it surfaced as amd_warp_functions.h: use of undeclared identifier '__AMDGCN_WAVEFRONT_SIZE'. A silent ABI mismatch would have been the worse outcome. Since Windows ROCm users often have a legacy HIP SDK installed, it may be worth having the JIT clear or override HIP_PATH explicitly.
clang header include order. The clang in the ROCm 7.14 nightly includes <cmath> before __clang_cuda_math_forward_declares.h in __clang_hip_runtime_wrapper.h, which is fatal against MSVC STL ≥ 14.51. Both llvm/llvm-project@main and ROCm/llvm-project@amd-staging have the correct order, with a comment explaining why, so this looks like a packaging regression; reporting to TheRock. ⚠️ Worth knowing if anyone hits it: the obvious workaround -Xclang -fno-cuda-host-device-constexprbreaks all of CK, because ck_tile's ignore_t relies on constexpr members being implicitly __host__ __device__. The fix is the include order, not the constexpr semantics.
Happy to re-run anything on gfx1101 — different shapes, dtypes, an end-to-end diffusion workload, or your own FMHA tests. I can also send PRs for (a), (b) and (c) against this branch if that is useful.
@Ragua1 Thank you for the exceptionally detailed gfx1101 report. The independent correctness, codegen-count, and latency results are very useful, especially the AOTriton SDPA caveat and the cross-attention result.
I addressed all four PR-local items in cccf0d8b8, then merged current main in 83bc0eff4:
(a) TheRock runtime discovery:_find_rocm_home() now probes _rocm_sdk_core first and falls back to _rocm_sdk_devel, before PATH lookup. On my stock wheel environment it now resolves ROCM_HOME to _rocm_sdk_core and reads HIP 7.14.60850 successfully.
(b) Windows compiler check: restored the Windows early return in check_compiler_ok_for_platform() and restored the Windows/MSVC branch in the subsequent ABI-version check. With MAX_JOBS=32, AITER_ENABLE_HIP=1 now builds and loads module_aiter_core successfully from a normal PowerShell session.
(c) duplicate offload arch: Windows now resolves GPU_ARCHS=native through PyTorch to the explicit live gfx target before flag construction, and user arch flags are considered before _get_rocm_arch_flags(). The generated Ninja file contains exactly one --offload-arch=gfx1151 and no --offload-arch=native.
(d) CU/WGP convention: physical CU count is now canonical, matching rocminfo, the existing CDNA tuning tables, and the cu_num dispatch keys. TheRock's RDNA multi_processor_count WGP value is converted to CUs (2 CUs/WGP), and the gfx1151 offline default is corrected from 20 to 40. On the live gfx1151 host, live and offline selection now both produce ('gfx1151', 40). CU_NUM remains the override for binned devices.
I also added your 341.8 s / 12-worker first-call JIT measurement to the Windows README section with a link back to your report.
Validation after merging current main:
Windows target/argv/CU regression suite: 7 passed, 15 subtests passed
Triton-only import plus aiter.ops.triton.activation: passed, with aiter.dtypes available and no native JIT
Native Windows import: built and loaded module_aiter_core with 32 workers
live target: gfx1151, 40 physical CUs
Ruff, compileall -j 32, and git diff --check: passed
I left the three external toolchain/package issues untouched as requested. Thanks again for testing this on gfx1101 and for catching the stock-install path gaps.
Re-verified on gfx1101 at 83bc0eff4 — all four items confirmed fixed. Two follow-ups below, neither blocking.
Thanks for turning these around so fast. I re-ran the whole thing on the RX 7800 XT with the three workarounds from my last report deliberately removed, so the build had to either prove the fixes or fail.
item
how it was checked
result
(a)
ROCM_HOME / ROCM_PATH unset
_find_rocm_home() → …\site-packages\_rocm_sdk_core. The full AITER_ENABLE_HIP=1 build now runs with no ROCm environment variable set at all
build.ninja for the same module: 71bda0e had --offload-arch=gfx1101 --offload-arch=native, 83bc0eff4 has --offload-arch=gfx1101 -fno-gpu-rdc. I also no longer need PYTORCH_ROCM_ARCH to stop the gfx110X-all wheel expanding to four archs — the explicit target short-circuits _get_rocm_arch_flags()
(d)
live vs offline, same device
multi_processor_count 30 → 60 = GFX_CU_NUM_MAP['gfx1101'] = rocminfo; get_build_targets_env() → [('gfx1101', 60)]. CU-as-canonical is the right call — it matches the cu_num dispatch keys
Rebuilt from a wiped cache: module_aiter_core33.7 s, CK FMHA mha_fwd_fp16_nbias_nmask_nlse_ndropout_nqscale333.6 s (was 341.8 s), kernels load and execute, max_rel_err 4.23e-04 … 7.61e-04 vs SDPA MATH.
Perf reproduces the table from my last comment, over three runs in both measurement orders: CK vs AOTriton SDPA 2.48–2.56× / 2.15–2.25× / 0.99–1.10× / 3.19–3.24×, CK vs Triton flash-attention 1.15–1.16× / 1.47–1.55× / 1.74–1.99× / 1.30–1.31×. All eight ratios land within ~3 % of what I posted.
(a′) One question on the probe order in _find_rocm_home()
The loop is ("_rocm_sdk_core", "_rocm_sdk_devel"), so core wins when both are installed. On my box that is exactly the fix — core is all I have. But core is also the thinner tree: its include/ contains only CL, amd_comgr, hip, hsa, hsakmt — no hipsparse/, no hipblas/ — while torch's ATen/hip/HIPContextLight.h:11 includes <hipsparse/hipsparse.h>. That is why I still have to add an -isystem pointing at a math-library header tree copied out of a legacy ROCm install.
So if rocm-sdk-devel does ship those headers, preferring core over devel would pick the root that cannot satisfy torch's own includes. I can't test the both-installed case here. Did your successful build have rocm-sdk-devel installed, and if so, where did hipsparse.h resolve from? If devel supplies it, flipping the tuple to ("_rocm_sdk_devel", "_rocm_sdk_core") keeps my runtime-only case working and fixes the other one.
(d′) The 2 CUs/WGP conversion is now a silent assumption
torch_processor_count_to_cu() is keyed on the gfx11/gfx12 prefix and validated on two devices (30 → 60 here, 20 → 40 on gfx1151); gfx1201 32 → 64 is asserted in the test without hardware behind it. If a future TheRock/HIP build ever reports physical CUs on RDNA instead of WGPs, this doubles silently and every (gfx, cu_num, M, N, K) lookup misses.
GFX_CU_NUM_MAP already holds the physical count for every RDNA target you list, so cross-checking the normalised live value against it and logging on mismatch would make that visible instead of silent. It can't be an assert — binned parts legitimately differ, which is what CU_NUM is for.
Environment as before, only aiter moved (83bc0eff4): RX 7800 XT / gfx1101, Windows 11 26200, torch 2.10.0+rocm7.14.0a20260611 (HIP 7.14.60850, TheRock gfx110X-all wheels, no rocm-sdk-devel), MSVC 14.51.36231, Windows SDK 10.0.26100, bundled clang 23, CK submodule f33252c.
Still applied on top, and none of it yours — listing it so "builds for me" stays auditable: HIP_PATH cleared, a cmath shim for the nightly clang's include order, -isystem for the math-library headers the runtime wheels don't ship, and __builtin_memcpy in ck_tile — that last one is ROCm/rocm-libraries#10067, and without it no ck_tile translation unit compiles under MSVC at all, so it is effectively a cross-repo prerequisite for native Windows CK. Worth knowing before this merges.
@Yasei-no-otoko — apologies for the long silence, and thank you for this; there's real work here that nothing else covers.
Context first: #2699 ("[HIP] [JIT] Add Windows support") was merged on 8 October as b1cdc19eb. It overlaps this PR on cpp_extension.py, chip_info.py, jit/core.py, setup.py, pyproject.toml, aiter/__init__.py and file_baton.py, so this is now CONFLICTING against main.
But the overlap is partial, and the non-overlapping half is the part I care about. As far as I can tell #2699 has no equivalent of:
aiter/jit/utils/blob_gen.py — the CK blob generator invocation, including quoting for paths with spaces
aiter/jit/utils/build_targets.py — RDNA WGP→CU normalization (torch reports WGPs on RDNA, so the count needs doubling)
aiter/jit/utils/mha_recipes.py — passing --targets gfx11xx into CK codegen
aiter/utility/dtypes.py and csrc/kernels/activation_kernels.cu
the offline build defaults for gfx1100/1101/1102/1103/1151/1201
That is CK and FMHA coverage on RDNA, which #2699 explicitly does not provide — its author noted that ops running a CK-tile blob generator were out of scope. So this is a real increment, not a duplicate.
What I'd suggest, if you're willing: rebase onto current main and keep the CK/RDNA half, dropping the changes that now duplicate #2699. I'd rather you make that call than have me resolve the conflicts — #2699 made some non-obvious choices that a merge could silently undo (for example, FileBaton._pid_alive deliberately stops using os.kill(pid, 0) on Windows, since CPython maps it onto TerminateProcess and the liveness check would kill the builder it was checking).
Two smaller notes on op_tests/test_windows_rdna_ck_targets.py:
It's a CPU-only unittest built on mock.patch.dict, so it will run on the GPU runners that op_tests/ is wired to without needing one. We have a broader problem with CPU-only tests living in op_tests/ and I'm addressing that separately — not something to fix in this PR, just flagging it so the eventual move doesn't surprise you.
It imports via sys.path.insert on aiter/jit/utils. That works, but it's the same pattern that makes chip_info.py's bare from cpp_extension import ... order-dependent. Worth using the package path if it's no trouble.
Happy to review promptly once it's rebased — and if you'd prefer to hand the CK/RDNA part over rather than carry it yourself, tell me and we'll find someone to pick it up with credit to you.
Addressed all four findings from Copilot review 5453793685 in 8ccc139. Windows argv preserves multi-value options, CK receives all requested architectures, batch-prefill rejects unsupported targets before codegen, and Windows native-mode documentation follows current main. Ten focused CPU regression tests passed. GitHub's Reviewers sidebar now confirms a formal Copilot re-review is in progress.
github-actionsBot
changed the title
Add Windows RDNA CK FMHA support
[HIP] [JIT] Add Windows RDNA CK FMHA support
Oct 8, 2026
Canonicalize positive MAX_JOBS values before returning
aiter/jit/core.py:806
Positive values accepted by int() are returned without normalization, but _get_num_workers() only honors digit-only strings. For example, MAX_JOBS=+32 (also accepted by setup.py) reaches this early return and is then silently replaced by the CPU-derived default instead of honoring the explicit override. Canonicalize the parsed value before returning and add a non-canonical positive-value regression.
For the CK side: rocm-libraries#13393 fixes the reference to __host__ function 'memcpy' in __device__ function error for any ck_tile kernel on the buffer addressing path on Windows, which also blocks the CK layernorm ops here. Once it merges, a CK submodule bump should let this PR drop the separate patched CK checkout.
The main PR-local issues now look addressed. The remaining blockers are dependency and validation:
Please update the AITER CK submodule to a commit containing the __builtin_memcpy fix, then rebase onto current main.
Re-run the Windows validation from a clean checkout using the pinned submodule, without an external CK_DIR or local patches.
Since this PR advertises gfx1200/gfx1201 support, please add at least one real gfx12 compile-and-run correctness result for FP16/BF16 CK FMHA. @0xDELUXA, could you help validate this on gfx1200?
Please run the full CI on the final head.
Once those are complete, this should be ready for final review.
Validated on gfx1200 (Radeon RX 9060 XT, Windows 11, torch 2.16.0a0+rocm10.2.0a20261007, HIP 7.17).
Clean worktree of the PR head f788f14, no CK_DIR, no local patches. The only change is the CK submodule moved from af9e1d1 to 509552a, the first ROCm/composable_kernel commit with the __builtin_memcpy fix (ROCm/rocm-libraries#13393, merged today). Bumping the pin to that commit or later should cover the first item above.
The JIT built module_aiter_core and the four FMHA forward modules (fp16/bf16 x mask/nmask) for gfx1200 without errors. aiter.flash_attn_func vs an FP32 math SDPA reference passed 24/24 cases (tolerance 2e-3 fp16, 1.6e-2 bf16); max abs error:
B
S
H
D
fp16
fp16 causal
bf16
bf16 causal
1
64
4
64
0.00033
0.00059
0.0029
0.0066
2
128
8
64
0.00046
0.00096
0.0025
0.0076
4
256
8
32
0.00038
0.00096
0.0038
0.0079
1
333
4
128
0.00024
0.00103
0.0017
0.0074
2
512
8
128
0.00041
0.00125
0.0030
0.0078
1
1024
16
64
0.00021
0.00095
0.0016
0.0082
test_windows_rdna_ck_targets.py, test_mha_optional_flydsl.py and test_dtype_parser.py pass (19 tests, 87 subtests).
Thanks @0xDELUXA. This confirms that the CK bump needs to be included in this PR rather than left as an external prerequisite.
The 24/24 gfx1200 result validates f788f14 with CK manually moved to 509552a; it does not validate the currently submitted dependency tree. Please update the CK submodule to 509552a or a verified later commit containing ROCm/rocm-libraries#13393, remove the external CK_DIR / manual-patch workaround, and rerun the clean-checkout Windows gfx1200 FP16/BF16 validation and full CI on the final head.
Unless another CK bump PR is guaranteed to merge first and this PR is rebased on top of it, we should not merge a feature whose default checkout cannot reproduce the validated path.
After reviewing this against AITER's longer-term backend direction, I would like to adjust the scope before we add more CK-specific Windows surface.
AITER expects CK support to decrease over time, while Windows should primarily follow the Triton/FlyDSL path. Please separate the backend-neutral Windows improvements from the CK FMHA enablement:
Keep generally useful fixes such as Windows codegen argument/path handling, JIT cache transaction behavior, RDNA CU/WGP and multi-arch target parsing, and optional FlyDSL handling.
Do not make the CK submodule bump, CK FMHA target policy, or new CK PREBUILD behavior part of the general Windows infrastructure change unless there is a concrete Windows consumer that requires CK and cannot use Triton/FlyDSL.
Please hold the CK-specific portion while we define that requirement. If needed, move the backend-neutral fixes into a smaller PR so they can land independently.
The Windows CK validation already done is useful evidence, and this scope adjustment is about AITER's maintenance boundary rather than the quality of that work. The goal is to avoid establishing a new CK path that our Windows CI does not exercise and that we do not intend to expand long term.
Follow-up after checking the current FlyDSL and Triton FMHA coverage, here is the maintainer decision for this PR:
Please split out and retain the backend-neutral Windows work: code-generation argument/path handling, JIT cache transaction behavior, RDNA CU/WGP and multi-architecture parsing, and optional FlyDSL handling.
Do not include the CK submodule bump, CK FMHA target policy, or CK PREBUILD expansion in that infrastructure change.
For Windows attention, use Triton as the current default for gfx110x/gfx115x/gfx1200 and for dense/varlen forward and backward coverage. These kernels already exist, and gfx1151 has architecture-specific tuning.
We should port the FlyDSL compiler/runtime and packaging to Windows. After that port, the existing gfx1201 dense forward kernel can be reused; the remaining architecture, varlen, and backward gaps should continue to fall back to Triton while FlyDSL coverage grows.
The CK correctness and performance measurements in this PR are useful. In particular, the reported gaps against Triton should become concrete Triton/FlyDSL tuning targets, but they are not sufficient reason to establish a new Windows CK support surface that our CI does not exercise and that we do not intend to expand long term.
We can reconsider a CK-specific exception only if there is a named Windows consumer and matched-shape evidence that the required functionality or performance cannot reasonably be provided by Triton/FlyDSL. For the current scope, please proceed with the backend-neutral split and hold the CK-specific portion.
We should port the FlyDSL compiler/runtime and packaging to Windows. After that port, the existing gfx1201 dense forward kernel can be reused; the remaining architecture, varlen, and backward gaps should continue to fall back to Triton while FlyDSL coverage grows.
My PR over at ROCm/FlyDSL#395 was closed because there are currently no plans to support or maintain Windows. I wonder what that means for ROCm/FlyDSL#1239, then.
Another thing worth noting is that, as far as I know, AOTriton also uses FlyDSL kernels on Windows, so this seems a bit confusing.
Separately, CK can be used on Windows through FlashAttention or xFormers if they are built from source.
Thanks, this is important context, and you are right to challenge the FlyDSL assumption in my previous comment.
I checked FlyDSL #395 and #1239. #395 was closed because there was no ownership, hardware, or CI plan for maintaining Windows support. #1239 demonstrates substantial native-JIT progress, but it is still open, Windows AOT remains unsupported, and the generic FP16 FlashAttention path does not currently compile on gfx1151. I therefore should not present FlyDSL on Windows as an established replacement path for this PR.
The AOTriton point also needs clarification. We need to distinguish between consuming prebuilt or embedded kernels on Windows and supporting the FlyDSL compiler/runtime as an AITER development dependency.
I am going to sync this internally with the AITER, FlyDSL, AOTriton/Triton, and Windows owners before making the final backend decision. Please hold off on restructuring or removing the CK-specific work for now; no additional validation is needed until that decision is made.
I will come back with one explicit outcome: either Windows FMHA remains Triton-only, with the identified performance gaps assigned for tuning, or CK is accepted as a narrowly scoped Windows backend with a defined consumer, owner, and CI coverage.
The correctness and performance validation already completed here remains valuable regardless of that outcome. Apologies for moving the target before confirming the FlyDSL support boundary.
@Yasei-no-otoko — a heads-up on what is actually blocking CI here, since the failure list is misleading.
Three of the four red checks are check-signal, which looks like the Windows job failing but is not. check-signal gates on the Checks workflow and exits 78 (neutral) when it has not passed, so the real failure is the fourth one, Check Code Style with Ruff, and everything downstream of it — including JIT op smoke (gfx1201), which shows as skipped rather than having run at all.
Ruff reports four findings:
op_tests/test_mha_optional_flydsl.py:37 S102 Use of `exec` detected
op_tests/test_mha_optional_flydsl.py:84 S102 Use of `exec` detected
op_tests/test_mha_optional_flydsl.py:240 S102 Use of `exec` detected
setup.py:317 I001 Import block is un-sorted or un-formatted
I001 is ruff check --fix. The three S102 are a judgement call — if the exec calls are deliberate for the optional-import test, a # noqa: S102 with a short reason on each is the usual way through; if they can be importlib, that is cleaner.
Once Ruff is green the Windows smoke job will run on its own. The PR already carries the ci:windows label and I approved the pending workflow runs yesterday, so nothing else is needed from our side to trigger it.
Separately, on your comment about the CK submodule: you noted that CK builds on Windows once the pin moves to 509552a, and that is 11 commits ahead of what main pins today (96afae1d, 6 Oct), no divergence. If you bump it in this PR we would have the Windows CK path demonstrable from a clean checkout, which is a considerably stronger position than a manual submodule move during review.
Thanks for your patience while we aligned internally. Here is the final decision for this PR.
For the current AITER support scope, Windows RDNA platforms will remain Triton-only. FlyDSL support on Windows is a separate longer-term topic and is not a dependency for this decision.
Therefore, we will not merge the CK FMHA enablement, CK-specific target/PREBUILD policy, or CK submodule change from this PR. This is not a concern with the quality of the implementation. The work has demonstrated that CK FMHA can compile, run correctly, and provide meaningful performance on Windows RDNA. However, merging it would also establish an ongoing Windows CK support and CI obligation across CK updates, ROCm/Windows toolchain changes, and the gfx11/gfx12 hardware matrix. That is outside the backend scope we are taking on today.
The backend-neutral improvements remain useful and should be considered separately, particularly:
Windows blob-generator argument and path handling
JIT cache transaction behavior and MAX_JOBS handling
RDNA CU/WGP normalization and multi-architecture parsing
Optional FlyDSL and native-enum import handling
If you are willing, please move those changes into a smaller backend-neutral PR. Given the amount of review-driven rework already done here, if you would prefer not to carry another split, let us know and we can arrange for someone to help carry the reusable changes forward with proper credit.
No further CK validation is required for this PR. We will preserve the implementation and the gfx1101/gfx1151/gfx1200 results as the reference if a concrete Windows CK consumer, owner, and CI path are established in the future.
Thank you again for the substantial implementation and validation work, and apologies for the changes in direction during the review.
Following the agreed scope, I have opened #6589 from main at e64692e for the remaining backend-neutral Windows improvements: generator argument/path handling, explicit MAX_JOBS, CU/WGP normalization, and optional imports. It retains main's existing cache transaction implementation.
All three current review findings on #6589 have also been fixed, replied to, and resolved, with focused CPU regression tests and Ruff/Black checks. The PR excludes CK enablement, CK target/PREBUILD policy, and submodule changes; no further CK validation was performed. The CK work and measurements here remain available as reference.
The reusable Windows fixes have been split into #6589 and are now merged. Since we are not expanding the Windows CK support surface, I am closing this PR. Thanks for restructuring the work and carrying the reusable pieces forward.
However, merging it would also establish an ongoing Windows CK support and CI obligation across CK updates, ROCm/Windows toolchain changes, and the gfx11/gfx12 hardware matrix.
This is already an existing obligation. Windows is fully supported by CK and the rocm toolchain. This is not a valid excuse. If you sell the hardware and push the requirements of your libraries into the standard frameworks, and lock out the average consumer from the documentation for their device such that they cannot create an alternative, then you should be required to support it. You have not made a valid argument and the systems required to implement CI/CD for coverage on Windows are available to you. It's almost like AMD would choose to not even support the Windows drivers for their consumer GPUs if they could.
I got here from a comment link and did not see discussion after the quoted comment. I blame the Android GitHub app user interface, but my point still stands.
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
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.
After #2699 supplied the Windows JIT infrastructure, CK FMHA still needs RDNA targets and safe blob-generation arguments. This PR now keeps that CK/RDNA increment on current main.
_USE_MATH_DEFINESblock fromactivation_kernels.cu; the Windows HIP compiler flags already define it globally.Windows native mode follows main's automatic ROCm-toolchain detection; AITER_TRITON_ONLY=1 opts out of native imports and builds.
Validation: focused target and optional FlyDSL-dispatch CPU tests pass (18 tests, 26 target subtests; the standalone dispatch test passes 11 cases). The pinned CK commit
af9e1d1f1ae347c22feeb08fd2d42645075e0c5dgenerated gfx1150/gfx1200 forward instances for FP16 and BF16; this is code generation, not device compilation. On gfx1151, the publicaiter.flash_attn_funcpassed FP16/BF16 comparisons against FP32 MATH SDPA for B=1, S=64, H=4, D=64 (seed 4340), with FlyDSL discovery forced absent and imports guarded in the test process. That absence was simulated on the local environment. Ragua1 also reported gfx1150 Radeon 890M FP16/BF16 correctness in the review thread, before this import guard was added. gfx1200 hardware runtime validation remains welcome.Windows native FMHA validation used a separate CK checkout carrying the two
__builtin_memcpysubstitutions from closed, unmerged CK PR 10067. The unmodified CK pin fails Windows device compilation. Use a short AITER_JIT_DIR to avoid Windows path-length failures.The full transaction suite retains the same 14 failures and one error as unmodified main on this Windows host. gfx10 FMHA and RDNA batch-prefill have no instances in the current CK generator, so they are not advertised as supported.
Native FP16 attention (B=1, H=16, D=64, S=128/512/1024) is finite and matches an FP32 reference within 0.0004883 absolute error. It is 2.03x/1.11x/1.15x faster than default PyTorch SDPA by median GPU-event latency; profiling confirms SDPA selects Flash Attention. ComfyUI SDXL (1024x1024, 20 steps, three alternating pairs) completed through an explicit temporary ModelPatcher attention adapter: median sampler time 15.257 s Aiter versus 15.513 s Flash SDPA, with 8,400 timed native calls and zero adapter fallbacks. The observed 1.7% difference is too small to claim a general speedup; stock ComfyUI does not select Aiter automatically. Full conditions and output checks are in the validation comment.