Skip to content

[FlyDSL] [gfx1250] MegaMoE: bf16-wire combine reduce reads its inputs directly - #7664

Merged
yifehuan merged 1 commit into
ROCm:mainfrom
yhl-amd:hyi/mega-moe-combine-direct-reduce
Nov 12, 2026
Merged

yifehuan merged 1 commit into
ROCm:mainfrom
yhl-amd:hyi/mega-moe-combine-direct-reduce

Conversation

@yhl-amd

@yhl-amd yhl-amd commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The bf16-wire combine reduce of the gfx1250 MegaMoE fused combine reads its inputs straight from global memory instead of staging them through LDS.

Motivation

The bf16 wire has no scale plane, so the LDS round trip in its reduce buys nothing: every element is read once and summed once. Dropping it removes the LDS staging and its barrier, and lets each lane keep all of a token's slot loads in flight at once.

Changes

  • combine.py: new _make_combine_direct_reduce and combine_direct_reduce_blocks. Each lane owns one b128 (8 bf16) of a token's hidden row; it issues all top-k (+ shared) loads first, then sums in registers in the same order as before. Slot rows are loaded non-temporal (read once); the output store is a normal store since the next op reads it. The grid is sized from the token count.
  • stages/combine_fused.py: the bf16 wire (quant_bits == 0) uses the direct reduce, with and without the shared add from [FlyDSL] [gfx1250] MegaMoE: fold the shared expert output into the fused combine reduce #7661. Quantized wires keep the existing LDS-staged reduce.
  • Hidden size and slot stride must be multiples of the lane tile; otherwise construction raises.

Validation

  • Bit-identical to the LDS-staged reduce on gfx1250: whole-layer comparisons plus an independent set of cases covering top-k 6 and top-k 3, several token counts, with and without the shared add.
  • DeepSeek-V4.1-Flash EP4 (MegaMoE, bf16 combine wire) on gfx1250 served end to end with this change in the stack; all requests completed.
  • black and ruff clean on the changed files; the modules and op_tests/multigpu_tests/test_mega_moe_gfx1250.py import cleanly.

🤖 Generated with Claude Code

@yhl-amd
yhl-amd requested a review from a team November 9, 2026 15:08
@github-actions github-actions Bot added the FlyDSL label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

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 7664 --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.

@aiter-bot

aiter-bot commented Nov 9, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 3851d2140a28 · 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. What is the most important boundary or failure mode introduced by this change, and what evidence covers 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.

@yhl-amd

yhl-amd commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

The Standard Tests (1 GPU) shard 2 failure is op_tests/test_flydsl_hgemm.py ("graph replay mismatch" on a split-K case, gfx950). This PR only touches gfx1250 MegaMoE files. The same shard passed on main at the same base (main run), and #7663 (gfx1250 config files only) hit the same test at a different case in the same window (#7663 run), so it looks flaky. Re-running the failed job.

The bf16 wire has no scale plane to stage, so its reduce no longer goes
through LDS: each lane loads one b128 (8 bf16) per slot for its token, all
topk (+ shared) loads first, and sums them in registers. Slot rows are read
non-temporal; the output store is not, since the next op reads it. The grid
is sized from the token count. The quantized wires keep the existing
LDS-staged reduce. Outputs are bit-identical.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yhl-amd
yhl-amd force-pushed the hyi/mega-moe-combine-direct-reduce branch from 3ffd8d6 to 3851d21 Compare November 11, 2026 14:43
@yhl-amd

yhl-amd commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main now that #7661 is in: the #7661 commit is dropped and only the direct-reduce commit remains (patch unchanged). The earlier conflict came from the squash of #7661 versus its original commit; nothing else on main touches these files. Removed the stacking note from the description.

@yhl-amd

yhl-amd commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

CI note: the failing job (MI35X Standard Tests shard 2, https://github.com/ROCm/aiter/actions/runs/43041317469/job/130664727526) has a single failure, op_tests/test_flydsl_hgemm.py: a gfx950 split-K case reports "graph replay mismatch" (one element of a 19x120 output differs by one bf16 ulp after changed-input graph replay). This PR only touches the gfx1250 MegaMoE combine, which that test does not use. The same assertion fails on unrelated PRs in the same window (https://github.com/ROCm/aiter/actions/runs/43080903893/job/130836755348, https://github.com/ROCm/aiter/actions/runs/43076930628/job/130774391091), and on this PR the same test passed on the previous re-run. Re-ran the failed jobs.

@yifehuan yifehuan 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

@yifehuan
yifehuan merged commit 6a80ddd into ROCm:main Nov 12, 2026
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
…7664)

The bf16 wire has no scale plane to stage, so its reduce no longer goes
through LDS: each lane loads one b128 (8 bf16) per slot for its token, all
topk (+ shared) loads first, and sums them in registers. Slot rows are read
non-temporal; the output store is not, since the next op reads it. The grid
is sized from the token count. The quantized wires keep the existing
LDS-staged reduce. Outputs are bit-identical.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

4 participants