Skip to content

[FlyDSL] Support hidden 6144 in the INT4 QuickReduce + RMSNorm epilogue - #6404

Merged
akii96 merged 4 commits into
ROCm:mainfrom
akii96:flydsl-qr-rmsnorm-6144
Oct 29, 2026
Merged

akii96 merged 4 commits into
ROCm:mainfrom
akii96:flydsl-qr-rmsnorm-6144

Conversation

@akii96

@akii96 akii96 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The FlyDSL INT4 QuickReduce all-reduce can fuse the residual add and RMSNorm into its all-gather epilogue. That only works when a whole bf16 row fits in one tile, and a hidden 6144 row (MiniMax-M3) never divides the 32 KiB tile. supports_rmsnorm rejects it, so for these shapes the epilogue never fires: QuickReduce runs the plain all-reduce, followed by a separate norm kernel (and on gfx950 a separate MXFP4 quant). This PR adds a 48 KiB tile that fits four 6144 rows, so the fusion starts firing at TP 2 and 4; TP 8 stays on the unfused path.

Technical Details

  • The kernel build now takes a tile_atoms parameter: 8 is the existing 32 KiB tile, 12 is a new 48 KiB tile that holds four 6144 rows. The default build is unchanged.
  • tile_atoms_for(hidden, world_size) picks the width. Hidden 6144 works at TP 2 and 4; TP 8 stays unsupported.
  • A 12-atom engine owns its own IPC inbox, is built by a collective (on prepare_rmsnorm(hidden) or the first fused call), and refuses to build under CUDA graph capture. Its persistent grid is clamped to the CUs' LDS residency.
  • supports_rmsnorm now needs an instance, because support depends on the number of ranks. vLLM already calls it that way, so nothing breaks.

Test Plan

Run the existing multigpu test, which now also covers hidden 6144:

python3 op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py --tp 4 --bench 2048,6144 8192,6144 16384,6144 32768,6144
python3 op_tests/multigpu_tests/test_flydsl_quick_allreduce_int4_rmsnorm.py --tp 2 --bench 8192,6144
  • New: six hidden-6144 cases at TP 2 and 4. They cover a single row, partial last tiles, plain and Gemma norm, in place and out of place, and up to 16384 rows.
  • Coverage: validity runs at TP 8, 4 and 2, so the CI multi-GPU job exercises the wide builds.
  • Checks, same as the existing cases: SQNR vs fp32 reference, tolerance vs the unfused path, cross-rank equality, and MXFP4 bitwise equal to per_1x32_f4_quant_hip.

Test Result

MI350X (gfx950): all 17 cases pass at TP 4 and TP 2, including the six new ones. MXFP4 is bitwise equal to the unfused quantizer in every case. SQNR 33.3 dB.

MI325X (gfx942): the same legs pass with the MXFP4 checks skipped (gfx950 only). SQNR ~36.1 dB.

Fused vs unfused at TP 4, hidden 6144, on MI350X. Fused: all-reduce + residual add + RMSNorm in one kernel. Unfused: FlyDSL all-reduce plus separate rmsnorm2d_fwd_with_add:

tokens fused (µs) unfused (µs) speedup
2048 121.1 135.2 1.12x
8192 395.4 416.3 1.05x
16384 741.8 779.5 1.05x
32768 1435.2 1476.8 1.03x

Fusing the MXFP4 quant as well (gfx950 only) gives 1.12x, 1.05x, 1.06x and 1.07x over all-reduce + norm + separate quant.

End to end (vLLM, amd/MiniMax-M3-MXFP4, TP 4, MI350X), stacked with FlyDSL QuickReduce, the vLLM routing fix and the FFN all-reduce deferral: +5.3 % output throughput at 60000/600 c64 vs HIP QuickReduce, about +2 % of that from fusing at hidden 6144.

@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: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 6404 --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.

@akii96
akii96 force-pushed the flydsl-qr-rmsnorm-6144 branch from 86b538b to 128ddfa Compare October 26, 2026 14:50
The fused add + RMSNorm epilogue reduces each row inside one workgroup,
so every bf16 row must sit inside one tile. A 12 KiB row (hidden 6144,
e.g. MiniMax-M3) never divides the 32 KiB tile, so those models fall
back to all-reduce plus a separate norm.

Add a 12-atom (48 KiB) build holding four 6144 rows, selected through a
tile_atoms factory parameter; the default 8-atom kernel is unchanged.
Wide engines own their own IPC inbox and are built by a collective, on
prepare_rmsnorm() or the first fused call; building under CUDA graph
capture raises. Their persistent grid is clamped to the CUs' LDS
residency. 12 atoms split across TP 2 and 4; TP 8 keeps rejecting 6144.

Co-authored-by: Claude (DSH agent)
Signed-off-by: Aakif Nawaz <[email protected]>
@akii96
akii96 force-pushed the flydsl-qr-rmsnorm-6144 branch from 128ddfa to c8c9076 Compare October 26, 2026 15:27
@akii96
akii96 marked this pull request as ready for review October 26, 2026 15:29
@akii96
akii96 requested a review from a team October 26, 2026 15:29
@akii96

akii96 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@TennyWang1223 gentle ping on this one for when you get a chance!

This is small extension to #6369 so the fused RMSNorm path covers hidden 6144 (MiniMax-M3) at TP 2 and 4. Default kernel untouched, validated on MI350X and MI325X. Thanks!

@TennyWang1223

Copy link
Copy Markdown
Contributor

review summary

Verdict: Needs work (advisory)

Evidence: The PR applies cleanly to main. I ran the test on 8x MI308X (gfx942): TP 8/4/2 all pass, including the new hidden-6144 cases. CI has no failures. At TP4 the fused path was 1.99x faster at 2048 tokens and 0.99x at 16384 tokens (one sample each).

Findings

  1. Int32 offset overflow with the 48 KiB tile [verified]: at hidden 6144 with 174761 or 174762 rows, _atom_soff reaches 2^31 for atoms 8–11 of the last tile and wraps. The soff < nbytes mask still passes. Production token counts don't reach this. Fix: cap the payload at 2**31 - tile_bytes, or compute the mask in 64-bit.
  2. Wide engines are built on first use [inferred]: the first fused call at hidden 6144 runs a collective and allocates about 285 MiB per rank. During graph capture it raises instead of falling back, and supports_rmsnorm still returns True. vLLM never calls prepare_rmsnorm. Ask: return False during capture, or build the engines eagerly, or have vLLM call prepare_rmsnorm.
  3. CI never ran the changed test [verified]: the 8-GPU MI350X job was skipped because the PR has no ci:multi-gpu label. Fix: add the label and get a green run before merge.

@akii96 akii96 added the ci:multi-gpu Trigger multi-GPU op tests on PR label Oct 28, 2026
@akii96

akii96 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @TennyWang1223

Added ci:multi-gpu + Pushed commit 0452cab with the requested fixes:

  • Fixed the signed 32-bit offset overflow while keeping the largest safe input supported.
  • Verified the failing case before and after the fix on gfx942 and gfx950.
  • Added safe handling for CUDA graph capture when the wider kernel is not ready.
  • The upcoming vLLM change will prepare the wider kernel before graph capture!

@TennyWang1223 TennyWang1223 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.

LGTM, can merge after CI pass

@akii96
akii96 merged commit 4d19806 into ROCm:main Oct 29, 2026
54 checks passed
vpietila-amd added a commit that referenced this pull request Oct 30, 2026
…sed QR RMSNorm, gfx950/xGMI retune)

Ported:
- FAMILY_POLICIES gfx950/xGMI TP2 one-shot window 64 MiB -> 4 MiB.
- MESH_ST_LADDER gfx950/xGMI retune (one b256 rung per TP).
- Policy test import fix (strict CustomAllreduce is_weak_contiguous).
- main: Gluon gfx1250 fused AR+RMSNorm hooks in communicator_cuda.

Superseded by this branch's fused design, not ported:
- QuickAllReduceInt4 fused RMSNorm (rmsnorm_hidden, compile_rmsnorm,
  runtime eps, MESH_NORM_LADDER): replaced by FlyQuickAllReduceRMSNorm,
  whose eps is already a launch argument, whose widths are prepared by
  FlyDSLAllReduceRMSNorm (hiddens / AITER_FLY_AR_FUSED_HIDDENS / prime),
  and whose ladders come from fused_allreduce_ladders.json.
- #6404 12-atom tiles for hidden 6144: the row-block geometry builds 6144
  natively (block 768) at TP2/4/8, and rows are addressed per row in i64.
- quick_allreduce_int4.py kernel/host and its RMSNorm test: deleted here.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
…ue (#6404)

* [FlyDSL] Support hidden 6144 in the INT4 QuickReduce + RMSNorm epilogue

The fused add + RMSNorm epilogue reduces each row inside one workgroup,
so every bf16 row must sit inside one tile. A 12 KiB row (hidden 6144,
e.g. MiniMax-M3) never divides the 32 KiB tile, so those models fall
back to all-reduce plus a separate norm.

Add a 12-atom (48 KiB) build holding four 6144 rows, selected through a
tile_atoms factory parameter; the default 8-atom kernel is unchanged.
Wide engines own their own IPC inbox and are built by a collective, on
prepare_rmsnorm() or the first fused call; building under CUDA graph
capture raises. Their persistent grid is clamped to the CUs' LDS
residency. 12 atoms split across TP 2 and 4; TP 8 keeps rejecting 6144.

Co-authored-by: Claude (DSH agent)
Signed-off-by: Aakif Nawaz <[email protected]>

* [FlyDSL] guard QuickReduce RMSNorm soffset range

Signed-off-by: Aakif Nawaz <[email protected]>

---------

Signed-off-by: Aakif Nawaz <[email protected]>
akii96 added a commit to akii96/vllm that referenced this pull request Nov 5, 2026
…lyDSL QuickReduce

fused_allreduce_gemma_rms_norm is the manual AR + norm fusion MiniMax-M3
calls directly (it runs without torch.compile, so fuse_allreduce_rms never
sees it). On ROCm it only fused on the one-stage custom all-reduce, i.e.
decode sizes; prefill fell back to all-reduce plus a separate norm.

With FlyDSL INT4 QuickReduce on, route sizes the custom all-reduce
declines to QuickAllReduce.fused_allreduce_rmsnorm(gemma_norm=True) when
it accepts the operands. QuickAllReduce also builds the fused-norm
engines for the model's hidden size at init, so hidden sizes AITER runs
on a wider tile (6144) never build them inside profiling or graph
capture.

Requires ROCm/aiter#6404 for hidden-size 6144 support.

Signed-off-by: Aakif Nawaz <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…ue (ROCm#6404)

* [FlyDSL] Support hidden 6144 in the INT4 QuickReduce + RMSNorm epilogue

The fused add + RMSNorm epilogue reduces each row inside one workgroup,
so every bf16 row must sit inside one tile. A 12 KiB row (hidden 6144,
e.g. MiniMax-M3) never divides the 32 KiB tile, so those models fall
back to all-reduce plus a separate norm.

Add a 12-atom (48 KiB) build holding four 6144 rows, selected through a
tile_atoms factory parameter; the default 8-atom kernel is unchanged.
Wide engines own their own IPC inbox and are built by a collective, on
prepare_rmsnorm() or the first fused call; building under CUDA graph
capture raises. Their persistent grid is clamped to the CUs' LDS
residency. 12 atoms split across TP 2 and 4; TP 8 keeps rejecting 6144.

Co-authored-by: Claude (DSH agent)
Signed-off-by: Aakif Nawaz <[email protected]>

* [FlyDSL] guard QuickReduce RMSNorm soffset range

Signed-off-by: Aakif Nawaz <[email protected]>

---------

Signed-off-by: Aakif Nawaz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:multi-gpu Trigger multi-GPU op tests on PR FlyDSL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants