Repository navigation
[FlyDSL] [Perf] A16W4 MoE: optional fused bf16 shared expert - #7773
Conversation
The moe_2stage_a16wmix gemm1/gemm2 kernels can now compute a dense bf16
shared expert in the same launches as the routed experts. The shared
tiles take the first program ids. The routed tiles and the sort do not
change. Without shared weights, the kernels, names and launch signatures
do not change.
- gemm1/gemm2: dense=True body mode and *_shared kernel variants
(compile parameters shared_tile_n/_m/_k and shared_k_wave).
- moe_kernels: parse the "_sh{M}x{N}x{K}[kw{W}]" kernel-name suffix;
forward shared_w1_bf16/shared_w2_bf16/shared_inter_bf16.
- fused_moe: the FlyDSL stage wrappers forward the shared tensors.
- MiniMax-M3.1 TP4 A16W4 rows: shared tiles on the 32-256 rows and
measured exact-width decode rows (40-168).
- Tests in op_tests/test_flydsl_moe_a16wfp4.py.
Signed-off-by: Vinayak Gokhale <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
…nputs On gfx950 at TP4, a pure-decode step of MiniMax-M3.1 runs each MoE layer's post-attention chain as one persistent FlyDSL launch (glue/kernel.py): the all-reduce of the o_proj partial (a reduce-scatter plus all-gather over Lamport inboxes in a peer buffer), the residual add, the Gemma RMSNorm and its MXFP8 copy, the router (fp32 weights as exact bf16x3 MFMAs), the biased top-4 x routed scale and AITER's moe_sorting outputs with a zeroed moe_buf. AITER's A16W4 gemm1 / gemm2 then run on that sort with the tuned row for exactly the step's rows, with the shared expert inside them when the installed AITER takes a dense bf16 shared expert (ROCm/aiter#7773, feature-detected); otherwise the shared expert runs as separate MXFP8 GEMMs. The all-reduce after the MoE is the stock one (TODO in decode.py: AITER's fused all-reduce + norm + MXFP8 quant, once it lands). No env vars. The glue is on when it applies: ROCm gfx950, TP 4, DP/PP 1, no EP/LoRA, the M3.1 config, a pure-decode step (eager or FULL graph, not DBO) whose row count is a compiled width (24-192, multiples of 8: DSpark 7 at 3-24 requests) and whose tuned A16W4 row takes the glue's sort; every other step runs the stock path. The setup runs at the first eager forward on every rank and is agreed across ranks; an epoch reset runs between steps before the kernel's tag space wraps. Sync is the M3 monokernel's (specialized_decode/mono/sync.py: bounded waits, the error record, fail-stop) on deepseek_v41 mono/common (PeerBuffer, plan, ops). New shared helpers there: - specialized_decode/mono/lamport.py: the Lamport (sentinel) inbox transport: arm, sentinel test and rewrite, bounded spin / probe / vector and triple polls. - sync.Mailbox(lazy_errors=True): polls read the error word only after a first miss; put_triple(plain=True). - mono/common/ops.buf_load / buf_store: buffer ops at a raw address (the glue no longer imports AITER's buffer_ops). Measured on MI355X, TP4, glue vs the stock all-reduce .. sort chain (us a layer, CUDA graph, max over ranks): 24 rows 19.6 vs 26.3, 64 22.6 vs 37.4, 96 27.6 vs 42.4, 128 31.0 vs 47.0, 160 36.9 vs 50.6, 192 41.4 vs 56.0. Outputs: residual, MXFP8 rows and scales, top-k sets and the sort bitwise equal to the stock ops. Refactor check against the kernel the AgentX runs used (same process, us a launch, max over ranks, graph replay): 24 rows 19.6 vs 17.9, 64 22.6 vs 21.7, 96 27.6 vs 28.2, 128 31.0 vs 31.2, 160 36.9 vs 36.1, 192 41.4 vs 40.7; the compiled ISA of both is the same instruction stream at every width (only some SGPR numbers differ), so the gaps are run-to-run noise. Protocol test (mixed widths in graphs, a 57-launch step replayed, epoch reset, forced fault + reset): 90 checks pass. Signed-off-by: Vinayak Gokhale <[email protected]>
The dense shared expert of the moe_2stage_a16wmix gemm1/gemm2 kernels can
now read MXFP8 weights (fp8 e4m3 codes + E8M0 1x32 scales) instead of a
bf16 copy, at half the weight bytes. The format follows the dtype of the
shared weight the caller passes; bf16 weights run as before.
- utils.make_b_loader: w_dtype "fp8". Codes in the shuffle_weight (16, 16)
layout (two dwordx4 per lane and 128-K block, whole-line runs per load
instruction), scales in the shuffle_scale layout (the routed MXFP4 scale
path, reused). The codes are scaled to bf16 in registers right before the
MFMA (v_cvt_scalef32_pk_bf16_fp8). An e4m3 value times a power of two is a
bf16 value and the K order and MFMA sequence are the bf16 path's, so the
output is bitwise that of the bf16 weights. gfx950 only.
- gemm1/gemm2: compile parameter shared_w_dtype ("bf16" or "fp8", kernel
name suffix _mxfp8); the shared kernels take a scale pointer. gemm2
asserts a power-of-two shared_tile_k (its A-LDS swizzle needs it).
- API: shared_w1 / shared_w1_scale and shared_w2 / shared_w2_scale
(fused_moe naming) replace shared_w1_bf16 / shared_w2_bf16 in the FlyDSL
stage wrappers and moe_kernels.
- MiniMax-M3.1 TP4 rows: shared tiles retuned for MXFP8 at the same shared
k_wave (so bitwise to the bf16 path): g1 rows 32, 48-56, 72-168, g2 rows
72-80.
- Tests: MXFP8 shared vs bf16 shared bitwise at every M3.1 TP4 decode row
(1-256; stage 1 and stage-2 shared tiles), MXFP8 in the shared-expert
correctness tests and the fused_moe_2stages test, argument checks.
MI355X, M3.1 TP4 rows, skewed routing, cold weights, CUDA graph, us per
layer (gemm1 + gemm2), bf16 shared at the previous tiles -> MXFP8 shared:
8 46.1 -> 43.0, 16 68.6 -> 60.2, 32 89.5 -> 86.1, 64 118.7 -> 117.1,
128 160.4 -> 152.4, 160 178.0 -> 161.4, 256 202.9 -> 195.9.
Signed-off-by: Vinayak Gokhale <[email protected]>
Keeps this branch's MiniMax-M3.1 A16W4 rows at 8, 16, 32, 64, 128 and 256 tokens over #7414's: the fused shared expert needs the atomic stage-2 epilogue, and these rows carry the shared tiles measured with it. Signed-off-by: Vinayak Gokhale <[email protected]>
| gfx950,256,144,6144,768,128,4,ActivationType.Swiglu,torch.bfloat16,torch.bfloat16,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,99.4289,flydsl_moe1_abf16_wfp4_bf16_t16x192x128_w2_xcd1_sh16x32x512kw2,0.0%,60.0498,flydsl_moe2_abf16_wfp4_bf16_t16x256x128_atomic_bnt2_sh64x64x128,4.3%,159.4787,0,0,0,102.25,11383.83, | ||
| gfx950,256,152,6144,768,128,4,ActivationType.Swiglu,torch.bfloat16,torch.bfloat16,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,99.4921,flydsl_moe1_abf16_wfp4_bf16_t16x192x128_w2_xcd1_sh16x32x512kw2,0.0%,59.9655,flydsl_moe2_abf16_wfp4_bf16_t16x256x128_atomic_bnt2_sh64x64x128,4.3%,159.4576,0,0,0,107.95,11386.57, | ||
| gfx950,256,160,6144,768,128,4,ActivationType.Swiglu,torch.bfloat16,torch.bfloat16,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,99.4203,flydsl_moe1_abf16_wfp4_bf16_t16x192x128_xcd1_sh16x32x512kw2,0.0%,59.775,flydsl_moe2_abf16_wfp4_bf16_t16x256x128_atomic_bnt2_xcd4_sh64x64x128,4.3%,159.1953,0,0,0,113.82,11406.56, | ||
| gfx950,256,168,6144,768,128,4,ActivationType.Swiglu,torch.bfloat16,torch.bfloat16,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,99.7693,flydsl_moe1_abf16_wfp4_bf16_t16x192x128_w2_xcd4_sh64x32x128kw2,0.0%,60.4182,flydsl_moe2_abf16_wfp4_bf16_t16x256x128_atomic_bnt2_sh64x64x128,4.3%,160.1875,0,0,0,118.77,11337.14, |
There was a problem hiding this comment.
The newly added tokens:40, 48, 56, 72, 80, 112, 136, 144, 152, 160, and 168—cannot enter fused_moe. In aiter/fused_moe.py:2707-2715, get_padded_M rounds the number of tokens up to the next power of 2 (nextPow2).
There was a problem hiding this comment.
So if we go through fused_moe what you say is true.
But get_2stage_cfgs does not enforce padding up to nextPow2. In vllm, we have removed topk and sort into custom kernel and call stage1 and 2 from AITER directly. That goes through get_2stage_cfgs directly. So when there are 40 rows, it will return config for 40 not 64 as it won't do the padding.
…idth - a16w4_default_shared_tile_n raises ValueError when N is not a positive multiple of step, and starts its search at N or below. Before, the search did not stop for such an N, or when tile_n / 4 was above N. - The shared-expert builds of gemm1 and gemm2 compare their LDS size with get_lds_capacity_bytes and raise NotImplementedError above it, as the gemm2 reuse_lds build does. The shipped _sh tiles use at most 64 KB (gemm1) and 32 KB (gemm2). - New tests: test_default_shared_tile_n_bounds, test_stage1_shared_rejects_oversized_lds and test_stage2_shared_rejects_oversized_lds. Signed-off-by: Vinayak Gokhale <[email protected]>
op_tests/test_fhmoe.py::test_heterogeneous_moe_uses_a_separate_custom_op_schema keeps FHMoE's argument names (shared_w1, shared_w2, shared_w1_scale, shared_w2_scale, shared_expert_id, clamp_shared) off the ordinary MoE APIs, so that the heterogeneous MoE keeps its own custom-op schema. The A16W4 shared expert used shared_w1 / shared_w1_scale / shared_w2 / shared_w2_scale on flydsl_moe_stage1/2 and the FlyDSL stage wrappers, and that test failed in CI. They are now fused_shared_w1, fused_shared_w1_scale, fused_shared_w2 and fused_shared_w2_scale (the shared expert fused into the routed launches); shared_inter_bf16 and shared_tile do not change. FHMoE's own arguments in fused_moe do not change. Signed-off-by: Vinayak Gokhale <[email protected]>
| gfx950,256,64,6144,768,128,4,ActivationType.Swiglu,torch.bfloat16,torch.bfloat16,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,92.4968,flydsl_moe1_abf16_wfp4_bf16_t16x32x128_w2_xcd1_kw4,,47.7397,flydsl_moe2_abf16_wfp4_bf16_t16x256x256_reduce_bnt2_xcd4_persist,0.45%,144.4385,0,0,0,50.18,6283.25, | ||
| gfx950,256,128,6144,768,128,4,ActivationType.Swiglu,torch.bfloat16,torch.bfloat16,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,106.5570,flydsl_moe1_abf16_wfp4_bf16_t16x32x128_w2_kw4,,54.8963,flydsl_moe2_abf16_wfp4_bf16_t16x256x256_reduce_bnt2_xcd4_persist,0.41%,162.5288,0,0,0,89.19,5593.57, | ||
| gfx950,256,256,6144,768,128,4,ActivationType.Swiglu,torch.bfloat16,torch.bfloat16,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,113.1458,flydsl_moe1_abf16_wfp4_bf16_t16x32x128_w2_xcd1_kw4,0.0%,62.2072,flydsl_moe2_abf16_wfp4_bf16_t16x256x128_atomic_bnt2,4.4%,175.353,0,0,0,165.33,10368.97, | ||
| gfx950,256,8,6144,768,128,4,ActivationType.Swiglu,torch.bfloat16,torch.bfloat16,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,29.1073,flydsl_moe1_abf16_wfp4_bf16_t16x32x128_w4_xcd1_kw4,0.0%,19.54,flydsl_moe2_abf16_wfp4_bf16_t16x256x128_atomic_xcd4,4.3%,48.6473,0,0,0,18.62,37250.49, |
There was a problem hiding this comment.
These rows (tokens 8–128) are the pre-#7414 #6942 rows, timings included, so this reverts #7414's real-routing retune for all callers, not just shared-expert ones (#7414 measured them 5–13% slower per layer, 64 tokens the worst). Only stage 2 at 8/32/64/128 needs to move from reduce to atomic. Could you restore #7414's stage-1 kernels and its token-16 row (already atomic+persist), and swap only those stage-2 kernels for atomic variants, re-measured with real routing? cc @Fangzhou-Ai
There was a problem hiding this comment.
Thanks for the reviewing @coderfeli , yes the #7414 is turned on real workload, though it's slower on the paper but shows observable advantages under our workload. We need to be cautious to revert that tuning before benchmark under production usages.
There was a problem hiding this comment.
Ok I made the change. The 8-128 rows case uses #7414's kernels again.
I asked my agent to measure with real routing: top-4 IDs of all 57 layers dumped from an AgentX c=16 run.
us per call, #7414 → this PR without the shared expert:
39.4 → 37.1 (8),
56.1 → 56.1 (16),
80.1 → 78.2 (32),
114.5 → 109.8 (64),
142.7 → 136.9 (128).
So the atomic epilogue is also faster for callers without the shared expert. With the fused shared expert: 37.5 / 58.0 / 89.0 / 112.8 / 142.6.
…ge 2 When main was merged in, the MiniMax-M3.1 TP4 A16W4 rows at 8-128 tokens went back to #6942's kernels and undid #7414's retune for every caller. They now use #7414's stage-1 kernels and its 16-token row. Only stage 2 at 8, 32, 64 and 128 tokens changes from the reduce to the atomic epilogue (the fused shared expert needs it), and the rows carry shared-expert tiles (_sh), which do not change the routed kernels. Real routing (top-4 ids of all 57 MoE layers from an AgentX c16 replay, 114 layer routings per token count, cold weights, MI355X), wall us a call: tokens #7414 this, routed only this + shared expert before + shared 8 39.4 37.1 37.5 39.6 16 56.1 56.1 58.0 61.5 32 80.1 78.2 89.0 84.9 64 114.5 109.8 112.8 120.3 128 142.7 136.9 142.6 150.7 CSV values: us1 = #7414's (the same stage-1 kernel); us2 and us = #7414's plus the measured change of the whole op (uniform routing, same process); err2 measured against the FP32 reference. Signed-off-by: Vinayak Gokhale <[email protected]>
…942-fp8-mfma Conflicts with ROCm#7773 (A16W4 fused bf16 shared expert), resolved as the union of both sides: - make_b_loader: ROCm#7773 adds MXFP8 W as `_is_fp8 = w_dtype == "fp8"`, the name this branch used for fp8 A. The fp8-A flag is now `_a_fp8`, so the MXFP8 shared weight takes the e8m0 `load_b_scale` path and the fp8 A path keeps the residual-table scale and LUT decode. - gemm1/gemm2 bodies and builders take both `dense` / `shared_*` and `a_dtype` / `arg_a_scale` / `arg_sref`; the shared-expert prologue asserts `a_dtype == "bf16"` (it has no A-scale or s_ref arguments), and the stage-1/2 dispatch keeps the fp8 mode off when a shared expert is fused. - the wrappers pass the fp8 pointers before the output and the shared pointers after it, matching each kernel's launch signature. Compile-only ISA is unchanged against both parents: 21 gfx942 fp8 kernels vs this branch, 21 gfx942 bf16 kernels vs main, and 6 gfx950 routed/shared (bf16, MXFP8) gemm1/gemm2 kernels vs main. Co-authored-by: MHYangAMD <[email protected]>
…942-fp8-mfma Conflicts with ROCm#7773 (A16W4 fused bf16 shared expert), resolved as the union of both sides: - make_b_loader: ROCm#7773 adds MXFP8 W as `_is_fp8 = w_dtype == "fp8"`, the name this branch used for fp8 A. The fp8-A flag is now `_a_fp8`, so the MXFP8 shared weight takes the e8m0 `load_b_scale` path and the fp8 A path keeps the residual-table scale and LUT decode. - gemm1/gemm2 bodies and builders take both `dense` / `shared_*` and `a_dtype` / `arg_a_scale` / `arg_sref`; the shared-expert prologue asserts `a_dtype == "bf16"` (it has no A-scale or s_ref arguments), and the stage-1/2 dispatch keeps the fp8 mode off when a shared expert is fused. - the wrappers pass the fp8 pointers before the output and the shared pointers after it, matching each kernel's launch signature. Compile-only ISA is unchanged against both parents: 21 gfx942 fp8 kernels vs this branch, 21 gfx942 bf16 kernels vs main, and 6 gfx950 routed/shared (bf16, MXFP8) gemm1/gemm2 kernels vs main.
…s pending A/B The 3 rows this branch changes in minimax_m3_fp4_tuned_fmoe.csv (tokens 32, 64 at inter_dim 768 and token 8192 at inter_dim 384) were tuned before the FlyDSL MoE kernel changes in ROCm#7769 and ROCm#7773, and tokens 32/64 raise the stage-2 error ratio from 1.2% to 4.8-4.9%. Restore origin/main's rows; each is re-applied only if a same-session A/B on current main shows it is faster at a comparable error ratio. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Bishwo Adhikari <[email protected]>
Resolve conflicts with the fused shared expert (ROCm#7773), the MXFP4 route-output intermediate (ROCm#7706) and the scatter LDS pairs option: keep the per-kernel-name FP8 route-out selection, with the MXFP4 intermediate as the fallback when FP8 is not selected. Co-authored-by: Claude Opus 5.5 <[email protected]> Signed-off-by: Carl Persson <[email protected]>
Summary
Allows the A16W4 MoE kernels (
moe_2stage_a16wmixgemm1/gemm2) to add a dense bf16 shared expert inside the routed launches. The shared expert then needs no side stream. FHMoE supports this, but has separate topk/routing kernels while this assumes that information is available already. This allows for a separately fused topk/routing kernel.Changes
flydsl_moe_stage1/2takefused_shared_w1/fused_shared_w1_scale(stage 1),fused_shared_w2/fused_shared_w2_scale(stage 2) andshared_inter_bf16.fused_moe_2stagespasses them in_stage1_extra_args/_stage2_extra_args.(16, 16)-preshuffled, E8M0 scales in theshuffle_scalelayout) or bf16 (no scales). The kernels convert MXFP8 to bf16 in registers before the MFMA, so both formats give the same output; MXFP8 reads half the bytes (M3.1 TP4: 14.6 MB instead of 28.3 MB a layer)._sh{M}x{N}x{K}[kw{W}]sets the shared tile.fused_moedoes not change: itsshared_w1/shared_w2already select FHMoE (FP8 shared expert).Compatibility
Without shared weights, a
_shrow builds the same routed kernel (same compile key, name and launch).fused_moepads M to a power of 2, so only exact-M callers use rows 40-168.Results
MI355X, MiniMax-M3.1 TP4 A16W4 MoE at 8-128 tokens, real routing (top-4 ids of all 57 MoE layers from an AgentX c16 replay, 114 layer routings per token count, cold weights), wall us per call:
The atomic stage 2 is also faster without the shared expert. At 32 tokens #7414's stage-1 kernel hides the shared expert less well (+11 us over routed only).
Earlier measurement, on this PR's previous rows (#6942's routed kernels), not repeated on the current rows: kernel time change in us vs. routed A16W4 + separate MXFP8 shared expert (cold cache, skewed routing):
Tests
op_tests/test_flydsl_moe_a16wfp4.py: FP32 reference, routed rows bitwise unchanged,_shrows without shared weights, M3.1 rows throughfused_moe.test_flydsl_moe_a16wfp4.pytests: 234 pass, 1 fail, 35 skip on both. The failure istest_stage2_lds_variants_have_distinct_cache_keys(ImportError in the FlyDSL 0.5.0 wheel).flydsl_tests/test_gemm2_valid_token_count.pyandtest_moe_mxfp4_inter_dim_align.py: 5/5 pass on both.test_moe_2stage.py --csv-filter _sh: the 14 runnable_shrows pass strict accuracy with no shared weights (logits_diff < 8.0e-4).Limitations
NotImplementedErrorwhen shared weights are given.PR Self-Review
Reviewed revision
c002ffa
Behavior and intent
The FlyDSL A16W4 MoE kernels (
moe_2stage_a16wmixgemm1 and gemm2) can now add a dense shared expert in the routed launches, when the caller gives its weights (MXFP8 or bf16) andshared_inter_bf16. Before, the shared expert ran as separate MXFP8 GEMMs on a side stream, and HIP graph replay does not hide that side branch well. In the launches, a MiniMax-M3.1 decode layer is 6 to 16 us faster at M 24 to 192. Without shared weights, the kernels do not change.Validation and unverified scope
pytest op_tests/test_flydsl_moe_a16wfp4.py -k "shared or oversized_lds": 39 passed, andop_tests/test_moe_2stage.py --no-legacy --csv-filter _sh: all 16 M3.1 rows (8-168 tokens) pass the strict accuracy check (logits_diff < 1e-3). The CSV values of the changed rows: us1 = [Config] [Tuning][gfx950] Retune MiniMax-M3.1 TP4 A16W4 decode rows (E=128, top-4) for 8/16/32/64/128 tokens #7414's (same stage-1 kernel), us2 / us = [Config] [Tuning][gfx950] Retune MiniMax-M3.1 TP4 A16W4 decode rows (E=128, top-4) for 8/16/32/64/128 tokens #7414's plus the change of the whole op measured in one process (uniform routing), err2 measured.fused_shared_w*:op_tests/test_fhmoe.py::test_heterogeneous_moe_uses_a_separate_custom_op_schemakeeps FHMoE'sshared_w*names off the ordinary MoE APIs and failed in CI), on MI355X: that test passes, andpytest op_tests/test_flydsl_moe_a16wfp4.py -k "shared or oversized_lds": 39 passed.ValueErrorfor an N that is not a positive multiple of its step and ends its search at N; the shared-expert builds of gemm1 and gemm2 raiseNotImplementedErrorabove the LDS capacity),pytest op_tests/test_flydsl_moe_a16wfp4.py -k "shared or oversized_lds"on MI355X: 39 passed. The shipped_shtiles use at most 64 KB of LDS (gemm1) and 32 KB (gemm2).pytest op_tests/test_flydsl_moe_a16wfp4.py -k sharedon MI355X: 34 passed. The MXFP8 shared intermediate and stage-2 shared tiles are bitwise equal to the bf16 path at the 20 M3.1 TP4 rows (1 to 256).pytest op_tests/test_flydsl_moe_a16wfp4.pyon main (MI355X, FlyDSL 0.5.0): the 12 new shared-expert tests pass. The other tests in the file: 234 passed, 1 failed, 35 skipped, the same as unmodified main. The failure is an ImportError in the FlyDSL 0.5.0 wheel.test_moe_2stage.py --csv-filter _sh: the 14 runnable_shrows pass the strict accuracy check without shared weights.NotImplementedErrorwhen shared weights are given), and stage-2 epilogues other than the atomic epilogue (not supported).PR-specific question
The rows are in
minimax_m3_a16w4_tuned_fmoe.csv: gfx950 with 256 CUs, MiniMax-M3.1 TP4 A16W4 (E=128, top-4, hidden 6144, inter 768). At 8-128 tokens the routed kernels are #7414's; only stage 2 at 8, 32, 64 and 128 tokens uses the atomic epilogue instead of reduce, which is 2-6 us faster per call also without the shared expert (real routing). The rows use the_sh{M}x{N}x{K}kernel-name suffix at 8 to 256 tokens, and there are exact-width rows at 40 to 168 tokens.fused_moepads M to a power of 2, so only callers that pass an exact M use the exact-width rows. Without shared weights, a_shrow builds the same routed kernel (same compile key, name and launch), and a test checks this. Rows of other models do not change.Changed op tests
op_tests/test_flydsl_moe_a16wfp4.py: new shared-expert tests. They compare against an fp32 reference, check that the routed rows stay bitwise unchanged, run_shrows without shared weights, and run the M3.1 rows throughfused_moe. New CPU tests check the default shared tile width and that an oversized shared tile raises in gemm1 and gemm2. No other test covers the shared-expert path.