Repository navigation
[FlyDSL] [gfx1250] grouped MoE: read the live GPU, not GPU_ARCHS - #8724
Conversation
grouped_moe_gfx1250 called get_gfx() in five places, all of them at call time: enabling grouped GEMM, keying the tuned-config lookup twice, and the two gfx1250 dispatch branches, including the a4w4-as-a8w4 fallback added in #8670 for the MI450 A0 errata. get_gfx() follows GPU_ARCHS and returns its last entry on a multi-target build, so it does not name the running GPU. Measured on an MI308X with GPU_ARCHS='gfx950;gfx1250-strict': live GPU gfx942 get_gfx() gfx1250-strict -> grouped GEMM on, strict fallback on get_gfx_runtime() gfx942 -> both off That fires the strict a4w4-as-a8w4 fallback on a GPU that has wmma-f4-insts, and the mirror case (an MI450 A0 whose build lists another arch last) skips the fallback the A0 errata needs, which is the NaN output #8670 fixes. Alias the import to get_gfx_runtime, as aiter/ops/gemm_op_a8w8.py and aiter/ops/gemm_op_a4w4.py already do, so all five call sites follow the live GPU. aiter/ops/rmsnorm.py already spells the same gfx1250 test with get_gfx_runtime(). No call site runs at import time or without a GPU, and get_gfx_runtime() keeps its AITER_AOT_REPLAY path for AOT processes. Tests: TestGroupedMoeArchSource in op_tests/test_gfx1250_strict_alias.py. Reverting the import alias fails test_dispatch_reads_the_runtime_arch. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision 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
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
Summary This PR adds
aiter/moev2, a rebuild offused_moedispatch and execution from small parts: - a problem description (MoeProblem); - segments, one per kernel family (sort, quant, CK, ASM, whole graph); - a plan that chains them. It lives next to the legacy code and takes over one group of calls (a path) at a time. Nothing changes by default. Paths run only when explicitly enabled withAITER_MOEV2. No path is graduated, so with the variable unset oroff, every call runs exactly the legacy code. This PR has two commits: 1. Phase 0/1: scaffolding, a harness that locks in legacy behavior, and helpers moved verbatim out offused_moe.py. No behavior change. 2. Phase 2: the problem/plan/segment framework, plus the first path,a8w8_pt(per-tensor fp8, 2-stage). It runs only withAITER_MOEV2=a8w8_pt(oron).aiter/moev2/README.mdlists every new file with its purpose. It also says whether the file is permanent or removed once the migration finishes and the legacy code is retired. ## How to enablebash AITER_MOEV2=a8w8_pt python ... # per-tensor fp8 calls go through moev2 AITER_MOEV2=on python ... # every registered path (only a8w8_pt today) AITER_MOE_EXPLAIN=1 # log why moev2 picked or declined each call## Commit 1: phase 0/1, scaffolding and harness (no behavior change) -aiter/moev2scaffolding: -AITER_MOEV2switch (envs.py); - path registry (paths.py, empty in this commit); - v2 entry point with the legacyfused_moesignature (api.py); - test hooks (hooks.py); - cache helper (dispatch/tuned.py). - Helpers moved fromfused_moe.py:resolve_activation_dtype,quant_remap,get_inter_dim,fused_topk, and the torch reference MoE. Each definition is AST-identical to the one it replaces, and each is imported back intofused_moe.py, so every existingfrom aiter.fused_moe import ...still works (36 names checked). - Import rule:aiter/moev2never imports the legacy MoE modules. The legacy modules may import from it, andtests/test_moev2_imports.pyenforces this. -fused_moe()hook: it does nothing while no path is enabled. -tests/moe_dispatch, to lock in legacy behavior: - a public-name inventory; - CPU arch simulation (gfx942, gfx942_cu80, gfx950, gfx1201); - a golden dispatch snapshot: what legacyget_2stage_cfgspicks for every tuned row plus a grid of untuned keys, read from frozen tuned tables; - a GPU suite list per planned path; - a perf baseline (perf_gfx950.json). ## Commit 2: phase 2, framework and thea8w8_ptpath (not graduated) - Framework: -MoeProblemround-trips the legacyget_2stage_cfgskey, so v2 and legacy can be compared key by key. - Segments declare what they can run. A problem with anything no segment declares is rejected. -dispatch/holds the kernel-name parser, the tuned lookup (with legacy's fallbacks), the resolver (legacy order, legacy log lines, legacy raises), and a default ranking table with static checks. -execute/mirrors_fused_moe_implandfused_moe_2stagesstatement for statement. - Patha8w8_ptcovers: - per-tensor fp8 weights on gfx942 and gfx950, Silu or Gelu, separated gate/up; - the CK default heuristic; - tuned CK and ASM+CK rows; - FlyDSL gfx942 whole-graph rows. - It declines (legacy runs the call): - herd routing,deterministic=True, or a registered presort; -swiglu_limit,betaorlinear_beta; - bias, padding or scatter; - caller-chosen activation dtypes, orAITER_ONLINE_TUNE; - tuned rows for kernel families it doesn't own (1-stage, post-reduction); - a call whose post-sort second lookup would raise, or that v2 can't reproduce. - More helpers moved verbatim: output-buffer validation,MOEMetadata/AsmMoeMode,get_padded_M,ck_moe_stage1,asm_stage1, the default kernel parameters, and the tuned-table reader. Each is AST-identical and imported back. - Upstream changes mirrored. These upstream changes touch code that v2 copies rather than calls, so git showed no conflict; each is mirrored in v2 and has tests: - #6736: gfx950 fp8 CK needs shuffled weights. v2 raises the sameRuntimeError, at the same two points, after the same log lines. - #7500: row-strided activations. v2 makes the same twohidden_statescopies. - #6926: zeroa2before dynamic per-tensor quant.op_tests/test_moe_per_tensor_a2_init.pyis added to the path's GPU suites. - #5988: post-reduction (flat=3) tuned rows are declined. - Harness additions: - CPU differential (v2 plan and log lines equal legacy's for every key the path claims); - key round-trip checks; - ranking checks; - GPU differential (same kernels, inputs and outputs as legacy). - Feature-variant keys in the snapshot. For per-tensor keys, the same call is added with one extraget_2stage_cfgsfeature (num_local_tokens, activation scales, fp8 input, unshuffled weights, bias, padding,doweight_stage1, Gelu, ...). A changed decision then names the exact feature responsible. ## Behavior claim - Legacy dispatch is unchanged. Every existing snapshot record is identical on all 4 archs. The new feature-variant records are byte-identical to ones generated with the upstream base'saiterpackage. - Whena8w8_ptruns a call, it launches the same kernels with the same parameters and inputs as legacy. It prints the same log lines, raises the same exceptions, and gives the same outputs, within legacy's own run-to-run noise. ## Testing | Check | Result | |---|---| | CPU unit tests (tests/test_moev2_*.py,test_moe_dispatch_snapshot.py) | 89 passed | | CPU differential, 4 archs | 22,087 claimed keys, 0 problems | | Key checks / ranking checks | 107,572 keys / 29,424 keys, 0 problems | | GPU differential, gfx950 (default, synthetic tuned table,AITER_USE_NT=1,AITER_BYPASS_TUNE_CONFIG=1) | 15 / 63 / 15 / 15 cases, 0 problems | | GPU suites,AITER_MOEV2=offvsa8w8_pt(test_moe_2stage -q 1,test_moe_per_tensor_a2_init,test_moe_sorting,test_moe_ep,test_moe_local_expert_ids,test_moe_dp_share_expert) | same exit codes and same per-check outcomes in both modes | | Legacy outputs, base vs this branch (test_moe_2stagesmall cases, all 10 quant types, 8,410 calls) | the 170 deterministic calls are bit-identical; the rest are within legacy's run-to-run noise | | Perf,dsv3_tp8_pt,a8w8_ptvs legacy | within 2.2% at every token count, mixed signs | | black, ruff | clean | Mutation checks confirm the new tests catch real breakage: - Without the a2 zero-fill, all 4 a2_init cases fail under v2. - Without the gfx950 raise, the differential reports 1,088 problems, all in the new feature-variant keys. - Without the second-lookup decline, its unit tests fail. ## Known limits -swiglu_limit=0.0, which vLLM sends for "no limit", is declined like any other limit value, so those calls stay on legacy. - The ASM and whole-graph branches are verified only by the CPU differential: their tuned rows are gfx942-only, and only gfx950 was available for GPU runs. - Pre-existing failures, unchanged by this PR:test_moe_2stage -q 1has 28 failing swiglu-limit checks,test_moe_ephas 2 andtest_moe_dp_share_experthas 13. They fail the same way withAITER_MOEV2off and on, and on the upstream base. - Legacy nondeterminism found while building the GPU gate: CK stage 2 accumulates with atomics, and some ASM stage 1 kernels aren't repeatable. The gate compares within a tolerance measured legacy-vs-legacy, and doesn't excuse a case that hits the non-repeatable kernels. ## Review guide - Start withaiter/moev2/README.md. - Moved helpers are AST-identical to the originals. The diff infused_moe.pyis mostly deletions plus import-backs. - The behavior-relevant v2 code is indispatch/resolver.py,execute/executor.pyandmigration/a8w8_pt.py. - The golden.jsonl.gzfiles are generated. Regenerate withpython tests/moe_dispatch/snapshot.py --update, and check with--check.PR Self-Review
Reviewed revision
f76850c
Behavior and intent
Default behavior does not change: with
AITER_MOEV2unset oroff, every call still uses the legacyfused_moepath. The PR introduces an explicitly enableda8w8_ptpath for per-tensor FP8 two-stage MoE and decomposes the monolithic dispatch/execution flow into a problem, feasible kernel segments, and a plan. The existing implementation is insufficient for a controlled multi-phase migration because dispatch choices, execution details, and fallback boundaries are intertwined; the new framework can claim one narrowly defined workload family at a time and decline every call it cannot reproduce back to legacy.Validation and unverified scope
Exact-head validation on
f76850c9e9a8254ee063ad2991e8e9539dda17e7: Python compileall, Black, and Ruff pass; focused regressions cover multi-target runtime architecture claims, declined-call no-copy dispatch, path-specific GPU architecture filtering, architecture-binding restoration, architecture-specific GPU case selection, fail-closed performance token coverage, and resolved whole-graph implementation/config equality. Repository Aiter Test and MI300X CI are running on this head. The full CPU parity and gfx950 GPU results recorded on pre-rebasec32cff446f351bc8ce3e60d0c0a14c70931b8186remain useful evidence but are advisory until repeated on the exact head. gfx942-cu80 ASM and FlyDSL whole-graph hardware validation remains unverified and is a prerequisite for graduating the opt-in path, not for merging this disabled-by-default implementation.PR-specific question
The new configuration is consumed only by workload keys that the
a8w8_ptpath claims: per-tensor FP8 weights on gfx942 or gfx950, two-stage execution, Silu or Gelu, and separated gate/up, using the CK default heuristic, matching tuned CK or ASM+CK rows, or matching gfx942 FlyDSL whole-graph rows. Keys with herd routing, deterministic mode, a registered presort,swiglu_limit, beta/linear-beta, bias, padding, scatter, caller-selected activation dtypes, online tuning, unsupported tuned kernel families, or an unreproducible second lookup are declined to legacy. Unrelated shapes keep their prior selection because the feature is opt-in, the legacy snapshot is byte-identical on all four architecture grids, feature-variant keys exercise each exclusion independently, and the differential requires every claimed key to match the legacy plan while every declined key continues through the unchanged legacy path.Changed op tests
None. This PR does not change any file under
op_tests/; it only adds the existingop_tests/test_moe_per_tensor_a2_init.pyto the moev2 GPU suite manifest so the already-canonical zero-fill coverage runs in both legacy and opt-in modes.