Skip to content

[CK] [FlyDSL] [JIT] [Kernel] Add gfx950 4-wave INT8 bpreshuffle GEMM - #6828

Merged
ksikiric merged 15 commits into
mainfrom
gfx950-flydsl-int8-gemm
Nov 17, 2026
Merged

ksikiric merged 15 commits into
mainfrom
gfx950-flydsl-int8-gemm

Conversation

@ksikiric

@ksikiric ksikiric commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #6827.

Add a public gfx950 FlyDSL signed-INT8 GEMM to
aiter.gemm_a8w8_bpreshuffle, with tuned 256-CU dispatch, a correct untuned
fallback, and AOT/run-only support.

The kernel uses a 256x256x128 workgroup tile, one wave per SIMD,
v_mfma_i32_16x16x64_i8 with INT32 accumulation, two LDS buffers, and FP32
row/column scales before BF16 stores.

Motivation

AITER already ships gfx950 INT8 ASM bpreshuffle kernels. This change adds a
distinct FlyDSL implementation through gemm_a8w8_bpreshuffle, with higher
measured throughput, tuned and untuned routing, tests, and deployable AOT
support.

Changes

  • Add the gfx950 4-wave INT8 kernel and a validated runtime wrapper.
  • Route signed-INT8 calls through the public bpreshuffle API.
  • Use persistent dispatch for measured K=5120 shapes when the output tile grid
    exceeds active CUs; use non-persistent dispatch for K=13824 and general
    supported shapes.
  • Derive CDNA4 XCD count from active CUs.
  • Add three measured 256-CU tuning rows.
  • Filter shared bpreshuffle-table rows by backend: INT8 dispatch uses only
    rows that run on FlyDSL at the physical K (4-wave rows, and generic rows the
    FlyDSL launcher accepts at that M and K) and otherwise takes the 4-wave
    fallback, because the generic launcher's CK fallback is FP8-only.
    gemm_a8w8_ASM skips the FlyDSL rows and uses every other INT8 row, as
    before, also when libtype is blank or filled in by a table merge;
    --run_config routes INT8 rows the same way.
  • The public INT8 checker enforces the 32-bit size bounds and the INT32 K limit
    before output allocation and config lookup.
  • Enroll the kernel in the common FlyDSL bpreshuffle tuner.
  • AOT: the replaying FlyDSL GEMM AOT driver replays INT8 rows with INT8
    operands, so the tuned rows compile into the cache.
  • Set slp-vectorize-once-used off for the kernel, as every gfx950 FlyDSL GEMM
    does since the FlyDSL 0.4.1 pin.
  • Cover INT8 in existing tests: correctness and dispatch checks in
    op_tests/test_gemm_a8w8.py, tuner candidates in
    op_tests/tuning_tests/test_tuner_infra.py, and the XCD count in
    tests/test_chip_info_xcds.py.

Public contract

  • Hardware: gfx950.
  • XQ, WQ: contiguous signed torch.int8; WQ uses
    shuffle_weight(..., layout=(16, 16)).
  • Scales: FP32 per activation row and output column.
  • Output: BF16.
  • K >= 256, K % 128 == 0, K_w % 128 == 0, N % 16 == 0. A K-padded
    WQ (K_w > K) dispatches at K_w.
  • 32-bit offsets: M*N*2, M*K_w and N*K_w must each be below 2**31.
  • K_w <= 130944: the kernel accumulates in INT32, and K_w full-range
    products of 128 * 128 must stay below 2**31.
  • bias must be None. INT8 calls with a bias tensor are rejected before
    dispatch; callers add bias after the GEMM.
  • Untuned supported shapes use the same kernel with a logged fallback.
  • Unsupported architectures and ABI combinations fail before launch.

Performance

Measured sequentially on one fixed physical AMD Instinct MI355X with FlyDSL
0.5.0:

  • gfx950, 256 CUs / 8 XCDs.
  • 30 warmups, 200 iterations, 15 rotating repeats.
  • Identical operands per shape; CUDA-graph replay; packing excluded.
M x N x K 4-wave TFLOP/s Gluon TFLOP/s ASM TFLOP/s Speedup vs ASM CK TFLOP/s
9450 x 5120 x 5120 2909.12 1737.31 1593.37 1.83x 415.62
9450 x 13824 x 5120 2954.45 1733.87 1536.20 1.92x 1787.22
9450 x 5120 x 13824 3089.70 2005.72 1721.40 1.79x 1886.02

ASM baseline (best ASM kernel for all three shapes):
_ZN5aiter42I8gemm_bf16_perTokenI8_BpreShuffle_160x128E

These numbers come from a standalone CUDA-graph harness that is not part of
this PR. In the repository, op_tests/test_gemm_a8w8.py times the same kernel
(its ck bpreshuffle us column) against CK:

python op_tests/test_gemm_a8w8.py -d bf16 -q i8 \
  -mnk 9450,5120,5120 9450,13824,5120 9450,5120,13824 --no-flydsl-csv

It uses its own timing, so its numbers differ from the table, and on gfx950 it
does not time the INT8 ASM kernels.

128-CU support

Runtime and offline AOT derive or accept the 128-CU / 4-XCD topology
explicitly, and the persistent and non-persistent _xcd4 variants are
bit-exact against the reference. No 128-CU hardware was available, so this PR
includes no unmeasured 128-CU tuning rows or performance claims. Those devices
use the correct untuned fallback until separately measured rows are available.

Validation

See "Validation and unverified scope" under PR Self-Review.

PR Self-Review

Reviewed revision

d18737f

Behavior and intent

  • On gfx950, gemm_a8w8_bpreshuffle now accepts signed INT8 XQ/WQ and runs
    them on the new 4-wave FlyDSL kernel: the three tuned 256-CU rows, and a
    logged 4-wave fallback for any other supported shape. Before, INT8 calls
    failed its FP8-only assertion, and INT8 bpreshuffle was available only
    through the ASM kernels, which are 1.78-1.92x slower on the measured shapes.
  • FP8 dispatch is unchanged. gemm_a8w8_ASM uses every INT8 row of the shared
    table except the FlyDSL ones, as before this PR, and --run_config routes
    INT8 rows the same way.

Validation and unverified scope

All on MI355X (gfx950, 256 CUs) with FlyDSL 0.5.0, the current main pin.

At a617357:

  • python op_tests/test_gemm_a8w8.py --no-flydsl-csv --no-legacy: INT8 4-wave
    correctness passed (4 bit-exact shapes, padded K, signed extrema including
    all-(-128) operands at K=130944, zero rows, contract rejections including
    K=131072, torch.compile, CUDA graph and a side stream), and so did the
    INT8 dispatch checks. When the test sees gfx942, both log as skipped and the
    script exits 0.
  • python op_tests/tuning_tests/test_tuner_infra.py: the four FlyDSL
    bpreshuffle candidate tests pass. Two TestGroupedFmoeResultToCsv tests
    error the same way on current main.
  • pytest tests/test_chip_info_xcds.py tests/test_flydsl_aot_replay.py: 43
    passed, including
    test_int8_csv_rows_reach_the_4wave_kernel_through_public_replay.
  • AOT: python -m aiter.aot.flydsl.gemm --csv <the three INT8 rows> into an
    empty cache (3 rows and 29 bisected smaller M, no failures), then --check.
    The three tuned shapes ran bit-exact with FLYDSL_RUNTIME_RUN_ONLY=1, and an
    untuned shape was refused.
  • The persistent and non-persistent _xcd4 variants are bit-exact against
    the reference.
  • Performance against the previous head (41e31d3 on FlyDSL 0.4.1), three
    alternating rounds per side on one GPU: the medians are within 0.2% on all
    three shapes. The final ISA has the same instruction sequence apart from two
    address additions scheduled earlier, the same AGPR and SGPR counts, no
    spills, and 4 fewer VGPRs at K=5120.

Unverified:

  • 128-CU hardware: no 128-CU rows are tuned or measured.
  • The legacy CK sweep of op_tests/test_gemm_a8w8.py on this branch.

PR-specific question

Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?

  • Architecture: gfx950 only; _check_int8_bpreshuffle_contract raises
    NotImplementedError on any other arch before dispatch.
  • Dtype: XQ and WQ both torch.int8, FP32 per-row and per-column
    scales, BF16 output, bias=None; anything else raises before dispatch. FP8
    inputs never take the INT8 path.
  • Shapes: 2-D contiguous operands with K >= 256, K and K_w multiples of 128,
    K_w >= K, K_w <= 130944 (so full-range products accumulate in INT32) and N a
    multiple of 16, with M*N*2, M*K_w and N*K_w below 2**31. Tuned rows
    are looked up at the physical K_w.
  • Invariants: every contract check, including the size and K limits, runs
    in the public checker before output allocation, config lookup or launch.
    INT8 dispatch uses a tuned row only if it runs on FlyDSL at the launch M and
    K (a 4-wave row, or a generic row whose name parses and whose M and K the
    launcher accepts); any other row takes the 4-wave fallback, so INT8 operands
    never reach the FP8-only CK fallback.

Changed op tests

  • op_tests/test_gemm_a8w8.py: run_int8_4wave_ci_correctness() runs from the
    CI script entry and checks INT8 bit-exactly on 4 shapes through the untuned
    fallback, padded K_w, signed extrema (including all-(-128) operands at the
    INT32 K limit, K=130944) and zero rows, plus contract rejections (including
    the next K), torch.compile, CUDA graph capture and a side stream.
    run_int8_4wave_dispatch_checks() runs next to it with fake tuned rows and
    launches: the tuned-row lookup at the physical K, the 4-XCD fallback on a
    128-CU tuning miss, use of only tuned rows that run on FlyDSL,
    gemm_a8w8_ASM skipping only FlyDSL rows (blank, NaN, 0 and missing
    libtype stay ASM), contract rejections before the
    tuned-row lookup, and the 4-wave compile guards. Both run only on gfx950.
    The INT8 case generator and exact reference (FP32 GEMM of the INT8 values
    with the FP32 scales, rounded to BF16) live in this file. test_gemm now
    runs per-token INT8 through bpreshuffle where the 4-wave kernel supports the
    shape. No other op test reaches the INT8 path of gemm_a8w8_bpreshuffle.
  • op_tests/tuning_tests/test_tuner_infra.py:
    TestFlydslA8w8BpreshuffleCandidates also checks the int8_4wave pipeline
    order, the names of generic INT8 candidates, and the K, topology and
    persistence of the 4-wave candidates.

@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 6828 --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.

@ksikiric ksikiric changed the title [Kernel] Add gfx950 4-wave INT8 bpreshuffle GEMM [FlyDSL] [Kernel] Add gfx950 4-wave INT8 bpreshuffle GEMM Oct 22, 2026
@ksikiric
ksikiric force-pushed the gfx950-flydsl-int8-gemm branch from dbe12fd to 6f7d083 Compare October 22, 2026 10:20
@johannes-graner
johannes-graner self-requested a review October 22, 2026 12:48

@johannes-graner johannes-graner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work on this. The speedup claims reproduced on an identical MI355X, with both warm and cold cache. Below are the items I would like to see addressed before merge, with a few exceptions: items left to you (this PR or a follow-up), one nit, and some design questions.

Numbered items

  1. Padded-K weights select an incompatible tuned row
  2. The ASM-only lookup breaks on the new FlyDSL rows
  3. The existing GEMM sweep calls the new candidate unconditionally
  4. Inline assembly and non-stable FlyDSL APIs
  5. The CI entry point does not run the new correctness cases
  6. The benchmark correctness reference is a candidate
  7. Dispatch assertions depend on the production tuning table
  8. The new kernel is not enrolled in the common tuner
  9. Untuned small-M INT8 fallback performance
  10. CU count validation in the XCD derivation
  11. XCD power-of-two assert

Design questions

  • Should consumers of the shared bpreshuffle tuned table filter rows by libtype and K before they use a kernel name? Items 1 and 2 both come from a consumer that reads this table without that check.
  • Is adding bias after BF16 conversion required by the intended consumer, or is it mainly a way to keep the device kernel specialized? The existing generic preshuffle bias epilogue adds bias before conversion, so the two are not numerically interchangeable. Bias-enabled calls were not part of the performance comparison (aiter/ops/gemm_op_a8w8.py:802).
  • Which existing generic FlyDSL INT8 configurations did you compare against before choosing a separate pipeline? The harness includes one flydsl_generic configuration, and the common tuner covers other tiles and split-K. A comparison against that family would establish the separate kernel's incremental benefit.

Lower importance

nit, lower importance. Could the PR body add the flydsl-kernel-code-cleanup completion checkbox once that pass is done? Keeping the rationale for each assembly boundary lets reviewers tell intentional exceptions from leftovers.

Comment thread op_tests/test_gemm_a8w8.py Resolved
Comment thread op_tests/test_flydsl_int8_4wave.py Resolved
Comment thread op_tests/test_flydsl_int8_4wave.py Resolved
Comment thread aiter/ops/gemm_op_a8w8.py Resolved
@ksikiric
ksikiric force-pushed the gfx950-flydsl-int8-gemm branch from 2359f19 to 13b2e0c Compare October 26, 2026 07:20
@ksikiric

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review. All numbered items are addressed in the latest push, which is also rebased onto current main; per-item replies are on each thread. Performance on the three measured shapes is unchanged versus the reviewed head (same MI355X, back-to-back runs, within 0.5%).

Design questions

  • Shared-table filtering: Yes. Every consumer of the bpreshuffle table in this PR now checks both: the INT8 path resolves rows at the physical (padded) K and ignores non-FlyDSL rows, gemm_a8w8_ASM ignores non-ASM rows, and --run_config routes INT8 rows by libtype. FP8 lookup is unchanged.
  • Bias: Post-GEMM bias only kept the device kernel specialized; the caller we tested already adds bias itself after the GEMM. Since it isn't interchangeable with the generic epilogue, it is removed: INT8 calls with bias are rejected before dispatch, and callers add bias after the GEMM.
  • Generic FlyDSL comparison: The 4-wave kernel is now in the common tuner, so the full --libtype flydsl family competes directly. MI355X, 256 CUs; within each shape both sides were timed by the same harness:
    • 9450x5120x5120: 1,472 generic configurations; best flydsl_bpreshuflle_128x256x128_I8_I8_B16_1x2x4x2_default at 1535 TFLOP/s vs 4-wave 2490.
    • 9450x13824x5120: 1,472 generic configurations; best flydsl_bpreshuflle_160x192x128_I8_I8_B16_1x0x4x2_default at 1683 TFLOP/s vs 4-wave 2660.
    • 9450x5120x13824: the exhaustive sweep exceeded the tuner's time limit, so I re-timed the winners from the two K=5120 sweeps with 15 paired CUDA-graph repeats: best generic 1871 TFLOP/s vs 4-wave 3015.
    • Split-K does not apply at M=9450: every generic tile grid already exceeds 256 workgroups, where k_split_candidates returns no candidates.

Nit: The flydsl-kernel-code-cleanup pass is complete: no legacy buffer_ops or private MLIR type construction remain, waits use the stable keyword API, and each retained raw boundary carries its rationale at the call site.

@johannes-graner

Copy link
Copy Markdown
Contributor

Thanks for the following up quickly, in general it now looks very nice!

A few small comments though:

  1. Public docstring (gemm_a8w8_bpreshuffle, INT8 section in aiter/ops/gemm_op_a8w8.py). Could it say explicitly that bias must be None for INT8, since it is now rejected before dispatch? Could it also list the 32-bit extent limits checked in aiter/ops/flydsl/gemm_a8w8_bpreshuffle_4wave.py (MN2, MK_w, NK_w)? They narrow the accepted shapes beyond the alignment rules already listed.
  2. PR description. Several parts still describe the previous state of the branch:
    • It advertises optional BF16 bias applied after the GEMM. Bias is now caller-owned and rejected by the API.
    • "62 passed, 1 skipped" refers to the removed op_tests/test_flydsl_int8_4wave.py suite. Correctness now lives in op_tests/test_gemm_a8w8.py and tests/test_gemm_a8w8_int8_4wave.py.
    • The performance table predates the kernel refactor. Please check it's up to date and update otherwise.
  3. Optional: run_int8_4wave_ci_correctness() passes silently, and the script then moves into a long CSV sweep. A one-line summary print would let a CI log show that the INT8 cases ran.

Once the docstring and description are updated, I will approve and you can open for further review.

@ksikiric

Copy link
Copy Markdown
Contributor Author

Thanks! All addressed in the latest push:

  • Docstring: the INT8 section of gemm_a8w8_bpreshuffle now says bias must be None (rejected before dispatch; callers add it after the GEMM) and lists the 32-bit limits: M*N*2, M*K_w and N*K_w must each be below 2**31.
  • PR description: updated. Bias is caller-owned, Validation points at op_tests/test_gemm_a8w8.py and tests/test_gemm_a8w8_int8_4wave.py, and the performance table is re-measured at the current head with the same command on the same GPU. The numbers are within 0.5% of the old table; the best ASM baseline is now 160x128 for all three shapes. I also re-checked the _xcd4 and AOT run-only statements at the current head.
  • CI summary (optional): done. run_int8_4wave_ci_correctness() logs one line when the INT8 cases pass, and one when they are skipped off gfx950.

@ksikiric
ksikiric marked this pull request as ready for review October 26, 2026 11:28
@ksikiric
ksikiric requested review from a team and a balanced review from Copilot October 26, 2026 11:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot changed the title [FlyDSL] [Kernel] Add gfx950 4-wave INT8 bpreshuffle GEMM [CK] [FlyDSL] [JIT] [Kernel] Add gfx950 4-wave INT8 bpreshuffle GEMM Oct 26, 2026
@zufayu
zufayu removed the request for review from yadaish October 29, 2026 10:17
Copilot AI balanced review requested due to automatic review settings November 10, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@zufayu
zufayu requested review from aoli26 and yadaish November 11, 2026 06:50
@zufayu zufayu assigned aoli26 and unassigned coderfeli Nov 11, 2026
@zufayu
zufayu requested a review from coderfeli November 11, 2026 06:51
Copilot AI balanced review requested due to automatic review settings November 12, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Comment thread aiter/ops/gemm_op_a8w8.py Resolved
gemm_a8w8_ASM and the tuner's --run_config accepted an INT8 row only
when its libtype was "" or "asm". pandas reads a blank libtype as NaN
("nan"), and merging a table without the column fills it with 0, so such
rows were skipped and gemm_a8w8_ASM fell back to the heuristic kernel
with splitK=1. Before FlyDSL INT8 every INT8 row was ASM; now only the
FlyDSL rows are skipped. The dispatch checks cover blank, NaN, "0", 0 and
missing libtype.
Copilot AI balanced review requested due to automatic review settings November 16, 2026 10:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@solinzby1

Copy link
Copy Markdown
Contributor

LGTM

Comment thread aiter/jit/utils/chip_info.py Resolved
@ksikiric
ksikiric merged commit 75347d8 into main Nov 17, 2026
@ksikiric
ksikiric deleted the gfx950-flydsl-int8-gemm branch November 17, 2026 09:36
ZLkanyo009 added a commit that referenced this pull request Nov 17, 2026
Main's #6828, merged in with #8030, adds signed-INT8 operands to
gemm_a8w8_bpreshuffle and makes its FP8 path assert that XQ has WQ's dtype.
The fast path checked only WQ's dtype, so an XQ of another dtype with an FP8
WQ ran the CK kernel where the custom op now raises. The fast path now
declines unless XQ and WQ are both FP8. INT8 calls run FlyDSL kernels, which
it never stands in for, and reach the custom op as before.

#6828 also documents the INT8 contract on the custom op's body, which this
PR keeps as the private _gemm_a8w8_bpreshuffle_op, while the public
gemm_a8w8_bpreshuffle had a one-line, FP8-only docstring. The docstring
moves unchanged to the public function.

op_tests/test_a8w8_eager.py: a BF16 XQ with an FP8 WQ reaches the custom op
and its "dtypes must match" assertion. With the new check removed, the call
takes the fast path and the test fails.
ZLkanyo009 added a commit that referenced this pull request Nov 17, 2026
…function

Which kernel a bpreshuffle GEMM runs was decided twice: in
_gemm_a8w8_bpreshuffle_into for the custom op, and again in the eager fast
path, which repeated the FP8 table lookup and the gfx1250 exception for
untuned shapes. #6828 just changed that routing on main (INT8), and every
such change had to be made in both places.

_bpreshuffle_kernel(m, n, k, w_k, q_dtype) now makes the decision and
returns it as data: the tuned row (a CK, CKTile or FlyDSL row runs that
libtype with its splitK) and, without one, the FlyDSL kernel the shape falls
back to (INT8's default 4-wave kernel, the closest fitting one on gfx1250);
with neither, the default CK kernel runs. _gemm_a8w8_bpreshuffle_into
launches what it returns, pads a K-padded XQ, logs the fallback warnings and
wraps default-kernel errors as before. The fast path calls the CK entry
directly for a CK row, or with splitK 0 when there is neither a row nor a
fallback, and declines otherwise; it has no gfx1250 check of its own.

The kernel choice, the warnings and the error text are unchanged: with the
launchers, the table lookup and the arch replaced by recorders, the op path
makes the same calls before and after this commit in all 168 cases of a grid
of rows (CK with and without split-K, CKTile, FlyDSL, an unparsable FlyDSL
name, asm, none) x FP8 / INT8 x K-padded or not x gfx942 / gfx1250 x a
failing CK launch.

Host time of one gemm_a8w8_bpreshuffle call on MI308X, weighted over the
four tuned CK shapes of Qwen3.8-Flash-Next PTPC FP8 at TP2, three
alternating runs each, before -> after this commit: fast path 13.89 -> 14.13
us warm, 29.16 -> 29.11 us cold; custom op through the dispatcher 21.84 ->
22.23 us warm, 44.57 -> 43.96 us cold. The public call on main is 22.59 /
45.56 us.
avjves pushed a commit to xdit-project/xDiT that referenced this pull request Nov 18, 2026
* style: ruff-format the loading backends and runner utils

Upstream lints whole changed files since the pre-commit CI (#798, #806), and the
AITER INT8 change touches these files. Formatting only, plus one trailing
whitespace fix in runner_utils.py; no behavior change.

* feat(rocm): add AITER INT8 GEMMs for Wan2.2 T2V

Adds xFuserAiterInt8Linear, an INT8 linear on AITER's signed-INT8
gemm_a8w8_bpreshuffle (the gfx950 4-wave FlyDSL GEMM, ROCm/aiter#6828), and an
AITER INT8 format backend that --gemm_quantization int8 selects on ROCm.

- Activations are quantized per row with round-to-nearest in a Triton kernel;
  weights are quantized per output channel and preshuffled once at load.
  Bias is added after the GEMM.
- The backend is available when AITER has #6828 and the GPU is gfx950;
  otherwise the probe reports why.
- Only Wan2.2 T2V opts in (use_aiter_int8_gemms), for both transformers.
  Models that declare TorchAO INT8 only, such as Z-Image, are not routed to
  AITER.

* fix(rocm): import Triton only where it is installed

PR CI installs the CPU torch wheel, which has no Triton, so importing
xfuser.model_executor.layers failed and no CPU test could be collected.
Guard the import the way xfuser/core/vsa_attention.py does.

* test(rocm): tighten the AITER INT8 tests

- Restore upstream's cross-product contract test: a model with TorchAO
  INT8 only must not get AITER INT8.
- Fold the INT8 FSDP case into the MXFP4 FSDP test and drop the test
  that only asserted descriptor constants.
- Test that Wan2.2 T2V accepts --gemm_quantization int8 and Wan2.1 T2V
  rejects it, instead of asserting capability flags.
- Fold the zero-input case into the linear test as zero padding rows.

* fix(rocm): name the missing AITER module, not a PR number, when INT8 is unavailable

* fix(wan): check projection types before their weights in the SDMA Q/K-first check

_qk_first_eligible read weight.shape on to_q/to_k/to_v before checking that
they are nn.Linear. AITER INT8 linears have no weight, so --gemm_quantization
int8 with --ulysses_a2a sdma --ulysses_sdma_overlap_qkv raised AttributeError
instead of falling back to the standard path.

* fix(rocm): declare AITER INT8 independently of TorchAO INT8

use_int8_gemms now declares only TorchAO INT8 and use_aiter_int8_gemms only
AITER INT8, so Wan2.2 T2V no longer accepts --gemm_quantization int8 on CUDA,
where it was never run. The CLI accepts int8 for a model that declares either
backend, and the load contract refuses the one it lacks.

The model reference names the INT8 platform (CUDA or ROCm gfx950) instead of a
check mark, and INT8 joins FP4 in select_runtime_quantization's routing branch.

* refactor(rocm): share the Linear-replacement walker between FP8 blockscale and INT8

- One _replace_linear_leaves walk for quantize_linear_layers_to_fp8_blockscale
  and quantize_linear_layers_to_aiter_int8. INT8 now frees the BF16 weight
  before quantizing, as FP8 blockscale did.
- INT8 picks layers with AITER's supports_4wave_int8_shape instead of a local
  copy of its rules, and its unit test goes with the copy.
- Drop offload_to_cpu from the INT8 adapter; the INT8 placement never passed it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add gfx950 FlyDSL 4-wave INT8 bpreshuffle GEMM

7 participants