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
[FlyDSL] FMHA gfx1250: per-tensor fp8 descales for the a8w8 kernel - #7214
Accept the q/k/v descales the gfx950 fp8 FMHA takes -- fp32, one element, on q's device.
All three must be given together, as gfx950 requires; a partial set is ambiguous, so the gate declines it rather than assuming 1.0.
Checked: descale 1.0 is bitwise identical to the no-descale path; q*k descale 4 against softmax_scale/4 is bitwise identical to baseline; v_descale 4 scales O by exactly 4; against an fp32 reference that dequantizes first, error is fp8 quantisation noise (3.6% non-causal, 1.4% causal); the existing fp8 sweep is 16/16 clean.
Accept the q/k/v descales the gfx950 fp8 FMHA takes -- fp32, one element,
on q's device -- instead of declining them and falling through to CK.
They are scalars, so no scaled WMMA is involved. V_WMMA_SCALE_F32_16X16X128
carries an E8M0 scale, which is a power of two and cannot represent an
arbitrary fp32 descale, and the kernel already applies softmax_scale to the
fp32 logits after QK precisely because 8-bit Q cannot carry it. So the split
is the one fmha_gfx950/pipeline.py:init_descale uses:
q_descale * k_descale -> folded into softmax_scale, hence into _s_scale,
which row_max already multiplies -- so it reaches
the LSE through m with no change to that line
v_descale -> folded into the epilogue's per-row inv_denom,
scaling O alone and leaving the LSE untouched
Loaded on device from the tensors, as gfx950 does; reading them host-side
would mean .item() and a device sync on every call.
has_descale is compile-time and part of the build key, so the no-descale build
is unchanged: same 6692 instructions, same 69 SGPR / 410 VGPR / 0 spills, with
only kernarg offsets shifted by the three unused pointers.
All three must be given together, as gfx950 requires; a partial set is
ambiguous, so the gate declines it rather than assuming 1.0.
Checked: descale 1.0 is bitwise identical to the no-descale path; q*k descale
4 against softmax_scale/4 is bitwise identical to baseline; v_descale 4 scales
O by exactly 4; against an fp32 reference that dequantizes first, error is fp8
quantisation noise (3.6% non-causal, 1.4% causal); the existing fp8 sweep is
16/16 clean.
ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm
vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all
All standard extended tests (excludes ci:atom_full)
Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7214 --add-label <label>
One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.
PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.
github-actionsBot
changed the title
FMHA gfx1250: per-tensor fp8 descales for the a8w8 kernel
[FlyDSL] FMHA gfx1250: per-tensor fp8 descales for the a8w8 kernel
Oct 30, 2026
flash_attn_varlen_func gated its FlyDSL hook on `not has_all_descales` and did
not forward the descales, so a prequantized fp8 call could never reach the
a8w8 kernel even now that it handles them -- it went straight to CK.
Drop that condition and pass the three through. The FlyDSL gate already
declines what it cannot serve (16-bit inputs, a partial set, a non-scalar or
non-fp32 descale) by returning None, so anything unsupported still falls
through to CK exactly as before.
Verified through the public entry, not the internal one: the FlyDSL path is
called and serves the request, and v_descale=4 scales O by exactly 4.0000.
No regression -- fp8 16/16 and bf16 32/32 clean, the latter all at err 0.
A zero Q or K descale passes validation but makes the effective logit scale zero in both THD and BSHD. _softmax masks scores to -inf before scaling, so its exponential argument evaluates -inf * 0 to NaN instead of giving masked keys zero probability. Preserve masking when applying a zero scale, including the row-max handling for fully masked rows.
flash_attn_func took no descales at all, so the bshd half of the a8w8 descale
support was unreachable. Add the three parameters, forward them to the FlyDSL
hook, and validate the all-or-none rule the varlen entry already enforces.
Unlike varlen, neither batched fallback consumes descales: the CK varlen path
takes q/k/v_descale, but FlashAttnFunc and the Triton batch entry do not. A
request that reached them with descales would be served unscaled, so raise
instead of returning a wrong answer. That keeps the rule that a backend either
honours an option or declines the call.
Checked through flash_attn_func: served with the right shape and dtype,
v_descale=4 scales O by exactly 4.0000, a partial set raises ValueError, and
bf16 + descale raises rather than silently dropping the scaling. fp8 16/16 and
bf16 32/32 clean, varlen route unaffected.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Supported FP8 descale requests are rejected before reaching FlyDSL when CK is disabled, and accepted zero Q/K descales can produce NaNs in causal attention.
Zero Q/K descales can produce NaNs on masked scores
aiter/ops/flydsl/fmha_kernels.py:261
This accepts a zero Q or K descale, but the shared _softmax implementation assumes its effective scale is positive: it masks scores to -inf before computing fma_inf(score, s_scale, ...). For causal FP8 attention with q_descale=0 and k_descale=v_descale=1, masked entries therefore evaluate -inf * 0, introducing NaNs instead of producing uniform attention over valid keys. Preserve masked -inf after scaling, or explicitly reject unsupported zero Q/K scales.
…escales
flash_attn_varlen_func rejected every descale call up front when ENABLE_CK=0,
before the FlyDSL hook ran. That was right when CK was the only backend that
could consume descales, but the a8w8 gfx1250 kernel now can, so a supported
fp8 request was refused for a reason that no longer applied to it.
Move the rejection to the Triton fallback it actually protects. FlyDSL gets
first refusal; only a request that falls past it, to a backend with no descale
support, raises.
With ENABLE_CK=0: fp8 + descales is now served by FlyDSL, and bf16 + descales
still raises instead of reaching Triton and being computed unscaled. With
ENABLE_CK=1 nothing changes -- varlen and batch routes and the fp8 sweep are
unaffected.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The new gfx1250 descale-enabled specializations lack checked-in regression coverage because existing gfx1250 sweeps never pass descales and current descale tests target only gfx950.
A third sweep beside thd and bshd, with its own table. Besides the usual error
against a reference that pre-scales q*qd, k*kd and v*vd, it checks three
invariants that pin the fold itself and do not depend on fp8 noise:
identity descales of 1.0 reproduce the no-descale path bit for bit
v_scale_ok v_descale=4 scales O exactly (x4 shifts the bf16 exponent and
leaves the mantissa, so round(4x) == 4*round(x))
qk_fold_ok q/k descale 2*2 against softmax_scale/4 is bitwise the baseline
Those matter because a wrong fold shows up as an error that reads like
quantisation noise; bitwise columns cannot be mistaken for it.
Descales are a8w8-only, so the sweep takes just the 8-bit dtype pairs and
self-skips when none is requested, leaving the existing two sweeps and their
--max-cases sampling untouched. --descale 0 turns it off.
64/64 rows across fp8/bf8, hdim 128 and 192/128, causal and not, batch 1 and 3,
GQA 1x and 4x: all three invariants true, err 0.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The descale tests do not fail when invariants are false, and the default-enabled sweep bypasses --max-cases, leaving regressions unenforced and partial runs unbounded by the requested limit.
The descale sweep iterated its product directly, so --max-cases bounded the
two layout sweeps but not it: a partial-axis request still paid for the whole
hdim x shape x fp8-dtype x causal product first, defeating the point of the
bound.
Split the indexed sampler out of _cases into _sample(axes, label) and route
all three sweeps through it. _cases keeps the hdim filtering that makes its
index space exact; the descale sweep passes its own four axes.
--max-cases 1 now yields one row per table and three sampling lines, and
--max-cases 0 still runs the full 64-row descale sweep, all invariants true
and err 0.
…OCm#7214)
* FMHA gfx1250: per-tensor fp8 descales for the a8w8 kernel
Accept the q/k/v descales the gfx950 fp8 FMHA takes -- fp32, one element,
on q's device -- instead of declining them and falling through to CK.
They are scalars, so no scaled WMMA is involved. V_WMMA_SCALE_F32_16X16X128
carries an E8M0 scale, which is a power of two and cannot represent an
arbitrary fp32 descale, and the kernel already applies softmax_scale to the
fp32 logits after QK precisely because 8-bit Q cannot carry it. So the split
is the one fmha_gfx950/pipeline.py:init_descale uses:
q_descale * k_descale -> folded into softmax_scale, hence into _s_scale,
which row_max already multiplies -- so it reaches
the LSE through m with no change to that line
v_descale -> folded into the epilogue's per-row inv_denom,
scaling O alone and leaving the LSE untouched
Loaded on device from the tensors, as gfx950 does; reading them host-side
would mean .item() and a device sync on every call.
has_descale is compile-time and part of the build key, so the no-descale build
is unchanged: same 6692 instructions, same 69 SGPR / 410 VGPR / 0 spills, with
only kernarg offsets shifted by the three unused pointers.
All three must be given together, as gfx950 requires; a partial set is
ambiguous, so the gate declines it rather than assuming 1.0.
Checked: descale 1.0 is bitwise identical to the no-descale path; q*k descale
4 against softmax_scale/4 is bitwise identical to baseline; v_descale 4 scales
O by exactly 4; against an fp32 reference that dequantizes first, error is fp8
quantisation noise (3.6% non-causal, 1.4% causal); the existing fp8 sweep is
16/16 clean.
* FMHA gfx1250: black formatting for the a8w8 descale change
* FMHA gfx1250: let descale calls reach the FlyDSL varlen path
flash_attn_varlen_func gated its FlyDSL hook on `not has_all_descales` and did
not forward the descales, so a prequantized fp8 call could never reach the
a8w8 kernel even now that it handles them -- it went straight to CK.
Drop that condition and pass the three through. The FlyDSL gate already
declines what it cannot serve (16-bit inputs, a partial set, a non-scalar or
non-fp32 descale) by returning None, so anything unsupported still falls
through to CK exactly as before.
Verified through the public entry, not the internal one: the FlyDSL path is
called and serves the request, and v_descale=4 scales O by exactly 4.0000.
No regression -- fp8 16/16 and bf16 32/32 clean, the latter all at err 0.
* FMHA gfx1250: route batched descale calls to the FlyDSL kernel too
flash_attn_func took no descales at all, so the bshd half of the a8w8 descale
support was unreachable. Add the three parameters, forward them to the FlyDSL
hook, and validate the all-or-none rule the varlen entry already enforces.
Unlike varlen, neither batched fallback consumes descales: the CK varlen path
takes q/k/v_descale, but FlashAttnFunc and the Triton batch entry do not. A
request that reached them with descales would be served unscaled, so raise
instead of returning a wrong answer. That keeps the rule that a backend either
honours an option or declines the call.
Checked through flash_attn_func: served with the right shape and dtype,
v_descale=4 scales O by exactly 4.0000, a partial set raises ValueError, and
bf16 + descale raises rather than silently dropping the scaling. fp8 16/16 and
bf16 32/32 clean, varlen route unaffected.
* FMHA gfx1250: guard the fallback, not the dispatch, for ENABLE_CK=0 descales
flash_attn_varlen_func rejected every descale call up front when ENABLE_CK=0,
before the FlyDSL hook ran. That was right when CK was the only backend that
could consume descales, but the a8w8 gfx1250 kernel now can, so a supported
fp8 request was refused for a reason that no longer applied to it.
Move the rejection to the Triton fallback it actually protects. FlyDSL gets
first refusal; only a request that falls past it, to a backend with no descale
support, raises.
With ENABLE_CK=0: fp8 + descales is now served by FlyDSL, and bf16 + descales
still raises instead of reaching Triton and being computed unscaled. With
ENABLE_CK=1 nothing changes -- varlen and batch routes and the fp8 sweep are
unaffected.
* FMHA gfx1250: test coverage for the fp8 per-tensor descales
A third sweep beside thd and bshd, with its own table. Besides the usual error
against a reference that pre-scales q*qd, k*kd and v*vd, it checks three
invariants that pin the fold itself and do not depend on fp8 noise:
identity descales of 1.0 reproduce the no-descale path bit for bit
v_scale_ok v_descale=4 scales O exactly (x4 shifts the bf16 exponent and
leaves the mantissa, so round(4x) == 4*round(x))
qk_fold_ok q/k descale 2*2 against softmax_scale/4 is bitwise the baseline
Those matter because a wrong fold shows up as an error that reads like
quantisation noise; bitwise columns cannot be mistaken for it.
Descales are a8w8-only, so the sweep takes just the 8-bit dtype pairs and
self-skips when none is requested, leaving the existing two sweeps and their
--max-cases sampling untouched. --descale 0 turns it off.
64/64 rows across fp8/bf8, hdim 128 and 192/128, causal and not, batch 1 and 3,
GQA 1x and 4x: all three invariants true, err 0.
* FMHA gfx1250: bound the descale sweep with --max-cases too
The descale sweep iterated its product directly, so --max-cases bounded the
two layout sweeps but not it: a partial-axis request still paid for the whole
hdim x shape x fp8-dtype x causal product first, defeating the point of the
bound.
Split the indexed sampler out of _cases into _sample(axes, label) and route
all three sweeps through it. _cases keeps the hdim filtering that makes its
index space exact; the descale sweep passes its own four axes.
--max-cases 1 now yields one row per table and three sampling lines, and
--max-cases 0 still runs the full 64-row descale sweep, all invariants true
and err 0.
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.
Accept the q/k/v descales the gfx950 fp8 FMHA takes -- fp32, one element, on q's device.
All three must be given together, as gfx950 requires; a partial set is ambiguous, so the gate declines it rather than assuming 1.0.
Checked: descale 1.0 is bitwise identical to the no-descale path; q*k descale 4 against softmax_scale/4 is bitwise identical to baseline; v_descale 4 scales O by exactly 4; against an fp32 reference that dequantizes first, error is fp8 quantisation noise (3.6% non-causal, 1.4% causal); the existing fp8 sweep is 16/16 clean.