Repository navigation
[FlyDSL] [MoE] Fit the gfx1250 grouped GEMM k-tile to K, and refuse one that does not divide it - #6706
[FlyDSL] [MoE] Fit the gfx1250 grouped GEMM k-tile to K, and refuse one that does not divide it#6706gbyu-amd wants to merge 1 commit into
Conversation
…e that does not divide it The TDM grouped GEMM runs K // tile_k k-tiles and has no tail, so a tile that does not divide K silently drops the rest of it. Every tuned grouped row divides its K, but the defaults a shape without a row takes (tile_k = 256 for both stages) do not for a tensor-parallel expert slice: Kimi-K3 at TP8 has inter_dim = 3072 / 8 = 384, so stage 2 summed 256 of its 384 K. On aiter's own grouped check (a4w4, Situv2, 896 experts, top-16, model_dim 3584, inter_dim 384) that is logits_diff 0.195 and rel_l2 0.571 against the fp32 reference; with tile_k2 = 128 it is 3.6e-6 and 0.0027, as for inter_dim 512 or 3072. Served, the model lost 7 points of GSM8K (0.8923 against 0.9575). _grouped_a8w4_tdm_moe now narrows each stage's tile to the widest of 512, 256 and 128 that divides its K, and flydsl_grouped_gemm_a8w4_masked raises for a tile that does not. Co-authored-by: Cursor <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
|
This PR is just a WA. Close it now since main has fixed the issue. |
Problem
The gfx1250 TDM grouped GEMM behind
_grouped_a8w4_tdm_moerunsK // tile_kk-tiles and has no tail, so atile_kthat does not divide K silently drops the rest of K.Every tuned grouped row divides its K. A shape without a tuned row takes the defaults,
tile_k = 256for both stages, and those do not divide a tensor-parallel expert slice: Kimi-K3 at TP8 hasinter_dim = 3072 / 8 = 384, so stage 2 sums only 256 of its 384 K. Nothing raises; the MoE output is just wrong.Fix
_grouped_a8w4_tdm_moenarrows each stage's tile to the widest oftile_k, 512, 256 and 128 (never wider than the requested one) that divides that stage's K, and logs when it changes it. Tuned rows already divide their K, so they are unchanged.flydsl_grouped_gemm_a8w4_maskedraisesValueErrorfor atile_kthat does not divide K, instead of dropping the remainder.Validation
tile_k2 = 256; 3.6e-6 and 0.0027 with 128, the same as at inter_dim 512 or 3072.blackandruff(0.16.0) are clean.Notes