Repository navigation
[FlyDSL] MegaMoEV2 EP4 V4.1-Flash: fix the large-input scale-load fault, faster decode (into #7788) - #7867
Open
zhiding512 wants to merge 61 commits into
Open
[FlyDSL] MegaMoEV2 EP4 V4.1-Flash: fix the large-input scale-load fault, faster decode (into #7788)#7867zhiding512 wants to merge 61 commits into
zhiding512 wants to merge 61 commits into
Conversation
…config mega_moe_fused_gemm.py carried private copies of helpers that already exist in gemm1/gemm2/gemm_util/mega_moe_config. Import those instead: _LdsF32View, scale_view, scale_mma_atoms, mma_one_j, _resolve_g2_knobs, _PACK, wait_lds_barrier, REFERENCE_EXPERTS_PER_RANK, _fixed_dispatch_cu. Remove expert_config_class/_scale_dispatch_cu: experts_per_rank is limited to <= 64, so both were identities that only widened the config cache key. Remove the unreferenced _spart_output_tile_index. Verified: gfx950 ISA of all 88 kernels built for MTPR 8192 (staged, small-M and large-M; ranks 0 and 7) is byte-identical to main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…M envs MegaMoEV2 had three routing systems: AITER_MEGA_SMALL_M with an explicit forward_small_m(max_tokens), AITER_MEGA_LARGE_M that sent every forward to the large-input kernel once built, and the staged path otherwise. Each had its own eligibility function (v2, small_m and large_m runtimes). The bundle plan now owns the routes: - fused_layout_supported()/small_m_cu_supported() in mega_moe_config are the single eligibility rule; MegaMoEV2 and both runtimes use them. - build_mega_moe_bundle_plan(small_m_mtprs=, large_m=) records the fused routes; capacities above the first small bank that covers the instance MTPR are unreachable and no longer built. - MegaMoEBundlePlan.route_for(max_tokens) picks small-input (smallest bank >= max_tokens), large-input (>= 513 rows, the measured crossover) or staged. forward(..., max_tokens=) takes the EP-wide row bound; without it the plan assumes the instance capacity, never the local row count, so all ranks take the same route. forward_prequant excludes the bf16-only small-input route. - Routes are built whenever the layout supports them (no env switches); small_m_mtprs=() / large_m_enabled=False leave one out. - forward_small_m and set_large_m_enabled stay as thin wrappers over the same selector; tests pin a route through _forward_route. - The weight attributes (_s1_w1, _s1_w1_scale, w2, w2_scale) are properties that rebind every route, and the small-input W2 dispatch table follows the current w2 per call, so callers that assign them directly per layer (ATOM) no longer leave the fused routes on the construction weights. - AITER_MEGA_MOE_BOUNDS_CHECK is read through envs; the AOT build drops its MTPR-8192 env hack and gets the fused kernels from the plan. Verified: gfx950 ISA and kernel set of the MTPR 8192 AOT build (88 kernels, ranks 0/7) byte-identical to main; tests/test_mega_moe_route_plan.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
forward(stream=s) ran prepare/Stage1/Stage2 on s but quantize (fixed-slot) and the staged combine on torch.cuda.current_stream(), so with s != current the combine could read the P2P input before Stage2 wrote it. An fx.Stream or raw handle also crashed in Stage2 (stream.cuda_stream). forward and forward_prequant now make the caller's stream current for the whole call, as the large-input route already did; torch_stream() moves to tensor_shim. test_mega_moe_v2 checks every route with a held-back caller stream for a torch stream, an fx.Stream and a raw handle. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tput arenas Each route owned a complete copy of the heavy per-call data: the staged op, the large-input runtime and every small-input bank allocated their own symmetric payload (activations, scales, route weights, source map) and their own GEMM1 output. An instance has one call in flight, and every route rewrites or masks this data before reading it and finishes reading it before its call's closing all-rank barrier, so one copy sized for the largest route serves all of them. Counters, epochs, ready flags and the combine buffers stay per route. - group_major_capacity() is the single capacity formula of a group-major op; GroupMajorPayloadArena allocates the shared symmetric payload and FlyDSLDispatchGroupMajorOp/FlyDSLDispatchCombineIntraNodeOp view it. - stage1_output_buffers() replaces three copies of the GEMM1 output/scale allocation and views a shared arena when given one. - MegaMoEV2 sizes both arenas from its plan's routes (staged, large-input, small-input banks) and passes them to the runtimes; a staged-only instance allocates exactly as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The large-input kernel was gated to instances of exactly 8192 tokens per rank. Nothing in its protocol or geometry depends on that capacity: the source-encoding (W*mt <= 2^24) and P2P/offset ABI checks that do bound it stay in place. LARGE_M_MTPRS now lists 1024..16384 and is the one place the capacity is gated (plan, runtime and fused selector read it). 32768 stays on the staged route: the large-input kernel is slower there (+11.7% E2E at 32768 uniform tokens per rank) and its route-major payload would need 10.5 GiB per GPU against the staged indexed payload's 1.75 GiB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… kernels The fused small-/large-input runtimes kept private copies of TileScheduler, ATileLoader, AS2RLoader, BWeightLoader, BScaleLoader, AScaleLoader and MfmaScaleGU. Use the gemm_util ones instead. The two options only the fused path needs become opt-in keywords whose defaults keep the staged code path: ATileLoader.for_tile(valid_rows_i32) clamps the tile descriptor so padding rows read back as zero, and BScaleLoader.load_step(cache_modifier) sets the B-scale cache policy. The fused kernels now build their GEMM1 weight, scale and routing descriptors with tensor_shim.ptr_buf_tensor (same base, alignment and max-size num_records as before) so the shared classes can index them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the fused copy of the SwiGLU + FP8 quant epilogue. The gemm_util one gains the three options the fused path needs, all off by default: out_cache_modifier (large-M stores with sc0|sc1 = 17 so GEMM2 on other CUs of the same kernel sees the GEMM1 output), a per-call store_cm override and valid_rows_i32, which clamps the tile output descriptor and drops padding-row output and scale stores. The fused kernels keep the 2-column store pass (evec=2) and now build their output descriptors with ptr_buf_tensor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the fused copies of do_tile and build_fused_gemm1 and move the lookahead K-loop do_tile_la next to gemm1.do_tile. build_fused_gemm1 gains rows_rsrc/lookahead (small-M runs do_tile_la, clamped to each tile's row count), out_cache_modifier (forwarded to the epilogue) and tile_zero, which makes the tail A ds_read offset opaque per tile so it is not hoisted and spilled (large-M). All default to the staged behaviour. do_tile's rows_rsrc argument is dropped: only do_tile_la was ever given one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the fused copies of issue_a_load_lds_dt and gemm2_compute_v2. The gemm2 versions gain the options the fused kernels use, defaulting to the staged behaviour: NW (CTA wave count; the 1-stage B path is now selected by a 64-column per-wave slab, BN // NW == 64, which is BN == 256 at NW=4), valid_rows (bounds the A tile descriptor to the tile's real rows) and early_b_load (1-stage path: issue the K-tile's B and A-scale loads before the barrier and the next A-tile DMA). The fused path now uses gemm2's padded B load (offset 0, then select zero) instead of load_at(mask=), whose out-of-range offset was not past num_records 0xFFFFFFFF and so read real memory. It was dead (has_pad is False in both fused kernels); load_at loses the mask argument. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mega_moe_fused_gemm.py still carried a second config system for the small- and large-input kernels: its own Stage1Config/Stage2Config/MegaMoEConfig (field subsets of mega_moe_config's), TOKEN_BUCKETS, nearest_token_bucket, SMALL_M_FIXED_SLOT_MAX_MTPR and a select_mega_moe_config that shadowed the staged selector's name. The fused kernels now use mega_moe_config's types. Their tuning rules move there unchanged as select_fused_config (small-input per-bucket fixed-slot configs, one large-input config per capacity); FUSED_TOKEN_BUCKETS keeps their bucket set (no 2-token variant), nearest_token_bucket takes the bucket set, and SMALL_M_MAX_MTPR is the one small-input bound. The file keeps only the buffer helpers of the fused dispatch/combine code (2107 -> 86 lines over the series). Verified: ISA of the MTPR 8192 AOT build (ranks 0/7) and of the MTPR 16384 build (rank 0) unchanged by this commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fixed-slot staged route and the large-input route quantized the input into freshly allocated tensors on every forward, so each call (and each captured graph) allocated. per_1x32_mx_quant takes an ``out`` pair; the fixed-slot route writes into the instance's existing quant buffers (only compact prepare used them) and the large-input runtime into its own, allocated once. quantize() still returns new tensors for callers that keep them across calls (forward_prequant). forward() now states the output contract: a view of the route's combine buffer, valid until the next call; slice_output=False returns the route's capacity rows, the rows past this rank's own undefined. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ffers The large-input runtime and each small-input bank still allocated their own symmetric combine input (8 * MTPR rows of 2*H bytes: 0.88 GiB per GPU at MTPR 8192, 1.75 GiB at 16384) and the large-input runtime its own quant buffers. Every route writes a peer's combine input only after that peer has entered the same call and reads its own before the call ends (with every launch on the caller's stream), so they view the staged op's buffers; the large-input route quantizes into the staged quant buffers. Combine outputs stay per route: they are the returned views. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups: - The small-input kernel's overrides (non-persistent NT GEMM2, 64-row tiles from bucket 256) live in mega_moe_config's _small_m_stage1/_small_m_stage2 instead of a second layer (small_m_config) in the runtime; the shape branches no supported fused layout reaches are gone. A golden test pins every fused launch config to its value before the move. - check_forward_inputs (weights.py) replaces the three per-entry input checks (MegaMoEV2 now also checks the shapes, as the small-input runtime did); combine_output() on the dispatch/combine op replaces three copies of the output view; stage2_p2p_row_nbytes moves to mega_moe_stage2 and replaces the inline row-size formulas in MegaMoEV2 and the large-input kernel. - Assigning w2_scale builds the small-input W2 dispatch table outside graph capture, so a capture right after a direct assignment finds it. - test_mega_moe_small_m compares against the staged route explicitly and checks the large-input route's epoch wrap through that route; docstrings and comments describe the shared arenas, forward_prequant's route set and the staged-only bench. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…EMM2 tiles The small- and large-input kernels carried their own copies of the GEMM2 -> P2P scatter epilogue. Keep the staged one in mega_moe_stage2 and give it the fused callers' knobs: NW (wave count), store_cm / fp8_store_cm (peer store cache policies), p2p_quant_type="dynamic" with fp8_rows, and elem_view_stores (address peer stores through store_at's element-stride view). Defaults reproduce the staged kernel; final ISA is byte-identical for all 88 MTPR 8192 kernels (ranks 0, 7) and 46 MTPR 16384 kernels (rank 0). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… P2P scatters p2p_scatter_epilog and the aligned-pair Stage2 scatter each inlined the same lane-group |max| reduction, leader E8M0 scale broadcast and FP8 packing. Move it into mega_moe_stage2._fp8_quant_1x32; group_lane / leader_gate keep the aligned-pair half-lane, active-gated leader. Final ISA is byte-identical (MTPR 8192 ranks 0/7: 88 kernels; MTPR 16384 rank 0: 46 kernels). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ent_i32 The large-input kernel kept its own copy of the tile-expected increment over an AddrBuffer; index a ptr_buf_tensor view with the dispatch helper instead. Final ISA is byte-identical (MTPR 8192 ranks 0/7: 88 kernels; MTPR 16384 rank 0: 46 kernels). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fused routes viewed the staged op's combine input, sized for the
instance MTPR. A small-input bank can exceed it (an MTPR-128 instance builds
the 256 bank), and construction failed ("the shared combine input is smaller
than this op needs"). MegaMoEV2 now allocates one combine input for the
largest capacity among its routes and every op, the staged one included,
views it; combine_input_numel() is the single sizing formula.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Paired 8-GPU timing (3x10 graph replays, ABBA against main) showed the large-input kernel 10-40% slower than the staged path below ~512 rows per rank (e.g. MTPR 8192, 1 row: 308.5 vs 194.4 us) and faster from 512 rows up. A call without the EP-wide row bound cannot tell the two apart, so it now keeps main's route for instances above the small-input capacities (the staged path); instances whose capacity fits a small-input bank still take it, as it is faster at every size. Callers that pass max_tokens get the large-input route from 513 rows per rank. test_mega_moe_v2 passes the instance capacity as max_tokens, so its staged and --expect-large-m runs keep their routes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
One line per instance (rank 0) names the staged layout and the fused routes the plan built, so a serving log shows which kernels a deployment can take. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without the EP-wide row bound a call now runs exactly main's route: the staged path, fixed-slot or compact by capacity. Instances whose capacity fits a small-input bank used to take it unhinted (e.g. a framework's MTPR-128 decode instance); the fused routes now need the caller's max_tokens, so callers that do not pass it see no change in kernels, numerics or speed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
SGLang (sgl-project/sglang#47065) drives the fused routes through main's interface: forward_small_m(max_tokens=) for decode steps, and set_large_m_enabled(True/False) followed by forward() without max_tokens for extend steps. With calls without max_tokens pinned to the staged route, set_large_m_enabled(True) no longer reached the large-input kernel. The switch is now three-state: never called, a call without max_tokens stays staged (unchanged default); True sends such calls to the large-input route, as on main; False keeps the large-input route out of every call. Calls with max_tokens still choose through route_for. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…shared GEMM code Port the shared parts of 28ee7fc ("Speed up the fused MegaMoE kernel for DeepSeek-V4.1 Flash on 4 GPUs") onto the deduplicated GEMM modules, every knob off by default: - gemm_util: srcmap-mapped A rows and scales (dedup_rows), inline-asm A operand reads, packed LDS A scales, and the fused evec 8 epilogue (valid rows, cache policy, short tiles, lean/fast-SiLU variants) next to the staged one, which stays as it was. - gemm1: row_map / plan_lookup / a_ahead in do_tile(_la), and the short, fold and mid tile runners of the large-input kernel. - gemm2: the BM64 1-stage knobs (uniform A copies, LDS A scales, folded tail rows) and their two copy helpers. - mega_moe_stage2.p2p_scatter_epilog: lane-fed row ids / peers, per-token completion counts, BF16 head tokens, staged scales, the lean FP8 / int8 route quantizer. - mega_moe_config: FusedStage1Knobs / FusedStage2Knobs on MegaMoEConfig instead of new Stage1Config / Stage2Config fields, so the staged configs and the fused config digest are unchanged. gfx950 ISA of EP8 V4-Pro a8w4 (MTPR 128/1024/8192/16384, ranks 0 and 7, 280 kernels) is byte-identical to the previous commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Port the small-input part of 28ee7fc: the single kernel accepts the EP4 layout (4 ranks, 5120/2304, 96 experts a rank) and runs it with the measured tune -- one dispatch row per (token, destination), every CTA building its own plan, direct source flags for 1-2 producers, per-token completion counts for 1-4 tokens, SGPR pointers, the lean GEMM1 epilogue and register-fed A rows, early GEMM2 CTAs at 512 tokens. The protocol state the commit changed for every layout stays EP8-neutral: the epoch step, the per-token counters and their reset, and the BF16 rows of the first tokens follow FusedStage1Knobs (direct_done, tok_counters, bf16_head_tokens), which only the EP4 tune sets; SmallMRuntime asserts that every bucket of a runtime agrees on them. The debug-only row_poll mode is not ported (it read environment variables at trace time and relied on combine-input rows the other routes now share). The token-row regions of dedup_rows live in the shared payload arena past the runtime's fixed slots (payload_capacity grows by world * mtpr rows on such a layout), so their u32 offsets are fixed instead of depending on where the symmetric heap put a separate allocation. fused_layout_supported() admits FUSED_LAYOUTS (EP8 V4-Pro, EP4 V4.1-Flash); large_m_mtprs_for() keeps the large-input route on EP8 only for now. select_fused_config() takes the layout. gfx950 ISA (AOT dry-run): - EP8 V4-Pro, MTPR 128/1024/8192/16384, ranks 0 and 7: 280/280 kernels byte-identical to the previous commit. - EP4 V4.1-Flash, MTPR 8192, ranks 0 and 3, against 28ee7fc: the 58 staged / quant / combine kernels are byte-identical; the 34 small-input kernels have the same instructions and resources, in a different order only (GEMM2 B loads through the shared gemm2 buffer view instead of the commit's element view; the t64x128 ones: the v_lshlrev move the branch already has on EP8). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… 8192 Port the large-input part of 28ee7fc: the persistent kernel runs the EP4 layout with the measured tune (8-12 payload producers per destination over 192 dispatch CUs, deduplicated token rows with arrival stamps, a parallel lean plan with tagged count words and bucketed pair order, presend, short / mid / folded GEMM1 tail tiles, XCD-affine grouped GEMM2 claims with early GEMM2 CTAs, staged row scales, LDS A scales, the lean epilogue with int8 route rows, and per-token combine waits). Every new kernel path sits behind a FusedStage1Knobs / FusedStage2Knobs flag that only _tune_v41_flash_ep4_large sets and that enters the kernel spec only when on, so EP8 compile keys and kernel names are unchanged. The spots where the commit changed the default path stay in their old form (the payload's peer-row loads keep their order when not hoisted, the combine's int8 scale sum exists only with route_i8). The epilogue changes went into the shared mega_moe_stage2.p2p_scatter_epilog in the previous commits; load_at takes its mask back for the new staged-scale reads. Host side: the bucketed pair order and the row-arrival / sent-row buffers are allocated only when the config uses them (on EP8 they keep their old sizes), and the staged-scale buffer is allocated at init, not in forward. large_m_mtprs_for() gives EP4 the capacity the tune was measured at (8192). gfx950 ISA (AOT dry-run): - EP8 V4-Pro, MTPR 128/1024/8192/16384, ranks 0 and 7: 280/280 kernels byte-identical to the previous commit. - EP4 V4.1-Flash, MTPR 8192, ranks 0 and 3, against 28ee7fc: same kernel set and names; staged kernels byte-identical; the large-input kernel has the same instructions and resources with one s_mul moved, and the small-input kernels as before. Loading GEMM2's B weights through load_at's element view (the commit's form) instead of the shared gemm2 buffer view makes every one of them byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ll-input tests - tests/test_mega_moe_route_plan.py: the fused layout gate admits EP4 V4.1-Flash (and no mix of the two shapes); large_m_mtprs_for() gives EP4 only 8192; every EP8 fused config keeps its fused knobs off, and the EP8 config digest is unchanged; a golden digest of the EP4 configs (checked field by field against 28ee7fc's small_m_config / select_mega_moe_config for 38 (mtpr, tokens) cases: no difference); every EP4 small-input bucket runs one launch protocol; EP4 dispatch CUs cover two expert waves; the dedup token rows fit in the payload arena below the u32 offset limit. - op_tests/multigpu_tests/test_mega_moe_small_m.py: --network v41_flash (run it on 4 ranks) and --check-time-acc, which checks every timed route and the large-input one against the fp32 reference at the timed count. - aiter/aot/flydsl/README.md: the EP4 AOT profile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eir own payload _build_route_arenas lets every route share one payload arena because each route finishes reading it before its call's closing all-rank barrier. The EP4 V4.1-Flash tune drops that barrier: the large-input combine waits only for this rank's tokens (comb_tok_wait) and the small-input tok_done buckets reduce a token once its own rows are counted. A rank can then leave and dispatch its next call (the small-input route has no launch handshake) into a peer that still runs GEMM1/GEMM2 on the shared arena: a large -> small or small 256 <-> small 512 switch overwrites rows, srcmap and weights the peer is reading. A runtime whose launch can end that way (LargeMRuntime / SmallMRuntime .ends_all_ranks) now keeps its own payload, as in 28ee7fc; the small-input runtimes also keep their own combine input, which their combine leaves poisoned for the first tokens (bf16_head_tokens), so the staged and large-input routes no longer read those rows. The large-input runtime keeps sharing the combine input (a peer writes it only after this rank entered the same call) and every route keeps sharing the rank-local GEMM1 output. EP8 reaches none of this: its fused runtimes still share every arena, and its allocations are unchanged. Host-only: no kernel changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…build production_jobs() built only the EP8 profiles, so every EP4 V4.1-Flash kernel (staged, small-input and large-input) compiled online on first use, and a cache-only run failed. Add the EP4 profile (world 4, epr 96, 5120/2304, a8w4) at the MTPRs of ATOM's instances: 128 (decode: staged + small-input 256), 8192 (prefill: staged + small-input + large-input) and 16384 (staged + small-input). An explicit --mtpr applies to it as well. The default build grows from 192 to 204 jobs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The pair order is rank-local, and a launch reads only the entries its own routes wrote (rows below this launch's per-expert counts), so the layer state slots share one copy. With bucket_pairs (EP4 V4.1-Flash) it holds total_experts x mtpr routes: 12.6 MB a slot at MTPR 8192, about 768 MB at the 61 slots of a DeepSeek model, now 12.6 MB. EP8 saves its 196 KB a slot as well. Host-only: no kernel changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…block_n A tok_done reducer waits until a token's counter reaches its valid routes x its own GEMM2 n-blocks, while every tok_done sender adds one per n-block of its own bucket. Ranks of a launch may pick different buckets, so the tok_done buckets must split model_dim alike; it held only because buckets 1 and 4 both use block_n 256. SmallMRuntime now asserts it, and the EP4 route-plan test checks it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A compact-dispatch producer walks every segment (expert, plus the fanout group)
of its destination. An empty segment still ran the chunk epilogue: s_waitcnt,
a CTA barrier, a system-scope release fence and an agent atomic on chunk_done
that it then reset to 0, all to publish nothing. At decode most of the 97
segments a destination has are empty, so producers spent most of their time
there (s_memrealtime probe, bs=1). Treat a zero-row segment as inactive; the
chunk_done counter ends where it would have (0).
EP4 MI355X, bench_deepseek_v41_mega_moe.py --inputs per-rank, us/layer vs the
tip (1d57a7c):
4 rounds rows 1: 142.0 -> 136.1 (0.959, 4/4) 2: 0.976 (4/4) 4: 0.987 (4/4)
8..512: 0.986..0.999 geomean 0.988
reversed 2 rows 1: 1/1.027 (2/2) geomean 1/1.0085
Prefill 1024/4096/16384 rows: 1.000/1.000/1.001.
Outputs bit-identical to the tip at 1..512 and 2048 rows, with --shared fused
and with --pad-rows 1; 2000 graph replays clean.
(Ported from plugin_poc ops/mega_moe 178f0aa.)
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
GEMM1 at 1..4 rows is K-step-latency bound: with --hidden 2560 (half the K steps) the tail from the last ready tile to the last Stage1 CTA fell from ~35 to ~21 us at bs=1. Buckets <= 4 ran the synchronous-A path, which loads the B scales inside each step and drains vmcnt(0) at its end, and bucket 1 (and bucket 2, which inherits bucket 1's base) kept B loads temporal. EP4 profile: bucket 1 uses non-temporal B (b_nt=3); buckets 2 and 4 use the bucket-8 geometry (tile_n 512, 8 waves, async A copy, A-major MFMA, b_nt=3). EP4 MI355X, bench_deepseek_v41_mega_moe.py --inputs per-rank, us/layer vs the tip (178f0aa), 4 interleaved rounds: rows 1 2 4 8 64 tip 137.1 178.3 205.4 268.0 472.9 this 129.8 172.2 200.2 267.8 471.8 B/A 0.947 0.966 0.975 0.999 0.998 (4/4, 4/4, 4/4, 3/4, 4/4) Reversed 2 rounds: 1/1.064, 1/1.043, 1/1.027 at 1/2/4 rows; 8..512 1.000+-0.002. Prefill 1024/4096/16384: 1.000/1.001/1.000. relL2 vs FP32 unchanged; --shared fused and --pad-rows 1 outputs bit-identical to the tip; 2000 graph replays clean. (Ported from plugin_poc ops/mega_moe 88c5b6f.) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
DeepSeek-V4.1-Flash at EP4 used 64-row GEMM1 sort tiles for the 256-token
bucket. At ATOM's 16384-token capacity, use 32-row tiles for that bucket
to reduce expert-row padding. Communication chunk size and GEMM2 block
size stay the same. The rule is scoped to this capacity and FP8 inputs;
the neighboring 512-token bucket did not benefit in the knob sweep.
EP4 on physical GPUs 4-7, a8w4, per-rank inputs, four layer weights per
graph replay, cache flush before replay. Three alternating process rounds
against integration tip 88c5b6f, after rebasing its tiny-batch tuning:
rows baseline candidate B/A
1 130.3 130.0 0.9976
2 167.5 168.3 1.0043
4 195.4 194.8 0.9969
8 264.7 264.3 0.9983
16 353.7 353.8 1.0003
32 421.3 421.2 0.9998
64 473.7 473.6 0.9998
128 498.4 497.1 0.9974
256 587.3 531.8 0.9055
512 653.2 653.8 1.0009
1024 894.5 894.6 1.0001
4096 2290.0 2286.6 0.9985
16384 8172.8 8113.6 0.9928
The 256-token bucket reduces latency by 9.5%, with all three rounds agreeing.
Other buckets are within noise. Before the rebase, six full-matrix rounds
against 178f0aa measured 0.9075 at 256 tokens (6/6 agreeing), and two
reversed-order rounds measured baseline/candidate = 1.0999.
Validation: normal outputs rechecked 40/40 bit-identical against 88c5b6f,
including FP32 reference checks at the changed 256-token case. The M32
change also passed fused-shared and padded inputs (108/108 dumps across
all three modes), with unchanged FP32 relL2, maximum 0.054206. Eager/graph
agreement and 2000 graph replays pass. Fourteen policy boundary and
wire-contract tests pass after rebase; ruff, black and package import pass.
(Ported from plugin_poc ops/mega_moe 16c3398.)
Co-Authored-By: Codex GPT-6 <[email protected]>
Prepare's owner CTA ran the compact plan on one wave: both 64-expert chunks of an EP4 rank (96 experts) back to back, then the remote row offsets. The other waves of the 8-wave CTA were idle. s_memrealtime probe at bs=1: plan loop ~13 us, offsets ~4 us, prepare ~44 us of a ~130 us layer. - Two 64-expert chunks are planned on waves 0 and 1 at once. Chunk 1 needs only chunk 0's padded-row total, which wave 0 hands over in LDS right after its scan; wave 1 returns its total, tile maximum and fanout-pair bases after draining its stores, and wave 0 publishes PLAN_READY as before. The prefix build moves to wave 6. Shapes with one chunk (EP8) keep the serial planner. - When the CTA has npes + 2 waves (EP4), waves 2.. derive the remote offsets during the plan instead of after it. - _initialize_section_ready takes the per-source counts the planner already holds instead of reloading them. Probe, bs=1: prepare 44 -> 34 us, last Stage1 CTA 99 -> 88 us. EP4 MI355X, bench_deepseek_v41_mega_moe.py --inputs per-rank, us/layer vs the tip (16c3398, rebased onto it), 4 interleaved rounds, every row 4/4: rows 1 2 4 8 16 32 64 128 256 512 tip 130.1 172.1 200.7 269.7 360.6 415.6 477.1 501.2 522.6 654.6 this 122.5 164.1 192.8 262.2 354.0 408.2 469.4 492.3 513.5 643.3 B/A 0.941 0.953 0.961 0.972 0.982 0.982 0.984 0.982 0.983 0.983 geomean 0.972. Before the rebase (vs 88c5b6f): geomean 0.974; reversed 2 rounds 1/1.027 (2/2 each). Prefill 1024/4096/16384: 0.988/1.003/0.997. Outputs bit-identical to the tip at 1..512 and 2048 rows, with --shared fused (97 experts per rank, also two chunks) and --pad-rows 1; 2000 replays clean. (Ported from plugin_poc ops/mega_moe 523fb5b.) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The EP4 V4.1-Flash small-input kernel at one token a rank runs ~108 GEMM1 tiles of 256 columns (about six experts with one m-tile each, 18 n-tiles apiece), so most of the 256 CUs stay idle while the busy ones stream W1 at ~40 GB/s each (~4.3 TB/s together; the first round of 256 tiles at two tokens streams ~6.7 TB/s). Halving the tile width doubles the CUs on W1. Measured with s_memrealtime stamps per tile: the K-loop is ~16-18 us of a ~47 us launch at one token. Bucket 2 had been folded into bucket 1 (FUSED_TOKEN_BUCKETS dropped it). It is now its own bucket with bucket 1's config and bucket 1's base tile width, so two-token launches run exactly what they ran before: at two tokens a loaded rank's tiles already outnumber the CTAs, and tile_n 128 costs +0.7% there. EP4 MI355X, bench_deepseek_v41_mega_moe.py --inputs per-rank, row-hint calling (tools/rowhint_shim.py), aiter-new environment, us/layer vs the tip (80a49ce), 4 interleaved rounds: rows 1 2 4 8 tip 49.1 82.3 110.5 162.5 this 45.4 82.4 110.3 162.5 B/A 0.925 1.000 0.999 1.000 (4/4, 2/4, 3/4, 2/4) Reversed 2 rounds: 1/1.081 at one token, 1/1.004 at two. Outputs bit-identical to the tip at 1, 2, 4, 8, 16 and 64 rows (the narrower tiles only repartition the columns), with --pad-rows 1 and --shared fused; 2000 graph replays clean. The staged and large-input routes are unchanged. (Ported from plugin_poc ops/mega_moe 1c6fa43.) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rank The fused store pass takes tile widths whose 8-column lane count does not divide the CTA (tile_n 384: 24 lanes a row, 10 rows a pass, a partial last pass): spare lanes and rows past the tile are masked. Buckets 2, 32 and 64 use 384-column GEMM1 tiles (12 n-tiles); bucket 32's GEMM2 takes block_n 256. 6 rounds against 1c6fa43 (row hint, per-rank): 2/32/48/64 rows 0.973/0.966/0.973/0.974, all 6/6; 1-512 otherwise 0.996-1.001; geomean 0.990. Decode, pad and fused outputs bit-exact. (Ported from plugin_poc ops/mega_moe 7e56ff7.) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Use GEMM1 M32/N256 and GEMM2 M32 for the V4.1-Flash EP4 small-input
256-row bucket in both capacities 256 and 512. This reduces expert-row
padding while retaining the 512-row bucket's M64/N128 geometry and the
integrated 1/2/32/64-row tuning.
EP4 a8w4, GPUs 0-3, hidden 5120, inter 2304, 96 experts/rank,
capacity 16384, per-rank inputs, four layer weights and cache flushing.
Against integration tip 7e56ff7, three alternating rounds:
rows/rank tip us candidate us ratio
1 45.5 45.3 0.9964
2 80.5 80.4 0.9989
4 110.7 110.6 0.9994
8 162.7 162.3 0.9980
16 223.8 222.8 0.9954
32 290.9 291.1 1.0007
64 331.4 330.7 0.9982
128 342.1 342.3 1.0005
256 401.1 359.5 0.8964
512 487.8 487.6 0.9996
1024 880.5 877.7 0.9968
2048 1378.0 1376.5 0.9989
4096 2328.4 2324.3 0.9982
8192 4134.2 4133.7 0.9999
16384 8072.5 8107.6 1.0043
At 256 rows latency falls 10.36% with 3/3 rounds
agreeing. Other decode and staged prefill points remain within 0.5%.
Decode geomean is 0.98784; staged prefill is 0.99963.
Two reversed rounds confirm the 256-row gain (base/candidate
1.11837). The guard discarded a disturbed prefill attempt
and reran it; the table uses only accepted measurements.
Validation on the rebased snapshots: 148/148 outputs bit-exact across
normal, shared-expert, padded, uneven and idle-rank inputs. Maximum
FP32 relL2 is 0.0469904 / 0.0542057 / 0.0470877 for normal/shared/pad,
unchanged from the baseline. Both 64 and 256 rows completed 2000 graph
replays. All 23 CPU configuration tests, ruff, black and import checks
passed.
Decode above uses the row-hint small-input route; prefill exercises
the staged/no-hint regression floor. LargeM code and selection are
unchanged. The pre-existing upstream cold-start illegal-address issue
remains open, including an earlier failed one-layer aiter-new baseline
check, so this change makes no LargeM performance claim.
(Ported from plugin_poc ops/mega_moe 9f25c95.)
Co-Authored-By: Codex GPT-6 <[email protected]>
…w m-tiles The cached-weight GEMM bodies pay off once a rank's experts span several m-tiles. With 64-row m-tiles that takes twice the rows of the 32-row bound (2560), so uniform routing at 448-512 tokens (2688-3072 rows, ~32 rows an expert, one m-tile each) now streams its weights; 32-row m-tiles keep 2560. 4 rounds against 9f25c95 (row hint, per-rank): 448/512 rows 0.955/0.958, all 4/4; 1-384 rows 0.997-1.002, geomean 0.992. Skewed routing (--route hot --hot-bias 0.5) at 128-512 rows: 0.999-1.000. Outputs bit-exact (uniform 448/512, hot 256/512); 2000 replays at 448/512 clean. (Ported from plugin_poc ops/mega_moe 30aecfe.) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
emit_presend and emit_dispatch_payload load a token's E8M0 scales with load_at(..., mask=lane * 4 < scale_n_i32). load_at implements a false mask by moving the access ~2 GiB past the descriptor base, which only works on a bounded descriptor; these two used an unbounded AddrBuffer, so lanes 10-63 read addr_in_sc + ~2 GiB. Whether that address is mapped depends on the process's GPU memory layout, so the first large-input launch faulted with an illegal memory access on some ranks and some runs (bench: 4/7 at 1024/4096 rows, --layers 1; most runs with --layers 4), never under rocgdb and never after a large reference allocation (aiter's own test). Found with per-CTA phase stamps in pinned host memory: on the faulting rank every presend worker stopped inside its first item, before its source loads completed, while the peers waited in GEMM1. Bounding both descriptors to the mtpr scale rows makes the masked lanes hardware-OOB reads (zero, unused). Outputs bit-exact against 30aecfe where it runs; 7/7 clean where 30aecfe crashed 4/7; --layers 4 at 1024-16384 rows 3/3 clean (graph replay equal to eager), 300 replays x 4 layers at 1024/4096 clean. Timing unchanged. (Ported from plugin_poc ops/mega_moe 94e6978.) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t route With its illegal-address fault fixed (94e6978), the large-input kernel serves 384-512 rows faster than the small-input one: its dispatch overlaps GEMM1 (presend, per-tile and per-row arrival), and at these rows the small-input dispatch is XGMI-bound for ~40 us before its plan. The route is chosen from max_tokens, the same on every rank, so every rank of a call takes it; other layouts keep the old bound (513). 4 rounds against 94e6978 (row hint, per-rank, --layers 4): 384/400/448/512 rows 0.973/0.964/0.949/0.926 (4/4 each); 1-352 rows 0.999-1.000; geomean 0.976. Skewed routing (--route hot --hot-bias 0.1): 320-512 rows 0.80-0.83 of the small-input route. The large route's P2P rows are offset int8 under E8M0 scales: relL2 vs the fp32 reference at 384-512 rows 0.0466 -> 0.0473 (tolerance 0.1); pad rows, fused shared expert, skewed and balanced routing pass; 1000 graph replays at 384/512 clean. (Ported from plugin_poc ops/mega_moe 11cd132.) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
At 8192+ input rows on a V4.1-Flash EP4 rank, use W1 b_nt=0 and GEMM2 m_group=16. Select these local knobs after the capacity configuration, preserving its tile geometry, producer counts and wire format when EP ranks have different row counts. Preload both schedules. Against integration 11cd132, physical GPU 4-7, per-rank inputs, four rebound layer weights, cache flush, three interleaved rounds: 8192 rows: 2367.37 -> 2295.44 us/layer (0.96962, 3/3) 16384 rows: 4981.31 -> 4777.60 us/layer (0.95911, 3/3) The other 15 points range from 0.99443 to 1.00677. Two reversed rounds confirm both gains. Hot routing (bias 0.1) gives 8192/16384 ratios 0.95238/0.98568, with no control regression. Validation: 180/180 dumps bit-exact across normal, shared, padding, hot, adversarial, capacity-8192, staged/no-hint and mixed-rank calls; 31 FP32 comparisons have unchanged error (max relL2 0.054206). AOT preload and 2000 NaN-poisoned replays each at 64/1024/8192/16384 pass, checking every replay. 26 configuration tests, ruff, black and lazy import pass. (Ported from plugin_poc ops/mega_moe b733a9f.) Co-Authored-By: Codex GPT-6 <[email protected]>
In the V4.1-Flash small-input 256-token bucket, use N384 for ranks whose received-row plan selects cached weights, while streaming ranks retain N256. Keep M32 and the row layout. Select matching work counts, completion thresholds and GEMM2 partitions from the same per-launch plan bit. GPU4-7, EP4 a8w4, per-rank inputs, four rebound layers, cache flush, against e78ed37. Four alternating-process rounds with hot-bias=0.1: rows/rank parent us candidate us candidate/parent 256 447.679 430.989 0.96272 320 531.673 511.521 0.96210 352 534.958 516.641 0.96576 All three improve in 4/4 rounds; reversed comparison confirms them. Hot-bias=0.5 with an independent seed has ratios 0.96249/0.95678/0.97128/ 0.95383 at 192/256/320/352 rows (2/2 each). The one 19-point ordinary-input matrix, three rounds, has geomean 1.00018 and ratios 0.99262-1.00440; there is no measurable ordinary-input or prefill regression. Validation: 216/216 dumps bit-exact, 50 FP32 comparisons with unchanged errors (maximum relL2 0.054314), shared/padded/hot/balanced/adversarial, no-hint staged and uneven-rank cases including idle ranks. All SmallM AOT buckets preload. 64 and 256 rows pass 2000 NaN-poisoned graph replays; 320 rows additionally pass 2000 graphs of 16 calls alternating received loads and N256/N384, checking every call. 31 config tests, ruff, black and lazy CPU import pass. Eight stitched ATT waves confirm the wider body; HIP reports two resident blocks/CU and the trace reports no scratch. Results: mega_moe_work/results/small-cached-width-e78ed37-codex-gpt6-ep4-4567/ (Ported from plugin_poc ops/mega_moe 2fb4239.) Co-Authored-By: Codex (GPT-6) <[email protected]>
Allow the V4.1-Flash EP4 local-replica layout (97 experts/rank, 388 total,
top-7) to use SmallM for row-hinted decode up to 512 rows. Reuse the EP4
small-input configurations and the general fixed-slot protocol. Pass the
local expert count to large_m_mtprs_for so this layout keeps staged
prefill, including when LargeMRuntime is constructed directly. Calls
without a row hint retain the staged route.
GPU4-7, EP4 a8w4, per-rank inputs, four rebound layers and cache flush,
against parent 2fb4239. The one 30-point matrix covers separate/shared
layouts, three alternating-process rounds:
shared rows/rank parent us candidate us candidate/parent
1 143.286 55.393 0.38659
2 183.904 83.372 0.45334
4 214.052 114.676 0.53574
8 281.554 167.438 0.59469
16 359.797 232.079 0.64503
32 441.857 293.173 0.66350
64 498.796 335.298 0.67221
128 530.834 353.256 0.66547
256 626.978 409.257 0.65275
512 688.866 521.065 0.75641
Shared decode geomean is 0.59190, every point 3/3 in the same direction.
Shared prefill geomean is 0.99957; separate-layout geomean is 0.99961
(range 0.99285-1.00242). Reversed order reproduces the gains. With an
independent seed and hot-bias=0.5, shared 64-512 rows improve 15-33%,
with the 1024-row control unchanged.
The new route follows SmallM's fused quantization/GEMM profiles and BF16
returns at small received loads, rather than the staged FP8 return path,
so changed shared outputs are not expected to be bit-exact. All 53 FP32
comparisons have non-increasing error (maximum relL2 0.063025). All 224
dumped outputs are finite; the 76 separate/no-hint/prefill controls are
bit-exact, as are two empty-rank outputs. Padding, hot, balanced,
adversarial magnitudes and mixed counts including idle ranks pass.
All SmallM AOT buckets preload. Explicit bind_layer calls at 1/64/256/512
rows each pass 2000 NaN-poisoned graph replays. 34 config tests and style
checks pass. ATT confirms the fused dispatch and four stitched waves;
HIP reports two resident blocks/CU before screening each shape.
ATOM a7ca4ad83 chooses its small-input call from mega.small_m_mtpr; no
extra expert-count whitelist or caller change is needed for this layout.
Results: mega_moe_work/results/shared-small-2fb4239-codex-gpt6-ep4-4567/
(Ported from plugin_poc ops/mega_moe 75ec3c3.)
Co-Authored-By: Codex (GPT-6) <[email protected]>
Also writes the four dict(...) calls the port added as literals (ruff C408). No functional change.
Two of the ported EP4 V4.1-Flash changes also reached other layouts: - 384-column GEMM1 tiles at 2 and 32-64 tokens (and GEMM2 block_n 256 at 32) sat in the shared small-input base (_small_m_stage1/_small_m_stage2) and in the staged fixed-slot base (_select_fixed_stage1), so EP8 V4-Pro's fused and staged configs changed with them. They move into _tune_v41_flash_ep4_small (and the bucket-2 rule takes 384 for EP4 only); the staged fixed-slot base is #7788's again. - The 4608-row cached-weight bound for 64-row m-tiles now applies to the EP4 V4.1-Flash layouts (4 ranks, 96 or 97 experts a rank) only. Both were measured on EP4 only. EP4 configs are unchanged by this commit (fused tables at MTPR 256..16384, staged tables, and the 97-expert shared layout); EP8/default-shape fused and staged tables are #7788's again.
At its large-input capacities (MTPR 8192 and 16384) EP4 V4.1-Flash sends calls of 384+ rows a rank to the large-input route (plan.large_m_min_tokens). - test_ep4_route_for_every_max_tokens checks that boundary (383/384 added). - test_mega_moe_v2's small-input cases expect the route the plan gives them (_small_input_route): the 448/512-row and c384_* cases now check the large-input route's accuracy at those rows, uneven and idle ranks included. - _EP4_FUSED_DIGEST is the EP4 table with the small-input tile tuning. The EP8 table (_FUSED_DIGEST) is unchanged.
GwilliamHu
force-pushed
the
ghu/mega_ep4_port_20261109
branch
3 times, most recently
from
November 19, 2026 06:43
49f0531 to
69b0135
Compare
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
zufayu
requested review from
Bernard-Liu,
GwilliamHu,
TennyWang1223,
coderfeli and
yadaish
November 25, 2026 01:11
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #7788: the base is
ghu/mega_ep4_port_20261109@ 78d4437.This PR ports a bug fix and the EP4 DeepSeek-V4.1-Flash performance work to this branch. We did the work on an out-of-tree copy of
aiter/ops/flydsl/kernels/mega_moethat had been rebased onto a90a0fb of this branch. Here each commit is replayed with the package's relative imports restored, then rebased onto 78d4437 (the env-var removal). The rebase had no conflicts.Bug fix: the large-input route reads scales out of bounds (7cef4dd)
emit_presendandemit_dispatch_payloadload a token's E8M0 scales withload_at(..., mask=lane * 4 < scale_n_i32). A false mask moves the access about 2 GiB past the descriptor base. That is only safe on a bounded descriptor, and both calls use an unboundedAddrBuffer(addr_in_sc), so lanes 10-63 readaddr_in_sc + ~2 GiB.Whether that address is mapped depends on the process's GPU memory layout. As a result, the first large-input launch intermittently faults with an illegal memory access on some ranks. It never faults under rocgdb or after a large allocation, which is why
test_mega_moe_v2passes.The fix bounds both descriptors to the MTPR scale rows, so the masked lanes become hardware out-of-bounds reads, which return zero and are unused. Outputs are bit-exact wherever the old code runs.
Reproduced in this run on 78d4437: 1 of 4 large-input prefill runs died with
hipErrorIllegalAddress. With this PR, 0 of 4 did. Earlier: 4/7 runs at 1 layer and most runs at 4 layers before the fix, 7/7 clean after.Performance
Setup:
ghu/mega_row_hint_20261109calls them:forward_small_m(max_tokens)up to 512 rows, the large-input route from 1024 rows.Prefill (large-input route, µs per layer):
At 1 layer, #7788 has only one valid round, because its second round hit the fault described above.
The decode rounds ran on GPUs 4-7 while an unrelated job used GPUs 0-3. The two sides were interleaved, so both saw the same conditions.
What changes
Most changes are scoped to the EP4 V4.1-Flash layout: 4 ranks, 96 experts per rank, hidden 5120, inter 2304. The fused-shared variant has 97 experts per rank.
Staged route
v41_flash_ep4network profile:Small-input route
tile_nis 128 at 1 token, and 384 at 2 and 32-64 tokens.SiluQuantEpiloguemasks the ragged last pass of a 384-column tile.FusedStage1Knobs.g1_cached_tile_n; 0 means off.Routing
V41_FLASH_EP4_LARGE_M_MIN_TOKENSand read throughplan.large_m_min_tokens.Large-input route
tune_large_m_launch_config).Fused-shared layout (97 experts per rank)
EP8 and other layouts
The EP8 V4-Pro fused and staged config tables are identical to 78d4437:
_FUSED_DIGESTis unchanged.test_ep8_fused_configs_keep_fused_knobs_offpasses.Code that does change for every layout:
FUSED_TOKEN_BUCKETS. Off EP4 it gets bucket 1's config, as before.g1_cached_tile_nis 0.Not run on EP8 GPUs: the 8-GPU box was shared during this run. Please run the EP8 routes and size suites before merging, or ask and I will run them.
Tests
New CPU tests:
tests/test_mega_moe_ep4_config.pytests/test_mega_moe_ep4_fused_config.pytests/test_mega_moe_ep4_shared_small_config.pyUpdated tests:
test_ep4_route_for_every_max_tokenschecks the 384-row boundary._EP4_FUSED_DIGESTmatches the new EP4 tables.test_mega_moe_v2, the small-input cases expect the route the plan gives them (_small_input_route). Theuniform448,uniform512andc384_*cases now check the large-input route's accuracy at those rows, including uneven and idle ranks.Results on this head, with FlyDSL 0.5.0:
--suite routes --network v41_flash --check-time-acc(EP4)--suite size --network v41_flash --bs-list 1..512(EP4)--suite routes --network v41_flash --smoke-only --layer-stress-cycles 9 --large-m-state-slots 61(EP4)Commit messages carry the measurements behind each change. Those were taken with our EP4 bench (
bench_deepseek_v41_mega_moe.py), and the SHAs they mention are from the out-of-tree copy.