Skip to content

[FlyDSL] Modularize MI308 MoE kernels (1/3) - #5795

Merged
coderfeli merged 4 commits into
ROCm:mainfrom
luocheng25:luocheng/moe_gemm_308_opt1
Oct 10, 2026
Merged

coderfeli merged 4 commits into
ROCm:mainfrom
luocheng25:luocheng/moe_gemm_308_opt1

Conversation

@luocheng25

@luocheng25 luocheng25 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR is a follow-up to #3987 — Add FlyDSL FP8 MoE kernels (decode weight-decompression + prefill) for MI308 — Qwen3.5-35B/397B, Hunyuan3.

It modularizes the already-merged implementation to improve maintainability and prepare for further optimization. This is part 1/3 of the original split; Down and B2–8 optimizations are deferred to separate PRs, pending approval of this refactor.

Changes

  • Split the existing two-stage MoE implementation into Gate/Up, Down, quantization, reduction, and shared-helper modules under an architecture-neutral package name.
  • Consolidate pointer conversion, dtype mappings, and numerical/layout helpers; remove the legacy monolithic kernel and utility modules. Internal callers now use the new package directly; legacy internal import paths are not retained.

Validation

Locally validated on MI308X (gfx942) with ROCm 7.2.4 and FlyDSL 0.3.4.1. All 202 shapes passed correctness checks on both revisions after independent tuning. Overall GPU latency remained essentially unchanged (+0.20%, RTA mode).

@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; main branch always runs both MI35X and MI300X
multigpu 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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 5795 --add-label <label>

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 opt this PR out.

@luocheng25
luocheng25 force-pushed the luocheng/moe_gemm_308_opt1 branch from e6955e4 to 0d1a83a Compare September 28, 2026 01:12
@luocheng25 luocheng25 changed the title [CK] [FlyDSL] [CI] Refactor MI308 MoE kernels and enable compilation caching (1/3) [FlyDSL] Modularize MI308 MoE kernels (1/3) Sep 28, 2026
@luocheng25
luocheng25 requested a lite review from Copilot September 28, 2026 01:15

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 review overview

🟡 Changes recommended

Unresolved cache, batch-1 compilation, environment override, and runtime configuration issues remain.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Modularizes the MI308 FlyDSL MoE kernels into reusable kernel, quantization, reduction, and helper modules.

Changes:

  • Splits the monolithic implementation into an architecture-neutral package.
  • Updates fused-MoE dispatch and shared utilities.
  • Removes legacy gfx942 kernel and utility modules.
File Summary
aiter/​ops/​flydsl/​kernels/​moe_gemm_2stage/​quant.py FP8 quantization kernels
aiter/​ops/​flydsl/​kernels/​moe_gemm_2stage/​moe_reduce.py Routing reduction kernels
aiter/​ops/​flydsl/​kernels/​moe_gemm_2stage/​gemm2.py Down kernels and dispatch
aiter/​ops/​flydsl/​kernels/​moe_gemm_2stage/​gemm1.py Gate/Up kernels
aiter/​ops/​flydsl/​kernels/​moe_gemm_2stage/​common.py Shared layouts, numerics, and helpers
aiter/​ops/​flydsl/​kernels/​moe_gemm_2stage/​__init__.py Package exports and dispatch API
aiter/​ops/​flydsl/​kernels/​moe_gemm_2stage_gfx942.py Removed legacy monolithic implementation
aiter/​ops/​flydsl/​kernels/​moe_gemm_2stage_gfx942_utils.py Removed legacy utilities
aiter/​ops/​flydsl/​fused_moe_gfx942.py Updated imports and compilation dispatch

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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 review overview

🔵 Needs a closer look

The refactor spans multiple performance-critical kernels and dispatch paths requiring final human review.

Review effort: Lite
Findings: None

Resolved since last review (3)

@luocheng25
luocheng25 marked this pull request as ready for review September 28, 2026 02:38
@luocheng25
luocheng25 requested review from a team and Copilot September 28, 2026 02:38

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 review overview

🔵 Needs a closer look

The broad kernel refactor and legacy-module removal require final human validation.

Review effort: Lite
Findings: None

Copilot AI lite review requested due to automatic review settings October 8, 2026 11:26

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.

🔵 Needs a closer look

Performance-sensitive kernel and dispatch refactoring warrants final human review.

0 open findings

🧠 Review effort: Lite


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@luocheng25
luocheng25 requested a review from fsx950223 October 9, 2026 01:07
fsx950223
fsx950223 previously approved these changes Oct 9, 2026
@luocheng25

Copy link
Copy Markdown
Contributor Author

Regression check: 571b02235 against its main merge-base a2144068f on MI308X/gfx942 (80 CUs), ROCm 7.2.4, FlyDSL 0.3.4.1, AITER_FLYDSL_MOE_BF16_RTA_SIMPLIFIED=1. Both sides run the same tuned CSV rows (106 shapes: 83 FlyDSL, 23 CK). Equal-shape geometric-mean GPU latency change; negative means faster:

Model / precision Shapes Kernel sum CUDA graph
Hunyuan3 / FP8 per-tensor 18 -0.30% +0.38%
MiniMax-M3 / FP8 PTPC 36 -0.63% -0.51%
Qwen3.5-35B / FP8 PTPC 34 -0.10% -0.40%
Qwen3.5-397B / FP8 PTPC 18 -0.01% +0.03%
All 106 -0.30% -0.23%
  • Kernel sum uses the tuner's native benchmark (10 warmups, 51 iterations); CUDA graph replays eight calls back to back. Each is the median of three alternating-order rounds.
  • All rows pass the tuner's correctness check on both revisions, and no shape is more than 3% slower in all three rounds. The 23 CK rows, whose code is unchanged, move by +0.07% / -0.70%, which indicates the noise level.

Copilot AI lite review requested due to automatic review settings October 10, 2026 07:43

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.

🔵 Needs a closer look

The refactor spans GPU kernels, dispatch integration, and removed legacy modules; final human validation is warranted.

0 open findings

🧠 Review effort: Lite

@coderfeli coderfeli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

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