Skip to content

[FlyDSL] [CI] mega_moe_tp: decode-shape (1-128 row) router top-4 + MXFP4/MXFP8 input quant chain - #8553

Closed
ganyi1996ppo wants to merge 27 commits into
ROCm:mainfrom
ganyi1996ppo:ganyi/mega-moe-tp-router-chain
Closed

ganyi1996ppo wants to merge 27 commits into
ROCm:mainfrom
ganyi1996ppo:ganyi/mega-moe-tp-router-chain

Conversation

@ganyi1996ppo

@ganyi1996ppo ganyi1996ppo commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Second PR of the MiniMax-M3.1 decode MoE series (E128 top-4, H6144, 1-128 rows, gfx950): the router front end that follows the router GEMM of #8548. It replaces amd-kernels' chain._route_quant_small, which the decode path calls before the expert GEMMs:

  • decode_router_topk_sorted.py: biased sigmoid top-4 of 128 experts over the split-K partials (one token per wave, DPP butterfly).
  • decode_router_topk_quant.py: the top-4 plus MXFP4 + MXFP8 input quantization from one bf16 read, one launch (<= 256 rows).
  • decode_router_chain.py: route_quant_small(x, router_weight, router_weight_lines, correction_bias, routed_scaling_factor) -> ((q4, s4), (q8, s8), topk_weights, topk_ids); 58-128 rows fold the quant workgroups into the router GEMM launch, 1-57 rows run router GEMM then top-4 + quant. That is 1-2 launches for gate GEMM + top-4 + both input quantizations.
  • op_tests/test_decode_router_chain.py: torch-reference test (ids vs fp64 top-4, weights, per-row FP8 / FP4 dequant error), rows 1..128.

Ported from amd-kernels (Apache-2.0, credited in the file headers), kernel bodies unchanged. No amd_kernels import. Launch / compile handles are per device, tensors and output spans are validated before launch.

Performance (MI355X gfx950, 1 GPU, CUDA-graph replay)

Parity with amd-kernels is the goal (us per route_quant_small call, this PR vs amd-kernels): 8 rows 4.72 vs 4.70, 16: 4.72 vs 4.71, 32: 5.01 vs 5.01, 57: 5.50 vs 5.48, 58: 5.62 vs 5.53, 64: 5.62 vs 5.63, 96: 6.00 vs 5.97, 128: 6.10 vs 6.12 (all within +-0.1 us; eager host time 0.1-1.7 us lower). No end-to-end gain by itself; the per-layer gain of the whole chain is in #8676 (8 rows: 96.8 -> 38.0 us, 128 rows: 144.0 -> 81.8 us per layer).

Tests / how to run

  • pytest op_tests/test_decode_router_chain.py op_tests/test_decode_router_gemm.py (gfx950): torch-reference checks; both files run through pytest in aiter_test.sh.
  • Bit identity vs amd-kernels chain._route_quant_small (harness not in the PR): q4, s4, q8, s8, weights and ids equal for rows 8..128 x 3 input kinds, 484 checks, 0 mismatches.
  • Known unrelated CI failure: Triton Tests (MI35X) / Shard 4 (test_gemm_a16wfp4); this PR does not touch Triton.

Dependencies / merge order

#8548 -> #8553 -> #8555 -> #8676 (#8556 independent). This branch contains #8548's commits (merged, not rebased); its own delta: ganyi1996ppo/aiter@ganyi/mega-moe-tp-decode-primitives...ganyi/mega-moe-tp-router-chain

PR Self-Review

Reviewed revision

3199323 (ac90ed4 + aliased topk weight/id output check, x-rank check before indexing)

Behavior and intent

Adds the router top-4 + MXFP4/MXFP8 input-quant chain (replaces amd-kernels chain._route_quant_small) on top of #8548.

Validation and unverified scope

484 bit-identity checks vs amd-kernels (0 mismatches) and graph-replay timing within +-0.1 us, both at ac90ed4. Not verified: no gfx942 run of the skip path; the two Copilot fixes in 3199323 (output-aliasing guard in splitk_biased_topk_mxfp4_mxfp8_quant, rank check before x.shape[0] in route_quant_small) are pure host-side validation and were checked by code reading + the new regression cases, not re-run on a GPU (none was free this pass).

PR-specific question

Only adds test files to the existing pytest lists in aiter_test.sh / split_tests.sh (inherited from #8548); no workflow, permission or secret change.

Changed op tests

  • op_tests/flydsl_tests/test_decode_id_routing.py: torch oracle for the in-kernel canonical expert-block routing (8-128 rows, partial blocks, skewed ids, ids outside [0, E)); nothing else in the tree exercises decode_id_routing.
  • op_tests/test_decode_router_gemm.py: split-K partials of the router GEMM sum to x @ W.T in fp64 for 1-128 rows; no other test covers these kernels.
  • op_tests/test_decode_router_chain.py: top-4 ids / weights vs an fp64 reference and per-row FP8 / FP4 dequant error of route_quant_small, rows 1-128.

🤖 Generated with Claude Code

ganyi1996ppo and others added 5 commits November 24, 2026 01:44
…MM tile primitives

Adds two new, self-contained helper modules to aiter's existing
mega_moe_tp family:

- decode_id_routing.py: in-kernel canonical expert-block routing for the
  small-M decode shape (<=128 rows, E128 top4) -- one workgroup resolves
  its 16-row expert block straight from topk_ids via an LDS-atomic
  histogram and a DPP wave scan, no sort launch and no global atomics.
- decode_tile_primitives.py: per-tile building blocks for the same shape's
  GEMM1/GEMM2 compute at H6144/I768 -- scaled-MFMA wrappers (MXFP4 A4W4 and
  MXFP8 A8W8), the SwiGLU activation, and MXFP4/MXFP8 row quantization.

Both are ports of the technique in amd-kernels'
moe/mxfp4_h6144_i768_e128_top4/{routing_ids.py,gemm1_a4w4_id_rows.py,
shared_gemm1_a8w8.py,shared_quant.py} (Apache-2.0, "Copyright contributors
to the amd-kernels project") -- same algorithm, reimplemented against
aiter's own aiter.ops.flydsl.kernels.buffer_ops instead of amd-kernels'
private copy of the same buffer-op wrappers. Neither file imports
amd_kernels; each file's docstring credits the specific amd-kernels source
module it is ported from.

mega_moe_tp already carries the epoch-flag / XCD-affinity / loader-wave
LDS-DMA primitives a fused decode GEMM1->GEMM2 kernel needs, but only at
128/256-row prefill tile shapes; this adds the small-M (8-128 row)
in-kernel routing and tile primitives it is missing for a decode-shape
fusion, generalized over the pair/row count (no model-specific constant
beyond the E128/top4/16-row-block shape a call site fixes).

This is a primitives-only PR: the tile loop, prefetch ring and LDS layout
that assemble these into a full fused kernel currently live in a
model-side integration (MiniMax-M3.1 decode MoE) that is not yet upstream
in ATOM, so no aiter op_test exercises the full assembled kernel here.
Correctness was verified through that integration instead: 72/72
adversarial-input bit-identical results against the original
amd_kernels-based kernel, and 12/12 matches against an independent
production reference, on real MI355X hardware (node 035, gpurun lease).
Perf (200 iters, same hardware): the assembled kernel using these
primitives measured -21.3/-12.1/-13.4 us vs production at n=16/24/32 rows,
within +0.2..+1.7 us (noise) of the pre-port amd_kernels version -- no
regression from the port itself.

Follow-up: land the model-side integration (currently
atom/models/minimax_m3/moe_one_launch_aiter.py in a private tree) as its
own ATOM-side PR once the file it extends is upstream, and add a native
aiter op_test once there is a complete in-aiter kernel to test against.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…tials

bf16x3 split-K router GEMM (E128 x H6144, MFMA 16x16x32) for 1-32 rows: a no-LDS
direct kernel for 1-16 rows and a line-layout two-wave kernel for 17-32 rows, plus
the tier dispatch (router_gemm_partials) and the one-time gate permutation
(router_line_layout). Ported from amd-kernels' moe/mxfp4_h6144_i768_e128_top4
(router_gemm_direct / router_gemm_nblocks_lines / router_gemm dispatch, Apache-2.0),
bodies unchanged, imports moved to aiter's buffer_ops / tensor_shim.

Verified on gfx950: partials bit-identical to amd-kernels for rows 1..32 (3 input
kinds), graph-replayed GPU time equal to +-0.01 us.

Co-Authored-By: Claude <[email protected]>
…, optional input-quant workgroups)

Adds the 33-128 row router GEMM tier (router_gemm_nblocks: split-48 to 64 rows,
split-16 above, optional MXFP4 + MXFP8 input-quant workgroups appended or
prepended to the same launch for the top-k + quant chain that follows) and extends
the router_gemm_partials dispatch to 128 rows. Ported from amd-kernels'
moe/mxfp4_h6144_i768_e128_top4/router_gemm_nblocks.py (Apache-2.0), bodies
unchanged; the quant group reuses decode_tile_primitives' _fp8 / _e8m0_fp8.

Verified on gfx950: partials bit-identical to amd-kernels for rows 1..128 (3 input
kinds, with and without the line-layout gate), graph-replayed GPU time within
+-0.03 us at 1..128 rows.

Co-Authored-By: Claude <[email protected]>
…XFP8 input quant chain

Completes the decode-shape routing front end that replaces amd_kernels'
chain._route_quant_small: biased sigmoid top-4 over the router partials
(decode_router_topk_sorted), the top-4 with the MXFP4 + MXFP8 input quant in one
launch for <= 256 rows (decode_router_topk_quant), and route_quant_small
(decode_router_chain), which picks per row count between the router launch with
the quant workgroups folded in (58-128 rows) and router GEMM + top-4/quant launch
(1-57 rows). Ported from amd-kernels' moe/mxfp4_h6144_i768_e128_top4
(router_topk_sorted, router_topk_mxfp4_mxfp8_quant_sorted_tasks,
router_gemm_topk_mxfp4_mxfp8_quant, chain, Apache-2.0), kernel bodies unchanged.

Verified on gfx950 against amd-kernels' chain._route_quant_small: q4/s4/q8/s8/
topk weights/topk ids bit-identical for every row count 8..128 (3 input kinds,
484 checks, 0 mismatches); graph-replayed GPU time equal within +-0.1 us at
8..128 rows (4.7-6.1 us per call). Torch-reference pytest included (no
amd_kernels dependency).

Co-Authored-By: Claude <[email protected]>
…tials

bf16x3 split-K router GEMM (E128 x H6144, MFMA 16x16x32) for 1-32 rows: a no-LDS
direct kernel for 1-16 rows and a line-layout two-wave kernel for 17-32 rows, plus
the tier dispatch (router_gemm_partials) and the one-time gate permutation
(router_line_layout). Ported from amd-kernels' moe/mxfp4_h6144_i768_e128_top4
(router_gemm_direct / router_gemm_nblocks_lines / router_gemm dispatch, Apache-2.0),
bodies unchanged, imports moved to aiter's buffer_ops / tensor_shim.

Verified on gfx950: partials bit-identical to amd-kernels for rows 1..32 (3 input
kinds), graph-replayed GPU time equal to +-0.01 us.

Co-Authored-By: Claude <[email protected]>
@ganyi1996ppo
ganyi1996ppo requested review from a team and a balanced review from Copilot November 24, 2026 08:47
@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 8553 --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 24, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 3199323ea483 · 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 permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
  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 — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent is too short to show concrete reasoning (15 units; need 18)

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

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.

🟡 Changes recommended

Critical buffer-validation and cross-device execution defects can cause out-of-bounds accesses or incorrect results, while CI does not execute the affected numerical tests.

6 open issues
What changed in this PR

Ports the decode MoE routing front end into aiter’s FlyDSL mega_moe_tp family, removing this chain’s runtime dependency on amd-kernels for 1–128 tokens, 128 experts, and top-4 routing.

Changes:

  • Adds split-K router GEMM kernels and row-count-based dispatch.
  • Combines biased sigmoid top-4 selection with MXFP4/MXFP8 input quantization.
  • Includes decode routing/tile primitives from the stacked PRs and torch-reference tests.
File Description
op_tests/​test_decode_router_gemm.py Checks summed GEMM partials against reference logits.
op_tests/​test_decode_router_chain.py Checks routing IDs, weights, and quantization error.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_tile_primitives.py Adds decode tile arithmetic and quantization helpers.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_topk_sorted.py Selects biased sigmoid top-4 from split-K partials.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_topk_quant.py Combines top-4 selection and dual input quantization.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_gemm.py Dispatches GEMM tiers and prepares line-layout weights.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_gemm_nblocks.py Implements larger-row GEMM with optional quantization workgroups.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_gemm_lines.py Implements line-layout GEMM for 17–32 rows.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_gemm_direct.py Implements direct GEMM for 1–16 rows.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_common.py Shares weight splitting, wave reduction, and conversion helpers.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_chain.py Orchestrates GEMM, routing, and quantization by row count.
aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_id_routing.py Builds expert blocks directly from top-4 IDs.

Review effort: Balanced

Comment thread op_tests/test_decode_router_chain.py Resolved
Comment thread op_tests/test_decode_router_chain.py Resolved

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.

🟡 Changes recommended

Critical tensor-validation and device-isolation gaps can cause out-of-bounds memory access, incorrect results, and cross-device launch failures, while the new tests do not execute in CI.

7 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Make all parameter combinations run in standalone CI

op_tests/​test_decode_router_gemm.py:30

Aiter CI runs this file with python3 "$file" (.github/scripts/aiter_test.sh:97), but it has no script entry point or pytest runner override, so none of its 30 parameter combinations executes. Convert it to the executable op-test structure in .claude/skills/aiter-op-test/SKILL.md: a main() sweep gated with get_gfx_runtime(), run_perftest measurements, asserted FP32 checkAllclose comparisons, and a summary table.

Review effort: Balanced

ganyi1996ppo and others added 3 commits November 24, 2026 03:36
…use rocdl cvt wrappers; add routing test

Co-Authored-By: Claude <[email protected]>
…use rocdl cvt wrappers; add routing test

Co-Authored-By: Claude <[email protected]>
…use rocdl cvt wrappers; add routing test

Co-Authored-By: Claude <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:36
ganyi1996ppo and others added 2 commits November 24, 2026 07:41
…fails without the id-range guard)

Co-Authored-By: Claude <[email protected]>
…rch/strides, per-GPU launcher, CI runs the test

Review findings on ROCm#8551:
- router_gemm_partials launched on the current device with whatever pointers it
  was given: a CPU or foreign-GPU gate / hidden state became an invalid GPU
  address, gfx942 reached an MFMA form it lacks, and one cached compiled handle
  served every GPU. It now returns None unless every tensor is CUDA storage on
  one gfx950 device, launches under that device with its stream and keeps one
  launcher per GPU (kernels/topk/topk_launch._launcher_on).
- An expanded row (stride(0) == 0) gave the kernels an empty buffer descriptor
  and silently zero partials (max error 10.46 = |logits| on 8 rows, reproduced
  on gfx950). Rows must not overlap, and m * stride * 2 must fit the 32-bit
  descriptor extent; both return None.
- _get_kernel took a hard-coded (48, 64) beside split_config; it uses the tier.
- The test had no per-split oracle (permuted split slots passed), no stride or
  rejection case, and CI runs op_tests with `python3 file` (collects nothing):
  add per-chunk reference, padded-stride and rejection cases, a gfx950 skip, and
  list the file in aiter_test.sh's pytest dispatch.

Verified on gfx950: 14 passed.

Co-Authored-By: Claude <[email protected]>

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.

🟡 Changes recommended

Device-agnostic launcher caches and missing input validation risk cross-GPU handle reuse and incorrect or out-of-bounds reads, while the new test suites are not wired to execute in standard CI.

9 open issues
1 previously missed issue

In code that hasn't changed since last review

High severity Validate inputs before selecting either row-count tier

aiter/​ops/​flydsl/​kernels/​mega_moe_tp/​decode_router_chain.py:95

The 58–128-row branch bypasses the dtype and layout checks in router_gemm_partials. For example, FP32 activations or BF16 router weights reach kernels that interpret them as BF16 and FP32 respectively, producing incorrect results and potentially reading beyond the weight storage. Validate the rank, dtype, shape, layout and matching GPU placement of x, router_weight and correction_bias before selecting either tier, including the bias's required 128-element length.

Review effort: Balanced

Comment thread op_tests/test_decode_router_chain.py Resolved
ganyi1996ppo and others added 3 commits November 24, 2026 07:49
…e, stride-aware input quant, per-GPU launcher, quant tests

Review findings on ROCm#8552 (the 8551 fixes ride along, same files):
- router_gemm_partials selected the 33-128 row n-blocks tier on any arch: its
  LDS (69632 B at 65-128 rows) exceeds gfx942's 64 KiB and the MFMA form is
  gfx950-only. It now returns None unless every tensor, including the optional
  line-layout gate copy, is CUDA storage on one gfx950 device, launches under
  that device and stream, and keeps one launcher per GPU.
- _dual_quant_group (the MXFP4 / MXFP8 input-quant workgroups) ignored the row
  stride: for a [m, 6144] view with row stride > 6144 it quantized the padding
  of the previous row. It reads rows at i32_sx like the GEMM path.
- Neither quant mode had a test. test_input_quant_workgroups launches modes 1
  and 2 (also with a padded row stride) and checks the e8m0 scales against a
  torch rule exactly, every element against the e4m3 / e2m1 error bound, every
  row's reconstruction error, and that the router partials still sum to the
  logits. Rows 1-128, per-split oracle, padded stride and rejection cases are
  covered; the file is listed in aiter_test.sh's pytest dispatch (CI runs op_tests
  with `python3 file`, which collects nothing here).

Verified on gfx950: 63 passed.

Co-Authored-By: Claude <[email protected]>
…e, stride-aware input quant, per-GPU launcher, quant tests

Review findings on ROCm#8552 (the 8551 fixes ride along, same files):
- router_gemm_partials selected the 33-128 row n-blocks tier on any arch: its
  LDS (69632 B at 65-128 rows) exceeds gfx942's 64 KiB and the MFMA form is
  gfx950-only. It now returns None unless every tensor, including the optional
  line-layout gate copy, is CUDA storage on one gfx950 device, launches under
  that device and stream, and keeps one launcher per GPU.
- _dual_quant_group (the MXFP4 / MXFP8 input-quant workgroups) ignored the row
  stride: for a [m, 6144] view with row stride > 6144 it quantized the padding
  of the previous row. It reads rows at i32_sx like the GEMM path.
- Neither quant mode had a test. test_input_quant_workgroups launches modes 1
  and 2 (also with a padded row stride) and checks the e8m0 scales against a
  torch rule exactly, every element against the e4m3 / e2m1 error bound, every
  row's reconstruction error, and that the router partials still sum to the
  logits. Rows 1-128, per-split oracle, padded stride and rejection cases are
  covered; the file is listed in aiter_test.sh's pytest dispatch (CI runs op_tests
  with `python3 file`, which collects nothing here).

Verified on gfx950: 63 passed.

Co-Authored-By: Claude <[email protected]>
…fails without the id-range guard)

Co-Authored-By: Claude <[email protected]>
@ganyi1996ppo
ganyi1996ppo marked this pull request as draft November 25, 2026 02:09
@ganyi1996ppo
ganyi1996ppo marked this pull request as ready for review November 25, 2026 02:21
Copilot AI balanced review requested due to automatic review settings November 25, 2026 02:21

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.

🟡 Changes recommended

Routing can produce NaN weights for supported inputs, unchecked buffer spans can allow out-of-bounds writes or offset overflow, and the new regression suite is not executed by CI.

5 open issues

Review effort: Balanced

Comment on lines +146 to +147
y = (x.to(fx.Float64) * fx.Float64(NEG_LOG2E)).to(fx.Float32)
ss.append(fx.Float32(fx.rocdl.rcp(T.f32, fx.Float32(1.0) + y.exp2())))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Acknowledged, tracked: this needs a maintainer/author decision (scope or design trade-off), so no change is made yet; decision pending.

ganyi1996ppo and others added 2 commits November 25, 2026 19:04
…e fp4 cvt, gfx950 gate via get_gfx_runtime, collect the id-routing probe in CI

- router_gemm_partials: reject non-2D hidden_states before reading shape[0] (a 0-D tensor raised IndexError instead of returning None for the caller fallback).
- decode_router_common._cvt_pk_fp4: use FlyDSL's rocdl.cvt_scalef32_pk_fp4_f32 wrapper (as decode_tile_primitives._fp4) instead of the raw LLVM intrinsic.
- test_decode_id_routing: gate on get_gfx_runtime() == "gfx950" instead of a gcnArchName substring probe.
- split_tests.sh / aiter_test.sh: add flydsl_tests/test_decode_id_routing.py to the nested-file list and dispatch it through pytest (it has no script entry point), so routing regressions run in CI.

Co-Authored-By: Claude <[email protected]>
…op-k output / partials spans

splitk_biased_topk_mxfp4_mxfp8_quant: reject output rows or partials whose byte span exceeds 2**31 - 1 (the 32-bit buffer descriptor extent, which is also the masked-store sentinel), as router_gemm_partials does.

Co-Authored-By: Claude <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 01:23
ganyi1996ppo added a commit to ganyi1996ppo/aiter that referenced this pull request Nov 26, 2026
…#8555) into moe-decode-fmoe-tuner

# Conflicts:
#	.github/scripts/aiter_test.sh

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

Human assessment is needed because omitted moderate-severity findings identify shape indexing before rank validation that can raise unexpected exceptions instead of the documented fallback or error.

3 open issues
2 resolved since last review

Review effort: Balanced

ganyi1996ppo and others added 2 commits November 25, 2026 20:48
A module-level pytest.skip leaves no collected tests, so the per-file pytest
run exits with code 5 on MI300X shards. Use a module-wide skipif mark.

Co-Authored-By: Claude <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 02: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.

🔵 Needs a closer look

Human review is needed because hidden findings identify critical buffer aliasing that can corrupt kernel outputs, alongside input-validation errors that cause unintended exceptions.

2 open issues
1 resolved since last review

Review effort: Balanced

@ganyi1996ppo

Copy link
Copy Markdown
Contributor Author

Status for the Copilot overviews (latest on ac90ed476) and the aiter-bot self-review: inline findings are answered in their threads (fixed in 6b89b92 / bd033f8 / 0374946, or not applicable with evidence); tracked with a decision pending: the sigmoid exp2 overflow for logits below -88.7. The description now has the PR Self-Review section for revision ac90ed4. Open: one Triton shard failure on this run, unrelated (no Triton files), rerun pending.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 07:47

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.

🟡 Changes recommended

Output validation permits aliased weight and ID buffers that overwrite each other, while a premature shape access raises IndexError for scalar inputs and prevents the documented fallback.

3 open issues
1 resolved since last review

Review effort: Balanced

…efore indexing

Copilot 4705298743: splitk_biased_topk_mxfp4_mxfp8_quant accepted topk_weights
and topk_ids views that alias the same storage (e.g. topk_ids=topk_weights.view
(torch.int32)), so the fp32 weight store and the int32 id store silently
overwrote each other. Reject overlapping output byte ranges before launch
(_row_major_byte_span) and add a regression (aliased view raises ValueError).

Copilot 4705298807: route_quant_small read x.shape[0] before checking
x.dim() == 2, so a 0-d x raised IndexError instead of returning None for the
caller's documented fallback. Move the shape[0] read after the rank check and
add a 0-d regression.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 08:45
@ganyi1996ppo

Copy link
Copy Markdown
Contributor Author

Status for the latest Copilot overview (on 4690f57be): both inline findings are fixed in 3199323ea (aliased topk_weights/topk_ids output rejected; route_quant_small's rank check now runs before x.shape[0]) and replied in their threads. The description's PR Self-Review is updated to 3199323ea.

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

Human assessment is needed because a critical output-aliasing case can overwrite input bias and make expert selection schedule-dependent.

1 open issue
2 resolved since last review

Review effort: Balanced

@ganyi1996ppo

Copy link
Copy Markdown
Contributor Author

Closing this as part of consolidating our MiniMax-M3.1 TP4 decode-MoE work.

Rationale: this decode chain (#8548 router GEMM + id-routing + tile primitives, #8553 top-4 + MXFP4/MXFP8 input-quant, #8555 expert GEMM1/GEMM2 + shared-expert fold, #8676 fused_moe(shared_folded) integration + decode-chain tuner) is a parity port of the amd-kernels decode path — bit-identical to that reference, not a speedup over it. aiter main already serves MiniMax-M3.1 TP4 decode at the same shapes (M=8-256) through the merged mega_moe_tp backend (#8270), which is the path our production stack uses, so this standalone single-GPU chain adds no independent end-to-end gain.

The one genuinely new optimization from this effort — the one-workgroup E128 expert sort (2.5-3x vs the default sort, through the general moe_sorting interface, useful to every E128 MoE model) — landed separately in #8556 and stays.

Closing to keep the review queue focused. Thanks to everyone who reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants