Skip to content

[FlyDSL] perf: integrate APRE M256 kernels into gfx1250 MegaMoE S1F - #7410

Open
yanguahe wants to merge 36 commits into
mainfrom
hyg_pr6564_opt
Open

yanguahe wants to merge 36 commits into
mainfrom
hyg_pr6564_opt

Conversation

@yanguahe

@yanguahe yanguahe commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Integrate the pinned M256 prefill kernels into gfx1250 MegaMoE S1F and extend the workers4096 path to runtime source_token_count >= 4096, including the GEMM1 CN2, dense BF16 slot, and combine128 entry points.

The latest c3-2 three-round medians reduce Flash EP4 H5120/I2304/E384/topk6/shared0 at T16384/rank from 1696.466 to 1544.144 µs/layer (8.98%) versus rocm-main. For EP4 H7168/I2048/E256 routed/topk8/shared1, the reductions versus rocm-main are 18.02%, 21.66%, and 24.55% at T4096/8192/16384 per rank. All versions in these latest comparisons enable pin VGPR. These are complete eight-layer chain measurements, including RMSNorm/residual and replay/synchronization overhead. The >20% target is reached for the shared-expert workload at T8192 and T16384; it remains open for the Flash workload.

Changes

  • Extend workers4096 selection using runtime source_token_count >= 4096 for the workloads below, together with GEMM1 CN2, dense BF16 combine slots, and combine128.
  • Port M256 prefill GEMM scheduling and register policies while keeping the original activation rounding order. Preserve the compact APRE payload/scale layouts and the GEMM1-to-GEMM2 contract.
  • On the pinned Flash EP4 large-prefill path, GEMM1 consumes the row-major dispatch input and produces APRE A2. Its default is M256/N256/K256/w2x2/b3, prefetch0; GEMM2 is M256/N256/K256/w2x2/b4, prefetch1, with one TDM owner for each of A/B/ScaleA/ScaleB. Pin is the only tuning override in formal validation.
  • Pair eligible large-step GEMM1 CTAs across adjacent N panels with a shared ticket and cluster rendezvous, preserving live dispatch readiness and completion waits. Use a 10240-byte BF16 combine slot pitch instead of 16384 bytes for the pinned Flash EP4 T16384 instance, with matching scatter/reduce address rules. GEMM1 remains S1F persistent; the extended path uses the tuned GEMM2 workers4096 schedule with fused scatter.
  • Retain the existing route masks, empty-source-rank handling, current-stream/pointer launch ABI, hook checks, and captured static grids. Keep optional producer/group/ring controls and the explicit APRE path for supported configurations.
  • Merge main 88ebffa4, including its normal M256 S1F 2x2 wave-layout fix. That main revision removes the large-batch receive restriction for this EP4/topk6 path, so the historical d551 comparison uses V1 and V3 only.
  • Extend the existing distributed benchmark with actual per-rank token counts, receive bounds, retained-input checksums, raw replay samples, and profiler completeness diagnostics.

Performance

Latest c3-2 workers4096 extension results (description updated 2026-11-27)

Environment: c3-2, container hyg_fyd1, four gfx1250 GPUs. The extension was developed on top of hyg_pr6564_opt at 4436f0e and synchronized to c3-2. Its entry uses runtime source_token_count >= 4096, extending workers4096 together with GEMM1 CN2, dense BF16 slots, and combine128.

Common configuration: pin VGPR enabled for every tested version, non-balanced routing (--routing uniform, AITER_MOE_EXPERT_BALANCE=False), identical seed=0 routing, a4w4_mxfp4, FP4 dispatch, combine_quant=none, 8 layers, warmup=5 / iters=20 / acc_verify=1. T is the actual MoE input token count on each rank. Each entry is the median of three independent runs. Units are µs/layer, calculated from the complete eight-layer chain, including RMSNorm/residual and replay/synchronization overhead.

Flash: E384 routed / topk6 / EP4 / H5120 / I2304 / shared0

Actual T/rank hyg_pr7410_base rocm-main workers4096 extension Time reduction vs base Time reduction vs main
4096 533.153 533.818 517.244 2.98% 3.10%
8192 939.657 939.241 865.629 7.88% 7.84%
16384 1695.100 1696.466 1544.144 8.91% 8.98%

The improvement versus rocm-main increases from 3.10% at T4096/rank to 8.98% at T16384/rank. The >20% complete-chain reduction target remains open for this workload.

Shared expert: E256 routed / topk8 / shared1 / EP4 / H7168 / I2048

Each rank contains 64 routed experts plus one shared-expert replica, giving 260 total expert slots across EP4. Each token has nine compute routes: eight routed experts plus one shared expert. The benchmark arguments remain -e 256 -k 8 --fused_shared_experts 1.

Actual T/rank rocm-main as-is workers4096 extension Time reduction vs main
4096 950.650906 779.314187 18.02%
8192 1757.999625 1377.272500 21.66%
16384 3507.929437 2646.563062 24.55%

The shared-expert workload exceeds the >20% reduction target at T8192 and T16384 per rank. The reduction is (baseline - extension) / baseline * 100%. These c3-2 results use their own stated baselines; the older d551 and f01-2 measurements below retain their original revisions and settings.

Reproduction commands

Run from the selected version's repository root inside hyg_fyd1, after confirming all GPUs are idle. Set MEGA_T to 4096, 8192, or 16384, and run three independent processes for each version and size. All compared versions use the pin setting below.

Flash workload:

MEGA_T=4096
PYTHONUNBUFFERED=1 PYTHONPATH="$PWD" \
AITER_MEGA_S1F=1 AITER_MEGA_QUANT_FUSE=128 AITER_MEGA_PLAN_PREFETCH=0 \
AITER_FLYDSL_EXPLICIT_VGPR_PARTITION=1 \
AITER_MOE_EXPERT_BALANCE=False AITER_FORCE_A8W4=0 \
MORI_GPU_ARCHS=gfx1250 FLYDSL_GPU_ARCH=gfx1250 \
MORI_AMD_SMI_PATH=/opt/rocm/lib/libamd_smi.so.27 ENABLE_CK=0 \
python3 -m torch.distributed.run --standalone --nproc_per_node=4 \
  op_tests/multigpu_tests/bench_mega_moe.py \
  -tpr "$MEGA_T" --layers 8 -e 384 -k 6 -hd 5120 -id 2304 \
  --fused_shared_experts 0 --routing uniform \
  -q a4w4_mxfp4 --dispatch_wire fp4 \
  --stage1_fused true --stage2_fused true --combine_quant none \
  --profile_table 0 --warmup 5 --iters 20 --acc_verify 1 --seed 0

Shared-expert workload:

MEGA_T=4096
PYTHONUNBUFFERED=1 PYTHONPATH="$PWD" \
AITER_MEGA_S1F=1 AITER_MEGA_QUANT_FUSE=128 AITER_MEGA_PLAN_PREFETCH=0 \
AITER_FLYDSL_EXPLICIT_VGPR_PARTITION=1 \
AITER_MOE_EXPERT_BALANCE=False AITER_FORCE_A8W4=0 \
MORI_GPU_ARCHS=gfx1250 FLYDSL_GPU_ARCH=gfx1250 \
MORI_AMD_SMI_PATH=/opt/rocm/lib/libamd_smi.so.27 ENABLE_CK=0 \
python3 -m torch.distributed.run --standalone --nproc_per_node=4 \
  op_tests/multigpu_tests/bench_mega_moe.py \
  -tpr "$MEGA_T" --layers 8 -e 256 -k 8 -hd 7168 -id 2048 \
  --fused_shared_experts 1 --routing uniform \
  -q a4w4_mxfp4 --dispatch_wire fp4 \
  --stage1_fused true --stage2_fused true --combine_quant none \
  --profile_table 0 --warmup 5 --iters 20 --acc_verify 1 --seed 0

Historical c3-2 d551 formal comparison (2026-11-17)

Environment: c3-2, container hyg_fyd1, four gfx1250 GPUs; FlyDSL source tag v0.5.0 / package 0.5.0.dev1018, LLVM 24.0.0git, COMGR 3.5.0. V1 uses a clean worktree at main 88ebffa40126277787d523a50632fe8d03d3dc9a; V3 source is d551a0bb4de6092a21491c8aa0f90f3dd4bc88c3 with AITER_FLYDSL_EXPLICIT_VGPR_PARTITION=1.

Workload: DeepSeek-V4.1-Flash, H5120/I2304, global routed E384/topk6/EP4/shared0, 16384 actual valid MoE tokens on every rank, uniform synthetic routing, data_init=norm, a4w4_mxfp4, FP4 dispatch, combine_quant=none, 8 layers, warmup5/iters20/acc_verify1, seed0. Both versions use identical input, per-layer routing, quantized weights, FP32 reference, and the original tolerance.

Round V1: clean main88 V3: d551 + pin Accuracy
0 1694.791313 1585.672625 Both PASS
1 1692.454438 1586.298406 Both PASS
2 1695.015750 1585.574250 Both PASS
Three-round median 1694.791313 1585.672625 Both PASS

Units are µs/layer. Each replay executes the complete eight-layer graph; each rank sorts 20 host-wall samples and selects index10, then the four rank values are averaged and divided by8. The table takes the median of three independent runs, alternating V1/V3, V3/V1, V1/V3. It includes RMSNorm/residual and replay/synchronization overhead. All prechecks and postchecks showed four idle GPUs and no KFD processes. The 12 complete four-rank FP32 output comparisons against same-round V1 are bit-identical (different_elements=0, max_abs_diff=0), in addition to six original accuracy-gate passes.

V3 reduces complete-chain time by 109.118688 µs/layer (6.438473%). The >20% threshold is <1355.833050 µs/layer; the d551 V3 snapshot is 229.839575 µs/layer above it. Historical main95 results include a test-only VGPR geometry guard and are not a main-as-is comparison. Single-round prototype results and instrumented component diagnostics do not replace the formal medians above.

The retained evidence for this d551 comparison is formal_acceptance_pairqdense2.json, formal_acceptance_audit_pairqdense2.json, and output_validation_pairqdense2.json in the retained task directory below. All six runs used fixed source revisions and empty source overlays. Four idle GPUs and no KFD/fuser workload were confirmed before and after each run; no GPU monitoring ran during timing.

Reproduction

From the c3-2 host, the retained idle-guarded harness can launch fresh cases at the validated source snapshots:

task7410=/mnt/data/yanguahe/code/wk_sp1/.codex_tmp/pr7410_s1f_port_20261116
run_id=$(date -u +%Y%m%dT%H%M%S)
for round in 0 1 2; do
  versions=(v1_main88 v3_formal)
  if ((round % 2)); then versions=(v3_formal v1_main88); fi
  for version in "${versions[@]}"; do
    python3 "$task7410/run_checked.py" \
      "reproduce_${run_id}_${version}_r${round}" "$version" run_formal_container.sh
  done
done

The V3 helper clears inherited tuning overrides, sets pin, and runs the following production-default workload inside hyg_fyd1. Execute kernel commands from the repository root after the required all-GPU idle check:

PYTHONPATH="$PWD" PYTHONUNBUFFERED=1 \
AITER_MEGA_S1F=1 AITER_MEGA_QUANT_FUSE=128 AITER_MEGA_PLAN_PREFETCH=0 \
AITER_MOE_EXPERT_BALANCE=False AITER_FORCE_A8W4=0 ENABLE_CK=0 \
AITER_FLYDSL_EXPLICIT_VGPR_PARTITION=1 \
MORI_GPU_ARCHS=gfx1250 FLYDSL_GPU_ARCH=gfx1250 \
MORI_AMD_SMI_PATH=/opt/rocm/lib/libamd_smi.so.27 \
torchrun --standalone --nproc_per_node=4 \
  op_tests/multigpu_tests/bench_mega_moe.py \
  -tpr 16384 --layers 8 -e 384 -k 6 -hd 5120 -id 2304 \
  --fused_shared_experts 0 --routing uniform \
  -q a4w4_mxfp4 --dispatch_wire fp4 \
  --stage1_fused true --stage2_fused true --combine_quant none \
  --profile_table 0 --warmup 5 --iters 20 --acc_verify 1 --seed 0

Exact retained inputs, reference reuse rules, raw samples, full-output comparisons, resource evidence, and the unretained prototype ledger are documented in the c3-2 report. The historical f01-2 nine-size table and its commands remain below, tied to their original source revisions and environment.

Historical f01-2 three-version comparison (2026-11-04)

Measured on four gfx1250 GPUs on f01-2 in the dsv41_mlperf container. Workload: DeepSeek-V4.1-Flash, H5120/I2304/global routed E384/topk6/EP4, shared experts=0, and equal actual valid MoE tokens per rank T. All versions use uniform synthetic routing, expert_balance=False, a4w4_mxfp4, FP4 dispatch, combine_quant=none, 8 layers, warmup=5, iters=20, acc_verify=1, and seed=0.

Version Fixed source revision Configuration
V1: main as-is 78e18eb80cda873f2402c1b1d4acf00032001c35 Original receive-bound/tile fallback checks; explicit VGPR partition disabled (pin=0).
V2: main with only recv fallback removed Same main revision A test-only wrapper makes _Stage1Fusion._recv_too_big() return False; other tile/shape checks remain; pin=0.
V3: PR + pin 73a2a9d9cd97af38cce0c5770bd2e17999193d0c pin=1; T<4096 keeps the original S1F path with the recv fallback removed by the same wrapper; T>=4096 selects APRE t256x256x256/w2x2/b4 GEMM1/GEMM2, GM8, producers64, ring8, store inflight3, APRE TDM/prefetch enabled, cluster 1x1.

Timing scope and statistic: units are µs/layer, and each entry is the median of three rounds. The value is the complete eight-layer graph-chain time divided by eight, including RMSNorm/residual and host graph replay/synchronization overhead. Within each round, each rank sorts its 20 host-wall replay samples and selects index 10; the four rank values are averaged and divided by eight. These are uninstrumented graph measurements, not isolated GEMM or pure MegaMoE device durations. All 81 total-time cases completed and passed the original FP32 numerical gate; GPU ownership, utilization and VRAM were checked on all four GPUs before recording performance.

Actual T/rank V1: main as-is V2: only recv fallback removed V3: PR + pin V3 time increase vs V2
256 207.606 207.197 274.501 32.48%
512 222.783 222.446 257.609 15.81%
1024 257.464 257.184 294.399 14.47%
2048 378.875 347.849 400.346 15.09%
3072 479.637 439.595 505.644 15.02%
4096 592.570 533.144 573.637 7.60%
5120 698.975 624.110 694.248 11.24%
6144 801.202 712.992 754.169 5.78%
16384 1861.588 1737.315 1786.383 2.82%

The increase is (V3 / V2 - 1) * 100%, calculated from the unrounded three-round medians. V3 is slower than V2 at all nine sizes; the T>=4096 increase is 2.82%-11.24%. This comparison changes PR code, pin VGPR, and the large-T APRE tile/scheduling configuration together, so it does not isolate a single cause.

Actual path audit: T256 selects an unsupported-for-S1F M32 tile, so all three versions fall back. V1 runs S1F only at T512/T1024 and falls back at T>=2048; V2/V3 run S1F at T>=512. V1/V2 retain main's row-major M128 at T>=4096, while V3 uses APRE M256. GEMM1/GEMM2 component measurements and strict MegaMoE device spans are still in progress and are not represented by the total-time table above.

Test commands for this comparison

The exact task-only harness and raw records are retained at:

/data/yanguahe/code/wk_sp1/pr7410_perf_20261103.NLFTOe

main/ and pr7410/ are clean worktrees at the fixed revisions above. The common entry.py loads head_bench_mega_moe.py for all three versions, imports production kernels from the selected worktree, and applies only the fallback predicate override described above. It also retains runtime/path audits and byte-checked canonical quant inputs/reference caches outside timing. The original mathematical reference and acceptance tolerance are unchanged. These measurement helpers are retained task artifacts, not additional files in this PR.

Run the following from the f01-2 host shell to reproduce three rounds in new case directories. run_checked_case.sh holds the task performance lock, waits for all four GPUs to be idle, and invokes run_case.sh; only the benchmark/kernel command executes inside dsv41_mlperf. The order reverses token sizes on odd rounds and rotates the version order.

set -euo pipefail
task7410=/data/yanguahe/code/wk_sp1/pr7410_perf_20261103.NLFTOe
run_id=$(date -u +%Y%m%dT%H%M%S)
sizes=(256 512 1024 2048 3072 4096 5120 6144 16384)
versions=(v1 v2 v3)
for round in 0 1 2; do
  for ((j=0; j<${#sizes[@]}; j++)); do
    index=$j
    if ((round % 2)); then index=$((${#sizes[@]} - 1 - j)); fi
    tokens=${sizes[index]}
    for ((k=0; k<3; k++)); do
      version=${versions[$(((round + k) % 3))]}
      tag="reproduce_${run_id}_time_r${round}_${version}_T${tokens}"
      bash "$task7410/run_checked_case.sh" "$tag" "$version" "$tokens" time
    done
  done
done

The helper's common four-rank benchmark command inside the container is:

torchrun --standalone --nproc_per_node=4 "$task7410/entry.py" \
  -tpr "$tokens" --layers 8 -e 384 -k 6 -hd 5120 -id 2304 \
  --fused_shared_experts 0 --routing uniform \
  -q a4w4_mxfp4 --dispatch_wire fp4 \
  --stage1_fused true --stage2_fused true --combine_quant none \
  --profile_table 0 --warmup 5 --iters 20 --acc_verify 1 --seed 0

run_case.sh supplies the selected source path, task/cache/output paths and these environment controls before importing AITER:

# Common controls, all versions
PYTHONPATH="$repo:$task7410"
PYTHONUNBUFFERED=1
AITER_MEGA_S1F=1
AITER_MEGA_QUANT_FUSE=128
AITER_MEGA_PLAN_PREFETCH=0
AITER_MOE_EXPERT_BALANCE=False
AITER_FORCE_A8W4=0
MORI_GPU_ARCHS=gfx1250
FLYDSL_GPU_ARCH=gfx1250
MORI_AMD_SMI_PATH=/opt/rocm/lib/libamd_smi.so.27
ENABLE_CK=0

# V1/V2: pin=0, AITER_TDM_A_PRESHUFFLE=0
# V3, T<4096: pin=1, AITER_TDM_A_PRESHUFFLE=0
# V3, T>=4096: pin=1 plus all controls below
AITER_FLYDSL_EXPLICIT_VGPR_PARTITION=1
AITER_TDM_A_PRESHUFFLE=1
AITER_TDM_TILE_M=256
AITER_TDM_TILE_M2=256
AITER_TDM_TILE_N=256
AITER_TDM_TILE_K=256
AITER_TDM_NUM_BUFFERS=4
AITER_TDM_M_WARP=2
AITER_TDM_N_WARP=2
AITER_GROUPED_GEMM_AS_PROLOGUE=0
AITER_TDM_NEXT_STAGE_PREFETCH=1
AITER_TDM_B_TH=0
AITER_FLYDSL_MXFP4_CLUSTER_M=1
AITER_FLYDSL_MXFP4_CLUSTER_N=1
AITER_MEGA_S1F_APRE_TDM=1
AITER_MEGA_S1F_APRE_PREFETCH=1
AITER_MEGA_S1F_PRODUCERS=64
AITER_MEGA_S1F_GROUP_M=8
AITER_MEGA_S1F_APRE_RING_SLOTS=8
AITER_MEGA_S1F_APRE_STORE_INFLIGHT=3

--profile_table 0 avoids profiler perturbation of the total-time measurements. The wrapper's time mode does not load kernel timestamps or HIP timing events. The three versions reuse identical retained hidden/routing and canonical CPU-quantized weight bytes; reference/quant preparation is outside timing. The frozen quant cache is retained at /data/yanguahe/code/wk_sp1/megamoe_apre_m128_20261103.BRARDq/frozen_quant_cpu1.

Historical single-round measurements

Historical single-round measurements at 78bd2c9e1ade8e8e1dc51705f12673a6d8333a39 on four gfx1250 GPUs on f01-2. These are not a before/after comparison against current main, nor GPU revalidation of the merged revision. No speedup against current main is claimed.

Configuration: H5120/I2304/global E384/topk6/EP4, real rows on all four ranks, uniform synthetic routing, expert_balance=False, S1F, FP4 dispatch, APRE M256/M256, explicit VGPR partition (pin=1), GM8, ring8/store3, 8 layers, warmup=5, iters=20, acc_verify=1. Each rank's 20 graph-replay host-wall samples are sorted and index 10 is selected; the four rank values are averaged and divided by 8. GPUs were idle for the recorded measurements.

Hardware Workload/configuration Before After Change
4x gfx1250, f01-2 Actual T4096/rank; configuration above Current main unmeasured Historical M256: 573.212 us/layer Not claimed
4x gfx1250, f01-2 Actual T5120/rank; configuration above Current main unmeasured Historical M256: 703.457 us/layer Not claimed
4x gfx1250, f01-2 Actual T6144/rank; configuration above Current main unmeasured Historical M256: 767.583 us/layer Not claimed
4x gfx1250, f01-2 Actual T16384/rank; configuration above Current main unmeasured Historical M256: 1834.463 us/layer Not claimed

Reproduction configuration (select MEGA_T from 4096/5120/6144/16384, from the repository root in the ROCm container):

MEGA_T=4096
PYTHONPATH="$PWD" PYTHONUNBUFFERED=1 \
AITER_MEGA_S1F=1 AITER_MEGA_QUANT_FUSE=128 AITER_MEGA_PLAN_PREFETCH=0 \
AITER_MOE_EXPERT_BALANCE=False \
AITER_FLYDSL_EXPLICIT_VGPR_PARTITION=1 \
AITER_TDM_A_PRESHUFFLE=1 \
AITER_TDM_TILE_M=256 AITER_TDM_TILE_N=256 AITER_TDM_TILE_K=256 \
AITER_TDM_M_WARP=2 AITER_TDM_N_WARP=2 AITER_TDM_NUM_BUFFERS=4 \
AITER_GROUPED_GEMM_AS_PROLOGUE=0 AITER_TDM_NEXT_STAGE_PREFETCH=1 AITER_TDM_B_TH=0 \
AITER_FLYDSL_MXFP4_CLUSTER_M=1 AITER_FLYDSL_MXFP4_CLUSTER_N=1 \
AITER_MEGA_S1F_APRE_TDM=1 AITER_MEGA_S1F_APRE_PREFETCH=1 \
AITER_MEGA_S1F_GROUP_M=8 AITER_MEGA_S1F_PRODUCERS=64 \
AITER_MEGA_S1F_APRE_RING_SLOTS=8 AITER_MEGA_S1F_APRE_STORE_INFLIGHT=3 \
MORI_GPU_ARCHS=gfx1250 FLYDSL_GPU_ARCH=gfx1250 \
MORI_AMD_SMI_PATH=/opt/rocm/lib/libamd_smi.so.27 ENABLE_CK=0 \
torchrun --standalone --nproc_per_node=4 \
  op_tests/multigpu_tests/bench_mega_moe.py \
  -tpr "$MEGA_T" --layers 8 -e 384 -k 6 -hd 5120 -id 2304 \
  --fused_shared_experts 0 --routing uniform \
  -q a4w4_mxfp4 --dispatch_wire fp4 \
  --stage1_fused true --stage2_fused true \
  --profile_table 1 --acc_verify 1 --warmup 5 --iters 20

Testing

  • Latest c3-2 workers4096 comparisons recorded for both workloads at T4096/8192/16384 per rank: three independent runs per entry, pin enabled for all versions, warmup5/iters20/acc_verify1, seed0.
  • Performance benchmarks run: six uninstrumented formal runs against clean main88, original accuracy gate PASS; all 12 complete four-rank output comparisons are bit-identical.
  • Archived AST/LF/Black/Ruff checks pass for the formally tested source. Host selection assertions, paired-queue/dense-pitch address checks, and six existing S1F bucket CPU placeholder compiles pass; diagnostic resource probes do not replace the formal GPU timing/output checks.
  • Existing four-rank unequal-token/empty-source and NaN-slot/dropped-route replay checks pass. Source-model E64/topk8 and E65/topk9/shared1 H7168/I2048/T16384/balanced/random/pin1 regressions pass with independent nonconstant scales.
  • Full public dtype/layout suite on the merged source.
  • MI250X / MI300X validation (this kernel path targets gfx1250).

Component profiles and later single-round tuning screens are diagnostics with separate snapshots and timing scopes. They are not summed into a substitute total or promoted to the production configuration. The formal results above come from the original uninstrumented complete-chain timer; the report records profiling limitations and experiment status separately.

Documentation

The report records exact source revisions, measurement scope, commands, successful and failed experiments, full-output audits, and the status of the >20% objective. Task-only kernel overlays and measurement helpers are retained outside the package and are excluded from the PR's production changes.

Dependencies and compatibility

No new third-party dependency was added by this optimization. The source is aligned with the current main FlyDSL pin. This validation uses the stated gfx1250 environment; it does not establish performance on other architectures or all routing distributions.

PR Self-Review

Reviewed source revision

The latest workers4096 results identify the tested source as the extension on top of hyg_pr6564_opt at 4436f0e. The historical d551 comparison was formally tested at d551a0bb4de6092a21491c8aa0f90f3dd4bc88c3; c77567c8099ee19c976b373a4ae536e1498699e7 is its subsequent documentation snapshot.

Behavior and validation

Pinned Flash EP4 large prefill selects the production M256 path without task-only tile overrides. G1 waits for live dispatch rows before consuming them, preserves the original activation rounding, and writes the APRE payload and M128 scale groups consumed by G2. The large-step paired queue matches adjacent N-panel A multicast without replacing live expert/readiness checks. G2 retains weighting-before-BF16, output masks, scatter completion, and the existing cross-rank combine barrier. Scatter and reduce agree on the 10240-byte BF16 slot pitch. Capture and replay retain static grids and read runtime row counts on device. The timing, FP32 reference, input, routing, weights, and acceptance threshold are unchanged.

The latest c3-2 workers4096 comparison establishes an 8.98% complete-chain time reduction versus rocm-main for Flash at T16384/rank. For the H7168/I2048 shared-expert workload, the reductions are 18.02%, 21.66%, and 24.55% at T4096/8192/16384 per rank. The >20% goal remains open for Flash and is reached for the shared-expert workload at T8192 and T16384. Old f01-2 tables describe their fixed historical revisions; unretained prototype or partial profiler results are not substituted for current formal performance.

Changed op test and its purpose

op_tests/multigpu_tests/bench_mega_moe.py extends the existing distributed benchmark with actual per-rank token counts, including an idle source rank, and explicit receive bounds. Retained-input checksum validation detects input/routing/quantized-weight mismatch before timing; raw rank samples expose the replay statistic, and exact profiler counts reveal missing events. Standalone GEMM tests do not cover this multi-rank wire/replay workflow. The existing FP32 numerical reference and original acceptance gate are retained; full merged-source public-suite coverage is not claimed.

k50112113 and others added 24 commits October 30, 2026 06:10
Decode GEMMs are too short to hide a compact plan that waits out the payload copy, so start the next layer's plan on the side stream before dispatch returns and size that launch to the step's route count.

Co-authored-by: Cursor <[email protected]>
compact_hist_layout kept dense rows at exactly npes*experts_per_rank
dwords. The publish and the matrix read both have a TDM bulk path gated
on a 32-aligned row, so a row that is not a multiple of 32 falls back to
a per-dword scalar store to every peer.

DeepSeek-R1 at EP4 with one fused shared expert lands exactly there:
experts_per_rank becomes 65, so segs = 4*65 = 260 and 260 % 32 == 4.
Without the shared expert segs would be 256 and the bulk path applies,
which is why this only shows up on the shared-expert configuration.

Padding to _align32(segs) (260 -> 288) costs 448 B of arena per rank and
moves both the publish and the matrix read onto the bulk path. Per-phase
shader-cycle stamps inside the plan kernel, 8 layers, tpr=1536:

    publish  22607 cycles (39.5%)  ->  1486 (3.1%)

The win is partly offset by the barrier that follows: once publish is
fast every rank reaches it sooner, so rank-to-rank tally skew that the
slow publish used to hide now shows up as wait. Net is still large.

bench_mega_moe, 61 layers, EP4, a4w4_mxfp4, -tpr 1536 -hd 7168 -id 1536
-k 8 --fused_shared_experts 1, AITER_MEGA_PLAN_PREFETCH=0:

    tdm_compact_plan   32.54 us -> 24.84 us   (-23.7%)
    per_layer (fused) 460.98 us -> 453.39 us  (-1.65%)

The stage1_fused=false arm does not use this kernel and measured 474.44
vs 474.86 us across the two runs, which bounds the run-to-run drift.
Accuracy PASS on both arms; A/B repeated 3x with non-overlapping ranges.
The tail entry of _DISPATCH_COMPACT covers every tokens-per-rank above 512,
and the measurements in the comment above it stop at 512. Retuned for the
prefill sizes: 128x16 token-major -> 192x16 route-major, the same route-major
walk the smaller buckets already use.

Measured on 4x gfx1250, a4w4_mxfp4, hidden 7168, inter 2048, topk 8 plus one
shared expert, 8 layers, accuracy PASS throughout. At tpr 1536, random
routing: dispatch 44.6 -> 40.1 (-10.0%), per_layer 450.8 -> 447.2 (-0.8%).
The win holds from tpr 768 to 16384. The <=512 buckets are untouched.

Both fields matter: at 4096 and 16384 either change on its own is slower than
the entry it replaces.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Clamp the step alignment by arena rows, not by the init tile, and key the compact lookup with ep_fused like fused_moe. Add the expert-65 token=32768 row.
Two defects in the gfx1250 compact plan:

* ``@comm_ops.traced`` no longer exists (removed with the tracing rework), so
  the plan kernel failed to build. Use ``@flyc.jit``.
* On the sparse histogram path the LDS histogram and matrix were sized from
  the window row, which is the shorter packed ``(nnz, seg|cnt)`` row there,
  while every index into them is a segment. Size them from the dense pitch;
  ``row_dwords`` stays the window row. Without this, sparse configurations
  (EP x experts not a multiple of 32, e.g. tokens/rank 16 and 24) either
  faulted or produced wrong counts.

Co-Authored-By: Claude Opus 5 <[email protected]>
…kernel

The gfx1250 compact path runs ``ep_dispatch_tdm`` to completion -- including
its tail barrier, which waits for every peer -- before GEMM1 starts, so the
dispatch sits on the critical path in full.

Add ``AITER_MEGA_S1F=1`` (off by default): one persistent stage-1 kernel that
does both. All 512 CTAs are resident at once and take their role from the
block id. The P lowest block ids of each XCC produce: a barrier-free 4-wave
mailbox pipeline over a 4-slot LDS ring, where W1 claims blocks of the plan's
run table, W0 fetches each run's <= 8 whole wire rows with one 16-bit-index
TDM gather, and W2/W3 ship them to the peer with one 2-D SCOPE_SYS TDM store
plus the ep_rowmap pairs. The op that completes a (tile, source) piece
publishes a generation-tagged flag. Every other CTA runs GEMM1 straight away
and waits per m-tile on that tile's source flags instead of on a global
barrier, so a tile computes as soon as its own rows land; producers join the
GEMM1 work once the run table is exhausted.

Supporting changes:
* The sender quant writes whole ``payload | e8m0 | pad`` wire rows at the
  compact pitch, so one gather fetches a run's payload and scales together
  (``quant_kernels.cu`` gains the row strides; the dense path is unchanged
  and bit-identical).
* The compact plan emits the producers' run table, the send list and
  per-m-tile ``tile_info``, and gets a faster X1 exchange: a single tagged
  hop instead of a release fence plus done atomics and an acquire (7.3 ->
  0.2 us), the send list built during the X1 wait, parallel table emission
  and release stores on the multi-block barriers. The default path takes
  these too.
* ``build_gemm_a8w4_tdm_task`` factors the GEMM1 tile body out of
  ``launch_gemm_a8w4_tdm`` so the stage-1 kernel can inline it per work item,
  with a hook for the per-tile data wait. The standalone launcher is
  unchanged (byte-identical ISA).

Measured on 4x gfx1250 (a4w4_mxfp4, 7168/1536, 2 layers), per layer vs the
default path, interleaved in one session, logits bitwise identical:

| tokens/rank |    16 |   128 |   768 |  1536 |  4096 |
|-------------|-------|-------|-------|-------|-------|
| bench (E260 k9)   | -5.3% | -3.5% | -8.2% | -8.1% | -9.4% |
| production (E256 k8 + 1 shared) |   -   |   -   | -6.4% | -6.1% |   -   |

At tokens/rank 1536 the stage-1 span goes 189.4 -> 155.7 us: of the 46 us the
dispatch and its gap cost, about two thirds is hidden, and 46% of GEMM1's busy
time overlaps a producer. What is left is producer/GEMM contention (~9 us) and
the start-up flag wait (~7 us).

The kernel inlines one GEMM1 configuration, so a tuned CSV row or an
``AITER_TDM_*`` override naming a different tile keeps the separate path:
``_s1f_gemm1_reasons()`` checks this before the dispatch is skipped and every
unsupported configuration warns once and falls back.

Co-Authored-By: Claude Opus 5 <[email protected]>
… a guess

Three crashes, all one root cause: whether a step runs the stage-1 kernel was
decided by predicting what the rest of the stack would do, and the prediction
drifted from reality. Because the dispatch is already skipped by the time the
GEMM1 hook runs, a wrong prediction cannot be recovered -- it raises mid-layer.
The DeepSeek-R1 shape (inter_dim 2048, 256 experts) hits all three; the shapes
tested so far did not, because their bucket has no tuned CSV row.

* The plan was built from the instance-level ``self._s1f``, so a step whose
  tuned GEMM1 tile is not the embedded one still compiled an S1F plan, and
  ``compile_tdm_compact_plan`` rejects tile_m > 255 instead of falling back.
  The plan's compile, its cache key, both warm-ups and its launch argument
  list now all derive from ``_s1f_plan_mode(align_m)``, so the plan and the
  GEMM1 hook never disagree.
* The launch argument list kept passing the three S1F pointers to a plan that
  had been compiled without them ("too many positional arguments").
* The gate predicted the GEMM1 configuration from the CSV row plus the
  ``AITER_TDM_*`` overrides. That misses, among others, a local default of 2
  where the builder's is 3. It is now observed instead: the first step of each
  (alignment, recv bound) runs the default path behind ``_s1f_probe_gemm1``,
  which records what the launch actually resolved to, and every later step
  decides from that record. One step per bucket, once per instance.

Also drop the tok_map rewrite from a prefetched S1F plan. Only the default
dispatch reads tok_map; the prefetch kept writing it because the step it feeds
was not yet known. With the step's verdict available ahead of it, the rewrite
goes: at tokens/rank 512 on the R1 shape the plan was 18.95 us with it and
9.87 us without, against 15.0 us for the default path's plan.

Validated on 4x gfx1250 at the R1 shape (7168/2048, E256 k8 + 1 fused shared
expert), logits bitwise identical to the default path at tokens/rank 128, 512
and 1536. 1536 is the bucket whose tuned tile is 256x256: it now falls back
cleanly ("step tile_m 256 != 64") where it used to raise.

Co-Authored-By: Claude Opus 5 <[email protected]>
At tokens/rank 1536 on the R1 shape (E256 k8 + 1 fused shared expert,
7168/2048) the tuned CSV row gives GEMM1 a 256-row tile, and the stage-1
kernel, which embedded only the 64-row one, fell back to dispatch + GEMM1 on
every step. Forcing 64 there costs more than the fusion saves (GEMM1 251-278
us at 64 against 173-175 us at 256).

* A second stage-1 variant at tile_m 256. Its GEMM1 needs ~750 VGPRs per
  lane (.vgpr_count 752, no spills), one wave per SIMD, so its grid is one
  CTA per CU (256 workers); the whole 320 KB of LDS is available, and 3
  buffers (221,184 B) measured faster than 4.
* Producers keep their 64-row pieces: a 32-run piece would not fit W1's
  32-lane look-ahead. The plan takes align_m (expert padding) apart from
  tile_m (run cuts, tile_info, flags), and a 256-row GEMM1 item reads its
  four flag tiles' tile_info and polls their flags in one load (lane j:
  flag tile j) and a ballot.
* Launches with 512 and 256 workers share one entry ticket: each CTA adds
  span / workers and L = ticket / span (span = 2 * CUs), so every launch
  advances the generation by one.
* The probe and the GEMM1 hook compare only the tile (tile_m = the step's
  alignment, 256 x 256). Waves, buffers and schedule are the variant's own:
  the tuned row's cluster 1x4, next-stage prefetch and planar LDS cannot be
  embedded (explicit tiles, deferred C wait), and dropping them from the
  separate GEMM1 cost nothing (161.9 us as tuned, 150.7-156.9 us without).
  The hook used to reject them after the dispatch was skipped. What the
  variants cannot build (K < 3 tiles, too few CUs, an e8m0 row that is not
  16 B) is now refused at init instead.
* forward() fixes the step's geometry before the S1F verdict, which used the
  previous step's alignment and probe record.

tpr 1536, 4x gfx1250, two interleaved same-session rounds: stage 1 167.9 us
(default dispatch + GEMM1 177.6 us), 437.4 us per layer (445.0 us). Logits
are bitwise identical to the default path on every rank, also in one process
that alternates 1536 / 512 / 128 tokens per rank (both variants on one
ticket).

Co-Authored-By: Claude Opus 5 <[email protected]>
…h window

A launch prefetches only the first 32,640 bytes of a kernel's code:
.amdhsa_inst_pref_size counts 128 B lines in an 8-bit field. The tile-256
stage-1 kernel is 47,488 B, so its epilogue sits outside that window and is
cold the first time a wave reaches it. Every CTA sharing an instruction
cache gets there at once, which is why each CTA's first item spent 9.1 us
between the end of its k-loop and its last store against 2.0 us for every
later item (traced, tpr 1536). The tile-64 kernel (21,760 B) does not have
the problem.

Wave 0 of each CTA now issues s_prefetch_inst_pc_rel over that tail at
entry, where the misses overlap the first flag wait. The range is not
hardcoded: the assembler folds .Lfunc_end0 - . into the code bytes that
follow, and each 4 KB chunk is prefetched only once a compare proves it lies
inside the kernel, so a kernel that fits the launch window branches out
after the first compare. gfx1250 has no safe-smem-prefetch, so a chunk must
never be allowed past the end of the code.

4x gfx1250, E256 k8 + 1 fused shared expert, interleaved same-session A/B:

  tpr 2048   stage 1  274.1 -> 267.3 us,  per layer  685.1 -> 676.6
  tpr 1536   stage 1  216.0 -> 210.3 us,  per layer  552.9 -> 546.8  (5 rounds)
  tpr  512   stage 1  139.2 -> 138.9 us   (tile 64: prefetch does not fire)

The first item's epilogue drops to 2.1 us, matching every later item. It
also removes a gate the traces had shown at tile 256: an item's end time
used to be independent of when its flags were ready (slope d(end)/d(ready)
0.01-0.45 across ranks), because early items all stalled on the same cold
cache lines; it is now 0.90-1.14, so work that becomes ready earlier does
finish earlier.

Co-Authored-By: Claude Opus 5 <[email protected]>
Only two of this shape's tuned rows reach the stage-1 kernel, because a
variant has to embed the step's GEMM1 tile and the table only held 64 and
256. Across the tuned file 82 of 118 gfx1250 rows ask for 16, 32 or 128, so
whole shapes (7168/768/384 at every bucket, 4096/2048/256 at 11 of 16) fell
back to dispatch + GEMM1 without a word.

A 128-row tile needs no new machinery: it is two flag tiles, the same path
the 256-row tile already takes at four. The compiled body takes 398 VGPRs
with no spills and 162,816 B of arena, so it runs two CTAs per CU -- two
arenas are exactly the 320 KB of LDS, and two waves of 398 VGPRs still fit a
SIMD. Residency is not a tuning knob here: the producers hand tiles to
consumers inside one launch, so a variant whose CTAs per CU exceeds what the
hardware allows would hang rather than run slow, which is why the comment
now says to read it off a dump.

4x gfx1250, E256 k8 + 1 fused shared expert, tile forced to 128:

  tpr  512   stage 1 131.3 us   (tile 64, the row this shape picks: 138.8)
  tpr 1536   stage 1 213.6 us   (tile 256: 210.3)

Logits are identical to the default path at both. The 512 figure is the
tuned row's to claim, not this variant's: 128 beats 64 there on the separate
GEMM1 too (119.8 against 125.9 us), and no row offers it.

Co-Authored-By: Claude Opus 5 <[email protected]>
`fx.rocdl.ballot` coerces its predicate itself (`_to_ir`, then a trunc to i1
when needed), so `arith.unwrap` at the call site only repeats the wrapper's
own `ir_value()`. Six of them go, which is all this file had.

No behaviour change: same VGPR / SGPR counts and spills (752 / 107 / 28), and
tpr 1536 measures 210.3 against 210.9 us of stage 1 over two interleaved
rounds, inside the 2 us a single variant spreads over. The register allocator
does renumber and the scheduler emits eleven more s_delay_alu, so the ISA is
not instruction-identical.

The stage-1 variant table's comment had grown by edits into one run-on
paragraph; it is a list of the three tiles now.

Co-Authored-By: Claude Opus 5 <[email protected]>
main deleted this package's `vector` proxy in #6379 and moved its own
descriptor builders onto `fx.Vector`, so the stage-1 kernel's nine
`vector.from_elements(T.vec(n, T.i32), ...)` calls no longer import. The
element type comes from the elements now, so the type argument goes with
them.

`TDM._i32` returns an `fx.Int32` in that same commit, which leaves the one
raw `arith.shli` beside it mixing a typed operand into a raw op;
`_tdm_group1_rows` reads its row count and shifts through `fx` instead, the
way main's `tdm_group1_rows_4b` already does.

Rebased onto main (65 commits) and re-measured: stage 1 is 209.4 us at tpr
1536 and 138.6 at 512, against 208.6-209.4 and 138.5 before the rebase, and
logits stay identical to the default path at both.

Co-Authored-By: Claude Opus 5 <[email protected]>
The plan is launched on its own stream ahead of the quant so the two overlap,
but they never do: rocprofv3 shows the separate stream surviving only in the
eager warmup (6 dispatches on stream 2 / queue 3) while every dispatch in the
captured graph lands on stream 0 / queue 1. CUDA graph capture flattens the
fork, so the quant simply waits for the plan, and a steady layer at tpr 1536
reads plan 15.9 | 2.2 | quant 6.7 | 2.5 | s1f 238.6, each boundary ~2 us.

So the quant moves inside the plan's launch instead. The plan occupies 1 to 7
of 256 CUs and holds them through its whole cross-rank histogram exchange;
blocks past plan_blocks now quantize on CUs that were idle. A lane takes one
whole 32-column group -- 64 B in, one e8m0 byte and 16 B of packed FP4 out --
so there is no cross-lane amax reduction, and consecutive lanes take
consecutive groups, so a wave reads 2 KB contiguous. It writes whole wire
rows (payload | e8m0 | pad), which is the layout the stage-1 producer
gathers.

The scale has to stay bit-identical or stage 1 reads a different payload:
both sides take RoundUp (kDefaultMxScaleRoundMode, csrc/include/
mx_quant_utils.h), which emit_mx_e8m0_scale documents its RoundUp branch to
match. Logits are unchanged against the default path at every size below.

The kernel ends when its last block does, so the plan's own time becomes
max(plan, quant) and the block count has to keep the quant under it. The
~28 MB a tpr-1536 step streams is HBM traffic, not the L2-resident kind a
GEMM sees: 32 blocks pushed the plan from 22 to 66-86 us, 128 brings it back
to 41-54. Per layer, interleaved rounds:

  tpr 2048   685.7 -> 676.2 us
  tpr 1536   548.8 -> 539.3 us   (two rounds here, three in the prototype)
  tpr  512   350.1 -> 343.8 us
  tpr  128   264.2 -> 260.3 us   (smaller: decode prefetches the plan)

A step whose plan was prefetched keeps the standalone HIP quant -- that plan
runs before the step's hidden states exist -- and AITER_MEGA_QUANT_FUSE=0
turns the fusion off everywhere.

Co-Authored-By: Claude Opus 5 <[email protected]>
Flash SwiGLU GEMM1 is N=4608, 18 tiles of 256. The 4-bit item code held 16 and the fused kernel fell back.

Co-authored-by: Cursor <[email protected]>
Keep main's dispatch/combine stages and carry the gfx1250 stage-1 kernel
on the compact path. AITER_MEGA_S1F stays off unless set.

Co-authored-by: Cursor <[email protected]>
The required_vmm_bytes check is not part of the stage-1 kernel change in this PR.

Co-authored-by: Cursor <[email protected]>
Integrate t256x256x256/w2x2/b4 APRE GEMM1/GEMM2 into the S1F FP4
path. Generate APRE A/ScaleA layouts in dispatch and the GEMM1
epilogue, and add opt-in eight-slot producer buffering with store
cap 3 while retaining the four-slot defaults.

Include S1F context, quantization and combine correctness fixes,
preserve invalid-row masks and empty-rank synchronization, and
support the FlyDSL 0.4.1.dev1005 pin interface.

Validated on gfx1250 EP4 synthetic MegaMoE at H5120/I2304/E384/topk6,
pin=1, 8 layers, warmup=5, iters=20 and acc_verify=1. Three-round
layer latency reductions versus checked M128 are 7.82%/3.11%/7.79%
at per-rank T4096/T5120/T6144; dynamic replay and fallback checks pass.
Keep the current main pointer ABI, stream handling and automatic S1F fallback. Allow explicit APRE M256 prefill configurations to retain the fused path, and keep the tested M256 kernels and benchmark diagnostics.
@yanguahe
yanguahe requested a review from a team November 3, 2026 14:44
@github-actions github-actions Bot changed the title perf: integrate APRE M256 kernels into gfx1250 MegaMoE S1F [FlyDSL] perf: integrate APRE M256 kernels into gfx1250 MegaMoE S1F Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

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 (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 gfx1201 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 7410 --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.

@github-actions github-actions Bot added the FlyDSL label Nov 3, 2026
@aiter-bot

aiter-bot commented Nov 3, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision fc159d252b9f · 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.

@zufayu
zufayu requested a review from yadaish November 4, 2026 01:30
# Conflicts:
#	aiter/ops/flydsl/kernels/mega_moe_gfx1250/s1f_stage1.py
Reuse GEMM1 stage payload and scale addresses and select the max-ilp scheduler.
Add a fixed-width 4096-worker GEMM2 EP scatter specialization and a
128-thread BF16 combine reduce for the accepted Flash prefill shape.
Extend EP MoE tests with model fixtures, ATOM input layouts and graph timing.
@zufayu
zufayu requested a review from GwilliamHu November 23, 2026 10:18
@zufayu zufayu assigned GwilliamHu and unassigned yadaish Nov 23, 2026
Remove clustered persistent continuations, APRE input/prefetch experiments,
and unused tuning overrides while retaining the pinned Flash EP4 T16384
current4096 configuration. Restore the main benchmark, standalone MoE
tests, and DSR1 tuning rows; the benchmark already reports all nine fields.

Validation: static AST/configuration, call signatures, LF, diff checks,
and source SHA256 synchronization. GPU tests were not run.
@@ -1748,110 +2341,173 @@ def compute_ktile(
None.
"""

active_m_rep, rmem_slots, alternate_b1, ring_addresses = state

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.

⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable alternate_b1 is never used

Suggested change
active_m_rep, rmem_slots, alternate_b1, ring_addresses = state
active_m_rep, rmem_slots, _alternate_b1, ring_addresses = state

@@ -1748,110 +2341,173 @@ def compute_ktile(
None.
"""

active_m_rep, rmem_slots, alternate_b1, ring_addresses = state

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.

⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable ring_addresses is never used

Suggested change
active_m_rep, rmem_slots, alternate_b1, ring_addresses = state
active_m_rep, rmem_slots, alternate_b1, _ring_addresses = state

XingerZhu added a commit that referenced this pull request Nov 24, 2026
…1 tpr

Port the pinned Flash/DSR1 EP4 prefill path from #7410 onto the DSR1 S1F
branch and keep the mori and small-tile paths at their previous speed.

From #7410:
- s1f_prefill_config(): M256/N256/K256 2x2 GEMM1 (3 buffers) and GEMM2
  (4 buffers) with A preshuffle for recv >= 16384 on (5120, 2304, 96, 6, 4)
  and (7168, 2048, 65, 9, 4).
- Stage-1 kernel: row-major MMA reuse, paired CTAs (pair_cluster_n=2),
  8-slot ring, silu16, quant_payload_preshuffled APRE output for GEMM2.
- GEMM2: fixed_n_ep 4096-worker EP scatter.
- Combine: dense BF16 slot pitch, 128-thread reduce, route masking from
  the source topk IDs.

On top of #7410:
- AITER_FLYDSL_EXPLICIT_VGPR_PARTITION now defaults to 1 and only gates the
  pinned prefill specializations. M256 4-wave tiles always take the fixed
  VGPR partition, as on main; small tiles no longer take it (tpr 256 S1F was
  241 us/layer with it, 205.5 without).
- Clustered 1x4/2x2 APRE GEMMs keep main's grouped DS schedule and
  ksl0_fence_mma tail instead of the native schedule, and compact M
  variants are limited to cluster_n <= 2 (mori GEMM2 at tpr 4096: 300.7 ->
  291.5 us).
- The direct BF16 combine reduce picks a block that divides one token's
  lanes (448 threads for hidden 7168), so route IDs load at a uniform
  address (mori combine at tpr 4096: 57.1 -> 44.9 us).
- DSR1 tile-256 grouped rows use cluster_m=1. With the clusters now formed
  under graph capture, 4x4 GEMM1 at tpr 16384 took 980 us vs 780 us at 1x4.
- Under AITER_MEGA_S1F_FALLBACK=mori, tpr 16384 (recv 65536) runs S1F when
  the pinned prefill is on: 2665.9 vs 2778.7 us/layer, 3 of 3 runs passed.

DSR1 EP4 unit bench, us/layer (mori -> S1F): 64 204.2->184.5,
128 207.6->186.7, 256 231.1->205.5, 512 291.6->251.6, 1024 376.2->338.1,
1536 425.7->419.6, 2048 513.8->492.2, 4096 845.3->777.5,
8192 1493.5->1384.4, 16384 2778.7->2665.9. Accuracy passes at every point
and logits_diff matches the previous commit bit for bit.
XingerZhu added a commit that referenced this pull request Nov 25, 2026
…1 tpr

Port the pinned Flash/DSR1 EP4 prefill path from #7410 onto the DSR1 S1F
branch and keep the mori and small-tile paths at their previous speed.

From #7410:
- s1f_prefill_config(): M256/N256/K256 2x2 GEMM1 (3 buffers) and GEMM2
  (4 buffers) with A preshuffle for recv >= 16384 on (5120, 2304, 96, 6, 4)
  and (7168, 2048, 65, 9, 4).
- Stage-1 kernel: row-major MMA reuse, paired CTAs (pair_cluster_n=2),
  8-slot ring, silu16, quant_payload_preshuffled APRE output for GEMM2.
- GEMM2: fixed_n_ep 4096-worker EP scatter.
- Combine: dense BF16 slot pitch, 128-thread reduce, route masking from
  the source topk IDs.

On top of #7410:
- AITER_FLYDSL_EXPLICIT_VGPR_PARTITION now defaults to 1 and only gates the
  pinned prefill specializations. M256 4-wave tiles always take the fixed
  VGPR partition, as on main; small tiles no longer take it (tpr 256 S1F was
  241 us/layer with it, 205.5 without).
- Clustered 1x4/2x2 APRE GEMMs keep main's grouped DS schedule and
  ksl0_fence_mma tail instead of the native schedule, and compact M
  variants are limited to cluster_n <= 2 (mori GEMM2 at tpr 4096: 300.7 ->
  291.5 us).
- The direct BF16 combine reduce picks a block that divides one token's
  lanes (448 threads for hidden 7168), so route IDs load at a uniform
  address (mori combine at tpr 4096: 57.1 -> 44.9 us).
- DSR1 tile-256 grouped rows use cluster_m=1. With the clusters now formed
  under graph capture, 4x4 GEMM1 at tpr 16384 took 980 us vs 780 us at 1x4.
- Under AITER_MEGA_S1F_FALLBACK=mori, tpr 16384 (recv 65536) runs S1F when
  the pinned prefill is on: 2665.9 vs 2778.7 us/layer, 3 of 3 runs passed.

DSR1 EP4 unit bench, us/layer (mori -> S1F): 64 204.2->184.5,
128 207.6->186.7, 256 231.1->205.5, 512 291.6->251.6, 1024 376.2->338.1,
1536 425.7->419.6, 2048 513.8->492.2, 4096 845.3->777.5,
8192 1493.5->1384.4, 16384 2778.7->2665.9. Accuracy passes at every point
and logits_diff matches the previous commit bit for bit.

This branch has not been deployed

No deployments
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.

8 participants