Repository navigation
[MHA] Fix -DONLY_FAV3=0 quoting that breaks the backward JIT build - #6616
Conversation
`flags_extra_cc` reaches the compiler through `extra_cflags`, which is passed as an argv list, so quoting an element makes the quotes part of the flag rather than shell syntax. ninja hides this on Linux because it runs each command through `/bin/sh -c`, which strips them, but on Windows it uses CreateProcess with no shell, so clang receives them literally and every translation unit of the backward module fails: clang: error: no such file or directory: ''-DONLY_FAV3=0'' The flag only appears on cmdGenFunc_mha_bwd and cmdGenFunc_mha_varlen_bwd, so the breakage is confined to the backward JIT build. Verified on gfx1151. Windows (25H2, TheRock SDK, torch 2.14.0+rocm10.2.0): the mha_bwd JIT build fails on all 166 translation units before the change and completes in 132.6s after it. Linux (Ubuntu 24.04, ROCm 7.15, torch 2.13.0): the module builds either way and test_mha.py reports identical numerics, as expected given the shell. A direct hipcc call reproduces the failure without a shell on Linux too: argv `-DONLY_FAV3=0` returns 0, argv `'-DONLY_FAV3=0'` returns 1 with the same error. This is a build-correctness fix and does not by itself enable anything new. Signed-off-by: menglcai <menglcai@amd.com>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
zufayu
left a comment
There was a problem hiding this comment.
The quoting fix is correctly isolated from the Windows CK support work, and the full CI is green. LGTM.
…m#6355 and ROCm#6616 - fmha_kernels.py: keep main's new _check_out and this branch's _fp8_gfx950_reject_reason rename. - mha.py: keep the try_flydsl descale routing and gate the FlyDSL route on ck_only_feature is None. - That keeps main's exclusion of padded cu_seqlens and logits soft-cap for every varlen call, not only descaled ones.
Motivation
Split out from #4306, with none of the CK backward/PREBUILD changes from that PR.
cmdGenFunc_mha_bwdandcmdGenFunc_mha_varlen_bwdreturn"flags_extra_cc": ["'-DONLY_FAV3=0'"]. That value reaches the compiler throughextra_cflags, which is passed as an argv list, so the quotes are part of the flag rather than shell syntax and the compiler reads''-DONLY_FAV3=0''as a filename.Linux never sees this, because ninja runs each command through
/bin/sh -cand the shell strips the quotes. Windows uses CreateProcess with no shell, so they survive and the backward module fails to compile:Technical Details
The flag is written into
build.ninjathe same way on both platforms; only the execution differs, which is why the bug is invisible on Linux.The change drops the quotes at the two sites that carry this flag:
ONLY_FAV3only appears on the two backward generators, so nothing else is affected. On Linux the change is a no-op, since the shell was already removing the quotes.Test Plan
Four machines, covering both operating systems and two GPU architectures:
Three checks:
mha_bwdJIT build, before and after, on Windows and Linux. The op is called directly rather than throughtest_mha.py. On a non-gfx9 host that test stops at the forward step withinvalid argument for fmha_fwd, because ck-tile'sgenerate.pydefaults to--targets gfx9,gfx950and emits no kernel the runtime arch can dispatch, so it never reaches the backward path this change affects.Linux regression check. Full
test_mha.pyrun with and without the change, to confirm it is a no-op there.Test Result
mha_bwdJIT build:The split follows the operating system, not the GPU: both Windows hosts fail and both Linux hosts build either way, which is what the shell difference predicts.
test_mha.pygives identical numerics either way (OutputanddQmax diff0.0009765625in both).Scope
This is a build-correctness fix and does not enable anything on its own: backward on a non-gfx9 host still fails to dispatch afterwards, for the same CK target reason noted above. That is out of scope here per the decision on #4306.
Submission Checklist