Skip to content

Mha v4: kv_splits="auto" from a wave-rounding cost model - #7942

Merged
JohnNikolay84 merged 6 commits into
mainfrom
mha4_kv_splits_auto
Nov 24, 2026
Merged

JohnNikolay84 merged 6 commits into
mainfrom
mha4_kv_splits_auto

Conversation

@jcaraban

@jcaraban jcaraban commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

mha_v4(kv_splits="auto") only splits a grid that fits in half a wave. MHA v4 runs one 512-thread work-group per CU, so a grid between one and a few waves ends on a nearly idle round that still costs about a full one: the Qwen-Image-Edit 2048x2048 per-rank attention at Ulysses 8 ([1, 21890, 3, 128]) is 258 work-groups, two rounds for 1.01 rounds of work, and auto leaves it unsplit at 824 us where 5-6 splits take 619-622 us.

This keeps today's rule up to half a wave and, past it, picks the count with the least modelled time: rounds (a partial last round at 0.40 of a full one plus its fill) times the keys of the longest range, plus the merge. The divisor and ragged rules decide the candidates as before; the head dim cancels out of the comparison, so one model covers hd128 and hd256. The constants are fit on MI355X BF16 and hold on MI350X. The merge counts 1.5x for 8-bit Q/K (INT8/FP8 and FP8/FP8, whose rows walk a key faster than BF16's) and 2x past batch 1 (each split also copies the queries); mha_v4_kv_splits() takes the Q/K format as a new keyword, q_format, which defaults to BF16.

It also makes auto safe under torch.compile with a dynamic sequence. Traced, the pick ran on symbolic sizes: divmod on a SymInt broke the graph, so Dynamo ran the caller eagerly, and the fold and range lengths guarded on the key length, recompiling per length. Under compile, the pick, fold, launch and merge now run inside one functional custom op (aiter::mha_v4_split_kv), where the sizes are concrete; eager calls run the same body directly. The op returns its output rather than writing into the caller's buffer, because Inductor's scheduler failed on the mutating form in such a graph.

Performance

Kernel sweep

CUDA-graph replay, every count from 1 to 12 and 16 timed per shape. Regret = time of the picked count over the best measured count, minus one; means are geometric.

BF16, 144 shapes, head dim 128: 3, 6, 7, 12, 14 and 24 heads at 21 lengths from 2048 to 65536 keys, batch 1, plus batch 2 for 3, 6 and 12 heads.

MI355X mean regret MI355X shapes >= 5% off MI350X mean regret MI350X shapes >= 5% off
unsplit 7.9% 50 / 144 7.4% 38 / 144
auto on main 3.4% 34 / 144 2.2% 21 / 144
auto with this PR 0.3% 2 / 144 0.3% 1 / 144

The best count is the same on both SKUs for 120 of the 144 shapes. A finer MI350X grid (3 and 6 heads, every 128 keys from 12288 to 26624, 226 shapes) puts this PR at 0.2% mean regret, 1 shape >= 5% off (main: 5.8%, 109 shapes). Fitting the constants to both SKUs jointly did not improve on these.

Per recipe, 27 shapes on one GPU: 3 to 40 heads at 4096 to 32768 keys, batch 1 and 2, and the Qwen-Image-Edit (Ulysses 8) and Qwen-Image (Ulysses 4) per-rank shapes. The quantized recipes' times include their quantizers, which do not depend on the count. Mean regret (shapes >= 5% off):

Operands SKU unsplit auto on main cost model without the two merge factors (3d6dd4c) auto with this PR
BF16 MI355X 9.0% (13) 7.9% (12) 0.6% (0) 0.5% (0)
BF16 MI350X 6.7% (11) 5.3% (10) 0.7% (2) 0.3% (0)
BF16/FP8 MI355X 7.4% (12) 6.3% (11) 0.7% (2) 0.2% (0)
BF16/FP8 MI350X 4.2% (9) 3.3% (8) 1.1% (2) 0.4% (0)
INT8/FP8 MI355X 4.1% (8) 3.8% (7) 1.1% (2) 0.4% (0)
INT8/FP8 MI350X 4.0% (7) 3.5% (6) 1.3% (2) 0.2% (0)
FP8/FP8 MI355X 3.3% (6) 3.0% (5) 1.6% (3) 0.2% (0)
FP8/FP8 MI350X 3.3% (6) 2.9% (5) 1.9% (4) 0.1% (0)

With this PR the worst of these shapes is 4.1% off its best count. The two merge factors come from this set: without them the batch-2 shapes split too far, e.g. FP8/FP8 [2, 21890, 3, 128] took 5 splits and ran 16% (MI355X) and 18% (MI350X) slower than unsplit, which is what main picks there.

An earlier 50-shape set of per-rank DiT shapes (Qwen-Image(-Edit), FLUX.1, FLUX.1-Kontext at 1024-2048 and Ulysses 1-8, plus head-dim-256 shapes) on MI355X: main 4.6% mean / 33.2% max regret, this PR 0.1% / 1.1%. Examples (us):

Shape (per rank) Work-groups Unsplit auto, main auto, this PR Best
[1, 21890, 3, 128] Qwen-Image-Edit 2048 U8 258 824 824 622 (5) 619 (6)
[1, 12395, 6, 128] Qwen-Image-Edit 1328 U4 294 486 486 399 (3) 394 (5)
[1, 33280, 6, 128] FLUX.1-Kontext 2048 U4 780 2914 2914 2594 (3) 2593 (4)
[1, 16384, 5, 256] 320 1321 1321 1065 (4) 1065 (4)
[1, 17794, 3, 128] Qwen-Image 2048 U8 210 374 374 374 (1) 374 (1)

End to end

xDiT, 8x MI355X, Ulysses 8, torch.compile, BF16 MHA v4 attention; seconds per output, two interleaved rounds. Measured at 3d6dd4c: this attention is BF16 at batch 1 per rank, where the last commit leaves the pick as it was.

Model Fixed count on main auto, previous revision (7f9f1a4) auto, 3d6dd4c
Qwen-Image-Edit 2048x2048 (CFG passes of 22016 and 22008 tokens) 11.10 / 11.10 (4 splits) 13.11 / 13.11 (graph breaks) 11.08 / 11.06
MiniMax-H3 768x1344, 124 frames 22.84 / 22.87 (1), 21.88 / 21.88 (3) 21.87 / 21.87 21.76 / 21.76
FLUX.2-dev 2048x2048, 2 input images 10.86 / 10.85 10.81 / 10.82
Qwen-Image 2048x2048 3.97 / 3.97 / 3.97 (1) 3.96 / 3.96 / 3.96
FLUX.1-Kontext-dev 1024x1024 1.22 / 1.22 / 1.22 (main auto) 1.21 / 1.21 / 1.21

Qwen-Image-Edit on 8x MI350X: 12.62 with auto, no graph breaks.

PR Self-Review

Reviewed revision

f63d42a

Behavior and intent

Only kv_splits="auto" changes its pick, and only for grids above half a wave; explicit counts and smaller grids pick as before. Every picked count is one an explicit kv_splits already accepts (a divisor, or any count at batch 1 for operands with per-batch key lengths), capped at 16 and at ranges of at least 512 keys. mha_v4_kv_splits() gains the keyword q_format; without it a caller gets the BF16 pick, and only INT8 and FP8 Q/K (the measured 8-bit recipes) scale the merge, so other formats get BF16's pick too. Under torch.compile every split (auto or explicit) goes through the one custom op, so a compiled graph neither guards on the key length nor sees the count; eager calls are unchanged apart from running the split through a helper.

Validation and unverified scope

On this branch merged with main (fe40b01), on MI355X and on MI350X: python3 op_tests/test_mha_v4.py runs 346 checks, 0 failed, and python3 op_tests/test_mha_v4_sparse.py 609 with 5 skipped, 0 failed. With #7939 (hd256 BF16) merged as well, test_mha_v4.py runs 360 checks, 0 failed (MI350X).

Eager calls: main and this branch in three interleaved rounds at [1, 4352, 3, 128] (BF16 at 4 splits, BF16/FP8 with auto and unsplit) take 54 to 120 us per call and differ by at most 4 us; the unsplit call, whose path this PR does not touch, differs by up to 2 us.

[1, 16400, 6, 128] with 16398 keys (Qwen-Image 2048 at Ulysses 4) had measured 12.7% slower at auto's 3 splits in an 8-GPU run. Re-timed on one GPU with 15 neighbouring shapes, 3 splits take 652 us against 683 unsplit on MI355X and 829 against 827 on MI350X, and auto is within 0.3% of the best count on all 16 shapes on both SKUs.

At f63d42a (review nits only: the 8-bit merge factor lists INT8/FP8 explicitly, and the dynamic-sequence compile check passes a caller's out), the two changed checks pass on MI355X. An FP8 case of the compile check, tried in ce8ba24, compiled more than once under CI's torch 2.10 (it passed on 2.13) and was dropped. The full suites were not rerun locally after f575999.

Unverified:

  • CU counts other than 256: the rule reads the device's count, but the constants were measured at 256.
  • Batches above 2.
  • The end-to-end runs were not repeated at f575999.

PR-specific question

test_mha_v4_kv_splits_auto_shrinks_a_partial_last_round fails on main, which returns 1 for every grid past half a wave, and its batch-2 and 8-bit cases fail at 3d6dd4c (5 splits instead of 2, and no q_format). The existing test_mha_v4_kv_splits_auto_fills_one_wave stops at half a wave. test_mha_v4_kv_splits_auto_cost_model_compiles failed at 87378e6, where the pick used min() with a key function that a fullgraph trace rejects; the existing compile parity test passes an explicit count. test_mha_v4_kv_splits_auto_compiles_once_for_a_dynamic_sequence fails at 7f9f1a4 (divmod on a symbolic size inside the trace) and would fail on a recompile per length; it is the only MHA v4 test that compiles with dynamic=True.

Changed op tests

op_tests/test_mha_v4.py: the three tests above are new (the dynamic-sequence one fills a caller's out; the partial-round one checks that an unmeasured Q format keeps BF16's pick), and benchmark_mha_v4 passes the Q/K format when it reports auto's count.

…a wave

Grids between one and a few waves end on a nearly idle round. MI355X BF16, 50 DiT per-rank shapes,
CUDA-graph replay: regret vs the best count mean 0.1% / max 1.1% (was 4.6% / 33.2%); Qwen-Image-Edit
2048 U8 824 -> 622 us.
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full 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 7942 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

…s it

min() with a key function is not traceable by Dynamo under fullgraph. The
compile test now uses 8192 keys, where the cost model splits (3), so it
exercises that branch.
…equence

Under torch.compile with a dynamic sequence, auto's cost model ran on
symbolic sizes: divmod on a SymInt broke the graph (Dynamo fell back to
eager for the caller), and the fold and range lengths guarded on the key
length, recompiling per length. On Qwen-Image-Edit 2048 (CFG passes of
different lengths) that made auto 18% slower end to end than a fixed count.

Under compile, the pick, fold, launch and merge now run inside one
functional custom op (aiter::mha_v4_split_kv), where sizes are concrete;
auto resolves to "pick at launch". Eager calls run the same body directly.
The op returns its output rather than writing the caller's buffer: the
mutating form failed in Inductor's scheduler on that graph.

Edit 2048 on 8x MI355X: no graph breaks; a new test compiles mha_v4 once
with dynamic=True over lengths whose picks differ and matches eager.
The cost model's merge term was fit on BF16 at batch 1. The INT8/FP8 and
FP8/FP8 rows walk a key faster, so the same merge is worth more of their
keys, and past batch 1 every split also copies the queries. Scale the
term 1.5x for 8-bit Q/K and 2x past batch 1.

27 shapes per recipe on one GPU under graph replay, mean regret of the
picked count (shapes at least 5% off the best):
MI355X: FP8/FP8 1.65% (3) -> 0.17% (0), INT8/FP8 1.17% (2) -> 0.39% (0),
BF16/FP8 0.74% (2) -> 0.21% (0), BF16 0.62% (0) -> 0.52% (0).
MI350X: FP8/FP8 2.00% (4) -> 0.10% (0), INT8/FP8 1.32% (2) -> 0.21% (0),
BF16/FP8 1.15% (2) -> 0.37% (0), BF16 0.71% (2) -> 0.27% (0).
@jcaraban
jcaraban marked this pull request as ready for review November 17, 2026 18:04
@jcaraban
jcaraban requested a review from a team November 17, 2026 18:05
@github-actions github-actions Bot changed the title [Triton/Gluon] Mha v4: kv_splits="auto" from a wave-rounding cost model Mha v4: kv_splits="auto" from a wave-rounding cost model Nov 17, 2026
@aiter-bot

aiter-bot commented Nov 17, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision f63d42afecbe · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

Only `kv_splits="auto"` changes its pick, and only for grids above half a wave; explicit counts and smaller grids pick as before. Every picked count is one an explicit `kv_splits` already accepts (a divisor, or any count at batch 1 for operands with per-batch key lengths), capped at 16 and at ranges of at least 512 keys. `mha_v4_kv_splits()` gains the keyword `q_format`; without it a caller gets the BF16 pick, and only INT8 and FP8 Q/K (the measured 8-bit recipes) scale the merge, so other formats get BF16's pick too. Under `torch.compile` every split (auto or explicit) goes through the one custom op, so a compiled graph neither guards on the key length nor sees the count; eager calls are unchanged apart from running the split through a helper.

Validation and unverified scope

On this branch merged with main (`fe40b01`), on MI355X and on MI350X: `python3 op_tests/test_mha_v4.py` runs 346 checks, 0 failed, and `python3 op_tests/test_mha_v4_sparse.py` 609 with 5 skipped, 0 failed. With #7939 (hd256 BF16) merged as well, `test_mha_v4.py` runs 360 checks, 0 failed (MI350X).

Eager calls: main and this branch in three interleaved rounds at [1, 4352, 3, 128] (BF16 at 4 splits, BF16/FP8 with auto and unsplit) take 54 to 120 us per call and differ by at most 4 us; the unsplit call, whose path this PR does not touch, differs by up to 2 us.

[1, 16400, 6, 128] with 16398 keys (Qwen-Image 2048 at Ulysses 4) had measured 12.7% slower at auto's 3 splits in an 8-GPU run. Re-timed on one GPU with 15 neighbouring shapes, 3 splits take 652 us against 683 unsplit on MI355X and 829 against 827 on MI350X, and auto is within 0.3% of the best count on all 16 shapes on both SKUs.

At `f63d42a` (review nits only: the 8-bit merge factor lists INT8/FP8 explicitly, and the dynamic-sequence compile check passes a caller's `out`), the two changed checks pass on MI355X. An FP8 case of the compile check, tried in `ce8ba24`, compiled more than once under CI's torch 2.10 (it passed on 2.13) and was dropped. The full suites were not rerun locally after `f575999`.

Unverified:
- CU counts other than 256: the rule reads the device's count, but the constants were measured at 256.
- Batches above 2.
- The end-to-end runs were not repeated at `f575999`.

PR-specific question

`test_mha_v4_kv_splits_auto_shrinks_a_partial_last_round` fails on main, which returns 1 for every grid past half a wave, and its batch-2 and 8-bit cases fail at 3d6dd4c (5 splits instead of 2, and no `q_format`). The existing `test_mha_v4_kv_splits_auto_fills_one_wave` stops at half a wave. `test_mha_v4_kv_splits_auto_cost_model_compiles` failed at 87378e6, where the pick used `min()` with a key function that a fullgraph trace rejects; the existing compile parity test passes an explicit count. `test_mha_v4_kv_splits_auto_compiles_once_for_a_dynamic_sequence` fails at 7f9f1a4 (`divmod` on a symbolic size inside the trace) and would fail on a recompile per length; it is the only MHA v4 test that compiles with `dynamic=True`.

Changed op tests

`op_tests/test_mha_v4.py`: the three tests above are new (the dynamic-sequence one fills a caller's `out`; the partial-round one checks that an unmeasured Q format keeps BF16's pick), and `benchmark_mha_v4` passes the Q/K format when it reports auto's count.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@JohnNikolay84

JohnNikolay84 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Nit: No test covers a caller-provided out= under compile, which is the out.copy_() branch. Adding out= (and maybe FP8) to
test_mha_v4_kv_splits_auto_compiles_once_for_a_dynamic_sequence would guard it.

Nit: 8-bit merge factor. q_format != AttentionFormat.BF16 gives the 1.5x factor to any non-BF16 Q. Only INT8 and FP8 were measured, and the public mha_v4_kv_splits() accepts any format.
Listing (INT8, FP8) explicitly would match the comment

…ut under compile

The 1.5x merge factor was measured on INT8 and FP8 Q/K only; other formats now keep BF16's
merge instead of inheriting it. mha_v4 itself only splits BF16 and those 8-bit recipes, so its
picks are unchanged. The dynamic-sequence compile check now also runs FP8 and passes out=,
which takes the copy from the compiled split.
@jcaraban

Copy link
Copy Markdown
Contributor Author

@JohnNikolay84 thanks, both taken in ce8ba24:

  • The 1.5x merge factor now applies only to INT8 and FP8 Q/K. Other formats keep BF16's merge, and the partial-round test checks that an unmeasured format (FP4) gets BF16's pick. mha_v4 only splits BF16 and those 8-bit recipes, so its own picks don't change.
  • test_mha_v4_kv_splits_auto_compiles_once_for_a_dynamic_sequence now runs BF16 and FP8 and passes a NaN-filled out=, so it goes through the out.copy_() branch and checks that the result is the caller's tensor and matches eager.

Both changed checks pass on MI355X (3 cases). I haven't rerun the full suites at this head.

The FP8 case added in ce8ba24 compiled more than once under torch 2.10 in CI (it passed on
2.13). The BF16 case, which passes a caller's out= through the compiled split, stays.
@jcaraban

Copy link
Copy Markdown
Contributor Author

Follow-up: CI's torch 2.10 compiled the new FP8 case of the dynamic-sequence check more than once (it passed on 2.13, where I'd run it), so f63d42a keeps that check on BF16. The out= coverage stays. I haven't looked into why FP8 recompiles on 2.10.

@JohnNikolay84
JohnNikolay84 merged commit da016c0 into main Nov 24, 2026
84 of 86 checks passed
@JohnNikolay84
JohnNikolay84 deleted the mha4_kv_splits_auto branch November 24, 2026 10:14
avjves pushed a commit to xdit-project/xDiT that referenced this pull request Nov 24, 2026
…-KV (#962)

* perf(aiter): compute FAv3 rows past the last full wave split-K

The AITER FAv3 hd128 bf16 forward on gfx942/gfx950 gives each CU one 256-row
query tile. Qwen-Image-Edit at Ulysses 8 launches 258 tiles on the 256-CU
MI355X, so a second wave of 2 tiles costs as much as the first. Run the rows
past the last full wave against K slices as varlen segments over all CUs and
merge them by log-sum-exp.

* perf(qwen): default Qwen-Image(-Edit) to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950, Qwen-Image
and Qwen-Image-Edit default to AITER_BF16. Edit uses a fixed 4-way split,
because the joint edit sequence leaves too few query tiles for the split auto
picks; Qwen-Image uses auto. An explicit --attention_backend or
--mha_v4_kv_splits keeps precedence.

Replaces the FAv3 last-wave split from the previous commit.

* fix(config): keep an explicit --mha_v4_kv_splits 1 over the model default

--mha_v4_kv_splits defaulted to 1, so the runner could not tell an explicit 1
from an omitted flag and replaced it with the model's split count. The flag
now defaults to unset; the model default fills it in, and the runtime config
resolves what is still unset to 1.

* fix(qwen): only default to split-KV MHA v4 on gfx950

AITER exports the MHA v4 LSE, and so accepts kv_splits > 1, only on gfx950;
on gfx942 AITER_BF16 is available but an explicit split count raises. Gate
the Qwen default on gfx950 so MI300-series GPUs keep the global default. The
test now drives the real arch check and patches only Qwen's split-KV gate.

* perf(qwen): default Qwen-Image-Edit to MHA v4 kv_splits auto

Needs ROCm/aiter#7942: its auto picks Edit's split from a wave-rounding cost
model and runs the split in one op, so torch.compile neither breaks the graph
nor recompiles across Edit's two CFG sequence lengths. With it, auto matches
the fixed 4 on Edit 2048 (8x MI355X: 11.07 vs 11.10 s); without it, auto
leaves Edit unsplit.

* fix(mha-v4): regroup batched packed keys without a graph break

A batch of several packed sequences is scattered back into a padded
[batch, max_k] buffer before the MHA v4 launch. The row and slot of each
packed key came from repeat_interleave over the lengths, whose output
shape depends on their values, so torch.compile split the graph at this
call in every transformer block.

Search the cumulative boundaries instead: the output has the shape of the
packed rows and the indices are the same, empty sequences included.

Qwen-Image-Edit with batched true CFG on AITER_BF16 (8x MI355X, 2048x2048,
measured on top of #962, where that backend is the default): 104 graph
breaks and 41 recompiles go to 0, and a step batch goes from 12.14 s to
9.88 s.
jcaraban added a commit to xdit-project/xDiT that referenced this pull request Nov 24, 2026
…#966)

* perf(aiter): compute FAv3 rows past the last full wave split-K

The AITER FAv3 hd128 bf16 forward on gfx942/gfx950 gives each CU one 256-row
query tile. Qwen-Image-Edit at Ulysses 8 launches 258 tiles on the 256-CU
MI355X, so a second wave of 2 tiles costs as much as the first. Run the rows
past the last full wave against K slices as varlen segments over all CUs and
merge them by log-sum-exp.

* perf(qwen): default Qwen-Image(-Edit) to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950, Qwen-Image
and Qwen-Image-Edit default to AITER_BF16. Edit uses a fixed 4-way split,
because the joint edit sequence leaves too few query tiles for the split auto
picks; Qwen-Image uses auto. An explicit --attention_backend or
--mha_v4_kv_splits keeps precedence.

Replaces the FAv3 last-wave split from the previous commit.

* fix(config): keep an explicit --mha_v4_kv_splits 1 over the model default

--mha_v4_kv_splits defaulted to 1, so the runner could not tell an explicit 1
from an omitted flag and replaced it with the model's split count. The flag
now defaults to unset; the model default fills it in, and the runtime config
resolves what is still unset to 1.

* fix(qwen): only default to split-KV MHA v4 on gfx950

AITER exports the MHA v4 LSE, and so accepts kv_splits > 1, only on gfx950;
on gfx942 AITER_BF16 is available but an explicit split count raises. Gate
the Qwen default on gfx950 so MI300-series GPUs keep the global default. The
test now drives the real arch check and patches only Qwen's split-KV gate.

* perf(qwen): default Qwen-Image-Edit to MHA v4 kv_splits auto

Needs ROCm/aiter#7942: its auto picks Edit's split from a wave-rounding cost
model and runs the split in one op, so torch.compile neither breaks the graph
nor recompiles across Edit's two CFG sequence lengths. With it, auto matches
the fixed 4 on Edit 2048 (8x MI355X: 11.07 vs 11.10 s); without it, auto
leaves Edit unsplit.

* perf(flux): default FLUX.1-Kontext to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950,
FLUX.1-Kontext-dev defaults to AITER_BF16 with kv_splits auto. At 1024x1024
with Ulysses 8 each rank attends 3 heads over ~8.7k tokens, too few query
tiles to fill the GPU, which the split fills. An explicit --attention_backend
or --mha_v4_kv_splits keeps precedence.

prefer_mha_v4 moves from the Qwen runner to base_model so both use it.
jcaraban added a commit to xdit-project/xDiT that referenced this pull request Nov 24, 2026
)

* perf(aiter): compute FAv3 rows past the last full wave split-K

The AITER FAv3 hd128 bf16 forward on gfx942/gfx950 gives each CU one 256-row
query tile. Qwen-Image-Edit at Ulysses 8 launches 258 tiles on the 256-CU
MI355X, so a second wave of 2 tiles costs as much as the first. Run the rows
past the last full wave against K slices as varlen segments over all CUs and
merge them by log-sum-exp.

* perf(qwen): default Qwen-Image(-Edit) to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950, Qwen-Image
and Qwen-Image-Edit default to AITER_BF16. Edit uses a fixed 4-way split,
because the joint edit sequence leaves too few query tiles for the split auto
picks; Qwen-Image uses auto. An explicit --attention_backend or
--mha_v4_kv_splits keeps precedence.

Replaces the FAv3 last-wave split from the previous commit.

* fix(config): keep an explicit --mha_v4_kv_splits 1 over the model default

--mha_v4_kv_splits defaulted to 1, so the runner could not tell an explicit 1
from an omitted flag and replaced it with the model's split count. The flag
now defaults to unset; the model default fills it in, and the runtime config
resolves what is still unset to 1.

* fix(qwen): only default to split-KV MHA v4 on gfx950

AITER exports the MHA v4 LSE, and so accepts kv_splits > 1, only on gfx950;
on gfx942 AITER_BF16 is available but an explicit split count raises. Gate
the Qwen default on gfx950 so MI300-series GPUs keep the global default. The
test now drives the real arch check and patches only Qwen's split-KV gate.

* perf(qwen): default Qwen-Image-Edit to MHA v4 kv_splits auto

Needs ROCm/aiter#7942: its auto picks Edit's split from a wave-rounding cost
model and runs the split in one op, so torch.compile neither breaks the graph
nor recompiles across Edit's two CFG sequence lengths. With it, auto matches
the fixed 4 on Edit 2048 (8x MI355X: 11.07 vs 11.10 s); without it, auto
leaves Edit unsplit.

* perf(flux): default FLUX.1-Kontext to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950,
FLUX.1-Kontext-dev defaults to AITER_BF16 with kv_splits auto. At 1024x1024
with Ulysses 8 each rank attends 3 heads over ~8.7k tokens, too few query
tiles to fill the GPU, which the split fills. An explicit --attention_backend
or --mha_v4_kv_splits keeps precedence.

prefer_mha_v4 moves from the Qwen runner to base_model so both use it.

* perf(flux2): default FLUX.2-dev to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits on gfx950, FLUX.2-dev defaults to
AITER_BF16 with kv_splits auto, except under PipeFusion, whose pipeline was
not measured. An explicit --attention_backend or --mha_v4_kv_splits keeps
precedence.
jcaraban added a commit to xdit-project/xDiT that referenced this pull request Nov 24, 2026
…KV (#968)

* perf(aiter): compute FAv3 rows past the last full wave split-K

The AITER FAv3 hd128 bf16 forward on gfx942/gfx950 gives each CU one 256-row
query tile. Qwen-Image-Edit at Ulysses 8 launches 258 tiles on the 256-CU
MI355X, so a second wave of 2 tiles costs as much as the first. Run the rows
past the last full wave against K slices as varlen segments over all CUs and
merge them by log-sum-exp.

* perf(qwen): default Qwen-Image(-Edit) to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950, Qwen-Image
and Qwen-Image-Edit default to AITER_BF16. Edit uses a fixed 4-way split,
because the joint edit sequence leaves too few query tiles for the split auto
picks; Qwen-Image uses auto. An explicit --attention_backend or
--mha_v4_kv_splits keeps precedence.

Replaces the FAv3 last-wave split from the previous commit.

* fix(config): keep an explicit --mha_v4_kv_splits 1 over the model default

--mha_v4_kv_splits defaulted to 1, so the runner could not tell an explicit 1
from an omitted flag and replaced it with the model's split count. The flag
now defaults to unset; the model default fills it in, and the runtime config
resolves what is still unset to 1.

* fix(qwen): only default to split-KV MHA v4 on gfx950

AITER exports the MHA v4 LSE, and so accepts kv_splits > 1, only on gfx950;
on gfx942 AITER_BF16 is available but an explicit split count raises. Gate
the Qwen default on gfx950 so MI300-series GPUs keep the global default. The
test now drives the real arch check and patches only Qwen's split-KV gate.

* perf(qwen): default Qwen-Image-Edit to MHA v4 kv_splits auto

Needs ROCm/aiter#7942: its auto picks Edit's split from a wave-rounding cost
model and runs the split in one op, so torch.compile neither breaks the graph
nor recompiles across Edit's two CFG sequence lengths. With it, auto matches
the fixed 4 on Edit 2048 (8x MI355X: 11.07 vs 11.10 s); without it, auto
leaves Edit unsplit.

* perf(flux): default FLUX.1-Kontext to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950,
FLUX.1-Kontext-dev defaults to AITER_BF16 with kv_splits auto. At 1024x1024
with Ulysses 8 each rank attends 3 heads over ~8.7k tokens, too few query
tiles to fill the GPU, which the split fills. An explicit --attention_backend
or --mha_v4_kv_splits keeps precedence.

prefer_mha_v4 moves from the Qwen runner to base_model so both use it.

* perf(minimax-h3): default MiniMax-H3 to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits on gfx950, the base MiniMax-H3 runner
defaults to AITER_BF16 with kv_splits auto. Its subclasses (FastH3, Turbo,
VDN, Ref2VA) keep their own defaults since they were not measured, and so
does --use_hybrid_attn_schedule, which refuses a set --attention_backend. An
explicit --attention_backend or --mha_v4_kv_splits keeps precedence.
jcaraban added a commit to xdit-project/xDiT that referenced this pull request Nov 24, 2026
* perf(aiter): compute FAv3 rows past the last full wave split-K

The AITER FAv3 hd128 bf16 forward on gfx942/gfx950 gives each CU one 256-row
query tile. Qwen-Image-Edit at Ulysses 8 launches 258 tiles on the 256-CU
MI355X, so a second wave of 2 tiles costs as much as the first. Run the rows
past the last full wave against K slices as varlen segments over all CUs and
merge them by log-sum-exp.

* perf(qwen): default Qwen-Image(-Edit) to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950, Qwen-Image
and Qwen-Image-Edit default to AITER_BF16. Edit uses a fixed 4-way split,
because the joint edit sequence leaves too few query tiles for the split auto
picks; Qwen-Image uses auto. An explicit --attention_backend or
--mha_v4_kv_splits keeps precedence.

Replaces the FAv3 last-wave split from the previous commit.

* fix(config): keep an explicit --mha_v4_kv_splits 1 over the model default

--mha_v4_kv_splits defaulted to 1, so the runner could not tell an explicit 1
from an omitted flag and replaced it with the model's split count. The flag
now defaults to unset; the model default fills it in, and the runtime config
resolves what is still unset to 1.

* fix(qwen): only default to split-KV MHA v4 on gfx950

AITER exports the MHA v4 LSE, and so accepts kv_splits > 1, only on gfx950;
on gfx942 AITER_BF16 is available but an explicit split count raises. Gate
the Qwen default on gfx950 so MI300-series GPUs keep the global default. The
test now drives the real arch check and patches only Qwen's split-KV gate.

* perf(qwen): default Qwen-Image-Edit to MHA v4 kv_splits auto

Needs ROCm/aiter#7942: its auto picks Edit's split from a wave-rounding cost
model and runs the split in one op, so torch.compile neither breaks the graph
nor recompiles across Edit's two CFG sequence lengths. With it, auto matches
the fixed 4 on Edit 2048 (8x MI355X: 11.07 vs 11.10 s); without it, auto
leaves Edit unsplit.

* perf(flux): default FLUX.1-Kontext to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950,
FLUX.1-Kontext-dev defaults to AITER_BF16 with kv_splits auto. At 1024x1024
with Ulysses 8 each rank attends 3 heads over ~8.7k tokens, too few query
tiles to fill the GPU, which the split fills. An explicit --attention_backend
or --mha_v4_kv_splits keeps precedence.

prefer_mha_v4 moves from the Qwen runner to base_model so both use it.

* perf(flux): default FLUX.1-dev to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits on gfx950, FLUX.1-dev defaults to
AITER_BF16 with kv_splits auto, except under PipeFusion, which runs FLUX.1 in
FP16. An explicit --attention_backend or --mha_v4_kv_splits keeps precedence.
avjves pushed a commit to xdit-project/xDiT that referenced this pull request Nov 25, 2026
…it-KV (#972)

* perf(aiter): compute FAv3 rows past the last full wave split-K

The AITER FAv3 hd128 bf16 forward on gfx942/gfx950 gives each CU one 256-row
query tile. Qwen-Image-Edit at Ulysses 8 launches 258 tiles on the 256-CU
MI355X, so a second wave of 2 tiles costs as much as the first. Run the rows
past the last full wave against K slices as varlen segments over all CUs and
merge them by log-sum-exp.

* perf(qwen): default Qwen-Image(-Edit) to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950, Qwen-Image
and Qwen-Image-Edit default to AITER_BF16. Edit uses a fixed 4-way split,
because the joint edit sequence leaves too few query tiles for the split auto
picks; Qwen-Image uses auto. An explicit --attention_backend or
--mha_v4_kv_splits keeps precedence.

Replaces the FAv3 last-wave split from the previous commit.

* fix(config): keep an explicit --mha_v4_kv_splits 1 over the model default

--mha_v4_kv_splits defaulted to 1, so the runner could not tell an explicit 1
from an omitted flag and replaced it with the model's split count. The flag
now defaults to unset; the model default fills it in, and the runtime config
resolves what is still unset to 1.

* fix(qwen): only default to split-KV MHA v4 on gfx950

AITER exports the MHA v4 LSE, and so accepts kv_splits > 1, only on gfx950;
on gfx942 AITER_BF16 is available but an explicit split count raises. Gate
the Qwen default on gfx950 so MI300-series GPUs keep the global default. The
test now drives the real arch check and patches only Qwen's split-KV gate.

* perf(qwen): default Qwen-Image-Edit to MHA v4 kv_splits auto

Needs ROCm/aiter#7942: its auto picks Edit's split from a wave-rounding cost
model and runs the split in one op, so torch.compile neither breaks the graph
nor recompiles across Edit's two CFG sequence lengths. With it, auto matches
the fixed 4 on Edit 2048 (8x MI355X: 11.07 vs 11.10 s); without it, auto
leaves Edit unsplit.

* perf(flux): default FLUX.1-Kontext to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950,
FLUX.1-Kontext-dev defaults to AITER_BF16 with kv_splits auto. At 1024x1024
with Ulysses 8 each rank attends 3 heads over ~8.7k tokens, too few query
tiles to fill the GPU, which the split fills. An explicit --attention_backend
or --mha_v4_kv_splits keeps precedence.

prefer_mha_v4 moves from the Qwen runner to base_model so both use it.

* perf(flux2-klein): default FLUX.2-klein to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits on gfx950, FLUX.2-klein-9B and -4B default
to AITER_BF16 with kv_splits auto, except under PipeFusion, which runs them in
FP16. An explicit --attention_backend or --mha_v4_kv_splits keeps precedence.
avjves pushed a commit to xdit-project/xDiT that referenced this pull request Nov 25, 2026
* perf(aiter): compute FAv3 rows past the last full wave split-K

The AITER FAv3 hd128 bf16 forward on gfx942/gfx950 gives each CU one 256-row
query tile. Qwen-Image-Edit at Ulysses 8 launches 258 tiles on the 256-CU
MI355X, so a second wave of 2 tiles costs as much as the first. Run the rows
past the last full wave against K slices as varlen segments over all CUs and
merge them by log-sum-exp.

* perf(qwen): default Qwen-Image(-Edit) to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950, Qwen-Image
and Qwen-Image-Edit default to AITER_BF16. Edit uses a fixed 4-way split,
because the joint edit sequence leaves too few query tiles for the split auto
picks; Qwen-Image uses auto. An explicit --attention_backend or
--mha_v4_kv_splits keeps precedence.

Replaces the FAv3 last-wave split from the previous commit.

* fix(config): keep an explicit --mha_v4_kv_splits 1 over the model default

--mha_v4_kv_splits defaulted to 1, so the runner could not tell an explicit 1
from an omitted flag and replaced it with the model's split count. The flag
now defaults to unset; the model default fills it in, and the runtime config
resolves what is still unset to 1.

* fix(qwen): only default to split-KV MHA v4 on gfx950

AITER exports the MHA v4 LSE, and so accepts kv_splits > 1, only on gfx950;
on gfx942 AITER_BF16 is available but an explicit split count raises. Gate
the Qwen default on gfx950 so MI300-series GPUs keep the global default. The
test now drives the real arch check and patches only Qwen's split-KV gate.

* perf(qwen): default Qwen-Image-Edit to MHA v4 kv_splits auto

Needs ROCm/aiter#7942: its auto picks Edit's split from a wave-rounding cost
model and runs the split in one op, so torch.compile neither breaks the graph
nor recompiles across Edit's two CFG sequence lengths. With it, auto matches
the fixed 4 on Edit 2048 (8x MI355X: 11.07 vs 11.10 s); without it, auto
leaves Edit unsplit.

* perf(flux): default FLUX.1-Kontext to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950,
FLUX.1-Kontext-dev defaults to AITER_BF16 with kv_splits auto. At 1024x1024
with Ulysses 8 each rank attends 3 heads over ~8.7k tokens, too few query
tiles to fill the GPU, which the split fills. An explicit --attention_backend
or --mha_v4_kv_splits keeps precedence.

prefer_mha_v4 moves from the Qwen runner to base_model so both use it.

* perf(z-image): default Z-Image to AITER MHA v4 BF16 with split-KV
jcaraban added a commit to xdit-project/xDiT that referenced this pull request Nov 25, 2026
…#977)

* perf(aiter): compute FAv3 rows past the last full wave split-K

The AITER FAv3 hd128 bf16 forward on gfx942/gfx950 gives each CU one 256-row
query tile. Qwen-Image-Edit at Ulysses 8 launches 258 tiles on the 256-CU
MI355X, so a second wave of 2 tiles costs as much as the first. Run the rows
past the last full wave against K slices as varlen segments over all CUs and
merge them by log-sum-exp.

* perf(qwen): default Qwen-Image(-Edit) to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950, Qwen-Image
and Qwen-Image-Edit default to AITER_BF16. Edit uses a fixed 4-way split,
because the joint edit sequence leaves too few query tiles for the split auto
picks; Qwen-Image uses auto. An explicit --attention_backend or
--mha_v4_kv_splits keeps precedence.

Replaces the FAv3 last-wave split from the previous commit.

* fix(config): keep an explicit --mha_v4_kv_splits 1 over the model default

--mha_v4_kv_splits defaulted to 1, so the runner could not tell an explicit 1
from an omitted flag and replaced it with the model's split count. The flag
now defaults to unset; the model default fills it in, and the runtime config
resolves what is still unset to 1.

* fix(qwen): only default to split-KV MHA v4 on gfx950

AITER exports the MHA v4 LSE, and so accepts kv_splits > 1, only on gfx950;
on gfx942 AITER_BF16 is available but an explicit split count raises. Gate
the Qwen default on gfx950 so MI300-series GPUs keep the global default. The
test now drives the real arch check and patches only Qwen's split-KV gate.

* perf(qwen): default Qwen-Image-Edit to MHA v4 kv_splits auto

Needs ROCm/aiter#7942: its auto picks Edit's split from a wave-rounding cost
model and runs the split in one op, so torch.compile neither breaks the graph
nor recompiles across Edit's two CFG sequence lengths. With it, auto matches
the fixed 4 on Edit 2048 (8x MI355X: 11.07 vs 11.10 s); without it, auto
leaves Edit unsplit.

* perf(flux): default FLUX.1-Kontext to AITER MHA v4 BF16 with split-KV

Where AITER's mha_v4 takes kv_splits (ROCm/aiter#6560) on gfx950,
FLUX.1-Kontext-dev defaults to AITER_BF16 with kv_splits auto. At 1024x1024
with Ulysses 8 each rank attends 3 heads over ~8.7k tokens, too few query
tiles to fill the GPU, which the split fills. An explicit --attention_backend
or --mha_v4_kv_splits keeps precedence.

prefer_mha_v4 moves from the Qwen runner to base_model so both use it.

* perf(qwen): default Qwen-Image-2.1 to AITER MHA v4 BF16 with split-KV

* fix(config): defer torch import in attention output codecs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants