[Feature][FlyDSL] Add fused heterogeneous MXFP4/FP8 shared-expert MoE (FHMoE)#4269
Draft
Fangzhou-Ai wants to merge 1 commit into
Draft
[Feature][FlyDSL] Add fused heterogeneous MXFP4/FP8 shared-expert MoE (FHMoE)#4269Fangzhou-Ai wants to merge 1 commit into
Fangzhou-Ai wants to merge 1 commit into
Conversation
Fangzhou-Ai
force-pushed
the
afz/dsv4-fmoe-bm16-post4
branch
from
July 16, 2026 21:21
c2142ac to
bdd87fc
Compare
Fangzhou-Ai
marked this pull request as ready for review
July 16, 2026 21:24
Fangzhou-Ai
force-pushed
the
afz/dsv4-fmoe-bm16-post4
branch
from
July 16, 2026 21:26
bdd87fc to
fd07bda
Compare
Fangzhou-Ai
marked this pull request as draft
July 16, 2026 21:28
Fangzhou-Ai
marked this pull request as ready for review
July 16, 2026 21:28
Fangzhou-Ai
marked this pull request as draft
July 16, 2026 21:32
Fangzhou-Ai
force-pushed
the
afz/dsv4-fmoe-bm16-post4
branch
2 times, most recently
from
July 16, 2026 22:15
01a1de9 to
21bb7b1
Compare
Fangzhou-Ai
marked this pull request as ready for review
July 16, 2026 22:17
Fangzhou-Ai
force-pushed
the
afz/dsv4-fmoe-bm16-post4
branch
from
July 19, 2026 16:55
21bb7b1 to
e9572c9
Compare
Fangzhou-Ai
force-pushed
the
afz/custom-ar-ipc-publication
branch
from
July 20, 2026 18:42
036f04f to
dc528ea
Compare
Fangzhou-Ai
force-pushed
the
afz/dsv4-fmoe-bm16-post4
branch
2 times, most recently
from
July 20, 2026 20:41
6943b0c to
f0f528b
Compare
Author
Fangzhou-Ai
marked this pull request as draft
July 21, 2026 05:19
This was referenced Jul 21, 2026
Fangzhou-Ai
force-pushed
the
afz/dsv4-fmoe-bm16-post4
branch
from
July 21, 2026 06:18
6eda046 to
8df1e76
Compare
Fangzhou-Ai
force-pushed
the
afz/dsv4-fmoe-bm16-post4
branch
from
July 21, 2026 06:24
8df1e76 to
bd4afac
Compare
Add a dedicated FHMoE dispatch, custom op, FlyDSL runtime, GPU kernel, AOT path, and correctness suite for MXFP4 routed experts with a native FP8 shared expert. Keep ordinary MoE schemas and compiler APIs unchanged behind narrow compatibility bridges. Start every FHMoE runtime and AOT job at XCD0 so this enablement has one validated scheduling contract. FHMoE-specific XCD performance tuning can follow as a separate stacked change. Validation covers exact DSV4 and small-shape sweeps, precision oracles, graph replay, compatibility, invalid contracts, XCD0 runtime/AOT normalization, Ruff, py_compile, and diff checks. AI assistance was used to implement, test, review, and organize this change. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Fangzhou Ai <fangzhouai@gmail.com>
Fangzhou-Ai
force-pushed
the
afz/dsv4-fmoe-bm16-post4
branch
from
July 21, 2026 06:33
bd4afac to
cc36e67
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
fused_moe_custom-op schema or ordinary kernel compiler APIs.fhmoe.py/test_fhmoe.pyfiles, with only narrow compatibility bridges in existing MoE modules.Stack and review scope
This PR directly targets #4314's
afz/dsv4-bm16-tuningbranch:GitHub therefore displays exactly one FHMoE commit (
cc36e67f9) and eight paths:aiter/fhmoe.py,aiter/ops/flydsl/fhmoe.py,aiter/ops/flydsl/kernels/fhmoe.py,aiter/aot/flydsl/fhmoe.py, andop_tests/test_fhmoe.pyaiter/fused_moe.py,aiter/ops/flydsl/moe_kernels.py, andaiter/aot/flydsl/moe.pyIt contains no model-config CSV change, ordinary mixed-MoE GPU-kernel change, XCD helper/test change, or ordinary MoE boundary test.
XCD policy and follow-up tuning
The initial FHMoE enablement intentionally uses XCD0 for every batch size:
This gives the feature one deterministic, validated scheduling contract. A follow-up FHMoE tuning PR will target this PR's upstream
afz/dsv4-fmoe-bm16-post4branch, benchmark the corrected XCD mapping from #4315 across relevant batch sizes, and select XCD settings only where they provide validated correctness and performance.Why heterogeneous fusion
The checkpoint stores the 384 routed experts as MXFP4 but the shared expert as FP8. Converting the shared expert to MXFP4 recovers fusion performance but adds substantial weight error; scheduling a separate FP8 shared kernel preserves precision but loses much of the fusion gain. FHMoE keeps one fused schedule while selecting FP8 weight and scale resources only for the final logical shared expert.
Existing callers keep their prior behavior when the shared-expert arguments are omitted. Compatibility coverage verifies that omitted and explicit-default calls are bitwise identical.
Validation
All GPU validation below ran on gfx950 from final head
cc36e67f9.Exact DeepSeek-V4 TP8 dimensions across M=4,8,16,32,64:
Result: 13 passed. The suite checks FP32 precision oracles, separately scheduled routed/shared controls, isolated routed and shared contributions, forced-reduce determinism, atomic-output bounds, graph replay, legacy compatibility, invalid contracts, the dedicated custom-op schema, and XCD0 runtime/AOT behavior.
The full small-profile sweep also passed:
Result: 13 passed.
Focused API/AOT/compiler-bridge coverage passed (3 passed), including a regression that invokes both shared generic dispatchers through the private XCD0 adapter while keeping the public FHMoE signatures XCD-free. Fresh-process imports succeeded in both
fused_moe -> fhmoeandfhmoe -> fused_moeorder, registeringtorch.ops.aiter.fhmoe_without the old custom-op name.Static checks passed on all eight FHMoE paths:
Model evaluation and serving measurements
Prior end-to-end validation of the same heterogeneous fused behavior completed all 1,319 GSM8K samples with 20-shot prompts, concurrency 64,
max_tokens=2048, and temperature 0:All requests completed without a server error or GPU-fault match. This model evaluation predates the isolation and naming refactor; the final head was revalidated with the exact-shape precision suite above.
Saved DeepSeek-V4-Pro TP8 8K-input/1K-output deployment measurements showed:
All measured requests completed. These are deployment-oriented cross-version measurements, not an isolated same-base PR A/B; the final structural refactor was not reswept. The isolated BM16 tuning results are documented in #4314.
Duplicate-work check
Open-PR searches found no equivalent heterogeneous MXFP4-routed/FP8-shared fused implementation. The original #4269 is updated in place rather than opening a duplicate feature PR.
AI assistance
OpenAI Codex was used to audit related work, implement and organize the patch, run validation and benchmarks, organize the stacked history, and draft this description. The human submitter reviewed every changed line and is responsible for understanding and defending the change end-to-end.