Skip to content

[HIP] Fix mxfp4 MoE aux sort build on gfx1250 - #8164

Merged
zufayu merged 1 commit into
mainfrom
fsx/fix-moe-sort-quant-gfx1250-dpp
Nov 24, 2026
Merged

zufayu merged 1 commit into
mainfrom
fsx/fix-moe-sort-quant-gfx1250-dpp

Conversation

@fsx950223

Copy link
Copy Markdown
Contributor

Motivation

Fixes #8133: module_moe_mxfp4_aux fails to build for gfx1250:

FAILED: [code=1] aux_sort_quant_NE128_TOPK3_MB32_H5120.cuda.o
error: Illegal instruction detected: Invalid dpp_ctrl value: broadcasts are not supported on GFX10+

Technical Details

dpp_inclusive_scan_wave in csrc/kernels/mxfp4_moe/moe_aux/moe_sort_quant.cuh used DPP row_bcast:15 and row_bcast:31 (0x142, 0x143), which exist only on GFX9. #7540 fixed the same bug in moe_sorting_opus, and this PR uses the same fix:

  • The GFX9 path is unchanged.
  • On other targets, the cross-row step adds the totals of the earlier 16-lane rows, read with readlane.

parallel_cumsum already sizes its waves with WARP_SIZE (opus::get_warp_size(), 32 on gfx1250). The worst case is E=896, which is 28 waves; its static_assert still holds.

The 36 failed gfx1250 MoE AOT replays in #8133 are not caused by this build failure. They fail at assert slot_width <= 128 in mxfp4_preshuffle_gfx1250_tdm.py, which is tracked as #8162. With this fix in place, row 68 of tuned_grouped_fmoe.csv still fails, and the traceback ends at that assertion. The gfx1250 grouped path never builds module_moe_mxfp4_aux. A failed JIT build raises RuntimeError, not an empty AssertionError.

Test Plan / Result

On gfx1250, ROCm 10.1 SDK image:

  • Module build: with GPU_ARCHS=gfx1250, origin/main fails with the ld.lld error above. With this PR the full module builds (about 43 s).

  • Scan unit test: compiled dpp_inclusive_scan_wave and parallel_cumsum and compared them on the GPU with a host reference. That covers 4 random 1024-lane inputs, including negative values, and E = 24, 33, 96, 128, 129, 256, 257, 385, 513 and 896. All pass.

  • End-to-end aux sort: compared fused_moe._adaptive_moe_sort output with routes computed on the host. Checked fields:

    • num_valid_ids
    • the order and counts of sorted_expert_ids
    • the route set
    • m_indices
    • reverse_sorted
    • the zeroed moe_buf

    Covered:

    • 10 shapes from E=24 to E=896
    • BM16 with and without zero-init, plus the three-stage BM32 and BM64 sorts
    • M from 1 to 257, with skewed routing, pad rows and num_local_tokens

    Result: 400/400 pass. With the cross-row carry deliberately removed, all 200 BM16 cases fail.

  • gfx950: the device assembly of a sort instance is identical before and after; only the per-file __hip_cuid hash differs. The full module also builds for gfx950.

🤖 Generated with Claude Code

@fsx950223
fsx950223 requested review from a team and a balanced review from Copilot November 18, 2026 05:55

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.

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

@github-actions github-actions Bot added the HIP label Nov 18, 2026
@aiter-bot

aiter-bot commented Nov 18, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision b874e0b44f72 · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer

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

@zufayu

zufayu commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

aiter-bot — queued behind 3 review(s); expect to start in about 79 min. The box reviews one PR at a time.

@aiter-bot aiter-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ROCm/aiter PR #8164 — [HIP] Fix mxfp4 MoE aux sort build on gfx1250

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — the PR changes runtime code that is executed at run time (the gfx1250 mxfp4 MoE aux-sort scan in csrc/kernels/mxfp4_moe/moe_aux/moe_sort_quant.cuh) but ships no test target for the validator to run; compile-level checks re-derived by hand on this box: base fails to assemble for gfx1250 with #8133's exact error, head builds clean for gfx1250 and gfx950, head's gfx950 device assembly is identical to base modulo the __hip_cuid hash, and the readlane carry is proven equal to the removed row_bcast pair by host simulation (300k random waves incl. negatives, wave64 and wave32, 28.8M lane-checks, 0 mismatches).
Perf (advisory): NOT RUN — Step 1 triaged perf as required but the PR ships no perf target; the in-repo benchmark (op_tests/op_benchmarks/hip/bench_mxfp4_moe_sort_quant.py) could not be run from this review box (no GPU access), and on gfx942/gfx950 the emitted sort code is unchanged, so gfx1250 is the only arch where a number could move.
Size: 25 lines / 1 files
Design (advisory): NONE — re-applies the #7540 gfx1250 row_bcast-removal pattern already landed for moe_sorting_opus
Human: N/A — design is NONE: the diff applies an existing, twice-landed pattern and decides nothing new

⚠️ [verified] The PR ships no in-repo test and no CI job exercises the new gfx1250 branch of dpp_inclusive_scan_wave (moe_sort_quant.cuh): the changed scan runs in the gfx1250 mxfp4 MoE serving path, where a wrong carry silently corrupts expert routing; the existing collected test op_tests/test_moe_sorting_mxfp4.py covers this kernel only on the MI35X/gfx950 shards (where the emitted code is unchanged), and the gfx1250 CI labels are Triton-only — so the branch's only coverage is the author's unlanded 400/400 out-of-tree run. Author must land the falsifiable check as a collected test — the scan-vs-host-reference unit test, or an extension of test_moe_sorting_mxfp4.py's _adaptive_moe_sort comparison — so the gfx1250 branch is covered by something the repo can run.

📝 [verified] csrc/include/dpp_scan.h:47 still carries the same unguarded GFX9-only row_bcast (0x142/0x143) this PR arch-gates out of moe_sort_quant.cuh: a minimal TU instantiating wave_inclusive_sum_dpp fails to assemble for gfx1250 with #8133's exact error, though no current TU instantiates it there (both module_top_k_per_row TUs build clean for gfx1250 — the wave64-only kernels that call it are preprocessor-gated off, and topk_sampled traps non-gfx950 passes), so a future gfx1250 caller of that shared helper hits the same build break this PR just fixed. Reviewer should ask whether dpp_scan.h should get the same GFX9 guard now rather than at the next #8133.

@zufayu

zufayu commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

ci failed

dpp_inclusive_scan_wave used DPP row_bcast:15/31, which exists only on
GFX9, so module_moe_mxfp4_aux failed to build for gfx1250 ("Invalid
dpp_ctrl value: broadcasts are not supported on GFX10+"). Keep the GFX9
path; elsewhere add the earlier 16-lane rows' totals with readlane, as
#7540 did for moe_sorting_opus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zufayu
zufayu force-pushed the fsx/fix-moe-sort-quant-gfx1250-dpp branch from a7ddb49 to b874e0b Compare November 23, 2026 04:55
Copilot AI balanced review requested due to automatic review settings November 23, 2026 04:55

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 merged commit 162173e into main Nov 24, 2026
61 checks passed
@zufayu
zufayu deleted the fsx/fix-moe-sort-quant-gfx1250-dpp branch November 24, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue]: module_moe_mxfp4_aux fails to build for gfx1250 (row_bcast DPP in moe_sort_quant.cuh)

5 participants