Repository navigation
[Triton/Gluon] [FlyDSL] [CI] [MoE] MegaMoE gfx1250: stage1/stage2 switches, mori combine path, current mori EPv2 - #6430
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
Four fixes to the mori dispatch/combine path (stage1_fused/stage2_fused off), each from driving mori's plans without its op layer: - dispatch: since ROCm/mori#726 the plan takes tok_off_ext and derives selfFirst itself; self_first_enabled() is gone, so importing it fails. - tuning lookup: key it on the dispatch wire the way mori's op layer does ("fp4_disp_bf16_comb" for fp4). Under the hard-coded "bf16" key topk 9 matched no entry and both dispatch and the fp4 combine fell back to the single-shot default. - comb_inp: add the overlapped fp4 combine's u64 flag per landing row (four ranks up). Its 24-warp geometries write them past the region, i.e. past the arena: a page fault at 16384 tokens a rank. - close(): synchronize first, so a launch still in flight does not read a window that has been freed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
With stage2_fused off, fused_moe's rows went into a fresh tensor and then into mori's staging rows (comb_inp): the bf16 combine copied them in its own kernel, the fp4 one through a host-issued copy whenever the recv bound was below max_recv -- every decode step under ATOM. Have fused_moe write them there directly. fused_moe(output=) already existed but the gfx1250 grouped path ignored it and copied at the end; thread it down to the gather-reduce. mori's bf16 combine then sees its input at the staging base and skips the copy, and the fp4 send reads the staging rows in place. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
mori's gfx1250 dispatch now reserves its slots once per destination (the aggregated reservation, ROCm/mori#745) and hands the push combine its landing offsets through the dispatch. MegaMoE drives the plans directly, so it has to size and pass what mori's op layer does: - dest_pe_token_counter holds 2 * world_size ints: send counts, then per destination the reservation base and the push combine's landing offset. It held world_size; the dispatch wrote the second half into allocator padding. - recv_num signals are 8 bytes a source. The region held 4 bytes a source; the arena's 256-byte alignment hid the overrun. - The combine reads its landing offsets from dest_pe_token_counter, which MegaMoE did not pass, so the mxfp4 combine (stage2_fused=False) got a null pointer there. - MORI_EP_TOKOFF_EXT=1 turns the aggregated reservation off, so a mori push combine is refused with it, as mori's op layer refuses it. - The push landing rows come from mori's push_land_rows(): one per (token, destination rank), max_tokens * min(world_size, topk) rather than world_size * max_recv. - The mori dispatch launcher drops total_recv.zero_(): gfx1250's dispatch overwrites the count (since ROCm/mori#599), and mori's op layer skips the same zero there. Against a mori from before ROCm#745 the landing rows keep the old count and the two larger buffers have unused tails. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
mori#703 moves the gfx1250 dispatch's staging arrays out of each kernel module's .bss into one buffer the caller allocates and binds as staging_base; an unbound plan is refused on the host. MegaMoE drives EpDispatchPlan directly, so it allocates ep_staging_bytes() once and binds it to every dispatch plan (they never run at the same time), and drops it after the plans on close(). A mori without ep_staging_bytes keeps the .bss arrays and is left as is. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
stage1_fused now picks the dispatch, and the dispatch_backend argument and config field went away with that. Callers still pass it (ATOM main passes dispatch_backend="mori" on a quantizing wire; ROCm/ATOM#2384 passes "flydsl" or "mori" alongside stage1_fused) and log mega._config.dispatch_backend, so both would fail on this aiter. Accept the argument again and check it against stage1_fused: "mori" is stage1_fused=False, "flydsl" is the compact plan. A "flydsl" without stage1_fused asked for the FlyDSL token-major dispatch, which no longer exists, so it is refused rather than run on mori. MegaMoEConfig gets a read-only dispatch_backend derived from stage1_fused. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
stage1_fused=false with stage2_fused=true is mori's fp4 dispatch with the fused combine (the bench's auto wire is fp4 for a4w4_mxfp4), the configuration DeepSeek-R1 serves with. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ea48721 to
2db3c81
Compare
tests/test_mega_moe_gfx1250_recipe.py needs no GPU and skips where MegaMoE does not import. It checks how the legacy flags map to a recipe and that the rejections keep their wording, and lays the arena out over a grid of geometries and every pairing against the region list ROCm#6430 built inline -- through a fake mori both with and without Plan.describe(), the describe one following mori's rules, which add no overlapped-reduce flags on a wide EP. required_vmm_bytes is held to the layout as cco rounds it, and its keyword form to at least that. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
test_mega_moe_gfx1250.py pins what a change to MegaMoEGfx1250's dispatch/combine wiring must keep, through the constructor and members its callers use today: - every dispatch/combine pairing matches the fp32 reference, and a captured graph replays bit for bit what eager produced; - the pairings MegaMoE rejects fail before the symmetric arena is allocated; - mori's combine reads fused_moe's rows in place (zero-copy staging); - close() releases the plans before the window, the window before its memory; - the members ATOM's Triton experts reach (_dispatch, _combine, _arena, _config). It spawns its own ranks and skips (exit 0) off gfx1250, below two GPUs or without mori, so CI's MULTIGPU job can run it on gfx950. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A caller now says what to run once, as a recipe, and MegaMoE builds it:
recipe = MegaMoERecipe(dispatch=DispatchKind.MORI,
combine=CombineKind.FUSED_SCATTER,
dispatch_wire="fp4", combine_wires=("bf16", "fp4"),
activation=..., quant_type=...)
geometry = MegaMoEGeometry(rank, world_size, model_dim, inter_dim,
experts, topk, max_tokens_per_rank)
mega = MegaMoEGfx1250.from_recipe(recipe, geometry, communicator=comm)
- MegaMoERecipe holds the transport (dispatch and combine kind, dispatch wire,
the combine wires to build) and the expert-GEMM recipe; frozen and hashable,
so a caller can key its cache of instances on it. MegaMoEGeometry holds the
model and EP shape.
- MegaMoERecipe.from_legacy is the one reader of stage1_fused, stage2_fused,
dispatch_backend and the $MEGA_DISPATCH_WIRE / $MEGA_COMBINE_QUANT defaults.
The keyword constructor goes through it, so both entries build the same thing.
- MegaMoEConfig is now that recipe resolved against a geometry: frozen, with
the same properties as before (stage1_fused, stage2_fused and
dispatch_backend included, for the callers that read them). The dispatch
schedule it used to have written into it lives on the instance; the
dispatch_block_num / dispatch_warp_num_per_block fallback it carried was
never reached.
- forward() takes combine_wire= (bf16 | fp8 | fp4), the recipe's vocabulary,
alongside combine_quant=.
Every check and its message is unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
_MoriCapabilities gathers what MegaMoE needs to know about the installed mori -- the plan classes, the tuning lookup, and each helper a mori PR added (scale_stride_bytes ROCm#593, push_wire_nbytes ROCm#719, push_land_rows ROCm#745, ep_staging_bytes ROCm#703, TokOffExt.wanted ROCm#726, self_first_enabled) -- into one cached probe, and the decisions that hang off them into its methods: the tuned schedules, the landing-row sizes, the staging size, where the slot word lives. The ImportError/hasattr branches are gone from the pipeline; the RuntimeError messages for an mori that is too old are unchanged. _plan_transport runs all of it, plus the fused reduce's tiles and mori combine's block/epoch-slot check, before the symmetric arena is allocated. A configuration that cannot run -- mori missing, MORI_EP_TOKOFF_EXT=1 with mori's fp4 combine, no reduce tile, too many combine blocks -- now fails with nothing allocated instead of leaking the arena. TokOffExt.wanted, collective when MORI_EP_TOKOFF_EXT is on, moves ahead of the arena's own collective allocation on every rank alike. The compact dispatch with the fused combine still never loads mori's ops. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The arena's regions now come from one formula, _arena_layout: the dispatch says what it writes (_dispatch_regions: the routing both kinds share, then its own rows), the combine what it stages through (_combine_regions), and _ArenaLayout.merge lays them down in the order the pipeline always used, so every pairing keeps the offsets it had. SymmetricArena takes the layout (or a region list, as before) and frees its memory if the window registration fails. MegaMoEGfx1250.required_vmm_bytes(recipe, geometry) reports the same layout, rounded the way ccoMemAlloc rounds an allocation -- the per_rank_vmm a caller needs for this MegaMoE, before any communicator exists, and exactly what the constructor then allocates. It is MegaMoE's share only; a communicator that also carries mori's own EP ops needs theirs on top. required_vmm_bytes(world_size=, hidden_dim=, max_tokens_per_rank=, experts=, topk=, stage1_fused=), the keyword form ROCm#6525 proposed and ATOM's yanbo/mega already calls, still works: it names neither wires nor combine nor inter_dim, so it returns the largest any recipe with that dispatch takes. _compact_gemm_align_m reads activation, quant type and inter_dim off the config instead of taking them separately. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nsport A move, no change in behaviour: each block of mega_moe.py lands in one module as it was, and mega_moe.py keeps only MegaMoEGfx1250. - recipe.py: the wires, DispatchKind / CombineKind, ExpertComputeConfig, MegaMoERecipe, MegaMoEGeometry, MegaMoEConfig. - mori_caps.py: _MoriCapabilities and mori's region names. - arena.py: SymmetricArena, the region order, _ArenaLayout, cco's rounding. - stages/base.py: DispatchStage / CombineStage and what the stages share (routing, resources, batch, compute target, schedule pick). - stages/dispatch_mori.py, dispatch_compact.py, combine_fused.py, combine_mori.py: one stage each; stages/__init__.py maps each kind to its stage. - transport.py: _EpDispatcher and the one arena layout. The only edit: recipe.py looks the stages up when asked for (the stages import recipe.py). mega_moe.py still exports the package's public names, and Routing, which a bench imports from there. The CPU test imports the private names it checks from the modules that define them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Compact dispatch can omit or misroute expert rows due to receive-bound and plan-alignment errors, while supported FP8/FP4 recipes can fail on activation-dtype mismatches.
15 open issues
Pass the wire activation dtype to fused_moe · New Validate pending plan geometry before reuse · New Use max_recv for the default receive bound · New Agree on alignment across all ranks · New Retain eight-rank coverage for both dispatch modes · New Restore legacy mori sizing and binding support · New Validate plan limits before arena allocation · New Preload both compact plan specializations · New Gate benchmark setup to gfx1250 · New Enable reliable profiler labels for compact mode · New Implement the documented fused_shared_experts option · New Add FP8 cases to quantized multi-GPU tests · New Synchronize rank-local failures before cleanup · New Use checkAllclose for quantized output validation · New Skip only known missing optional dependencies · New
What changed in this PR
Updates gfx1250 MegaMoE to use recipe-based dispatch and combine stages, with shared arena sizing and direct mori plan integration.
Changes:
- Adds recipe and geometry configuration, stage-specific planning, and resource cleanup.
- Threads output buffers through grouped MoE for zero-copy combine staging and preserves strided GEMM scale views.
- Updates benchmark stage switches and CI arguments, and adds host and multi-GPU regression tests.
| File | Description |
|---|---|
tests/test_mega_moe_gfx1250_recipe.py |
Tests recipes, validation, arena layout, and memory sizing. |
tests/test_grouped_gemm_strided_scales.py |
Tests scale aliases and launcher arguments. |
op_tests/op_benchmarks/triton/bench_moe_gemm_a4w4_cudagraph.py |
Migrates MegaMoE setup to recipes. |
op_tests/multigpu_tests/test_mega_moe_gfx1250.py |
Adds distributed correctness and lifecycle checks. |
op_tests/multigpu_tests/bench_mega_moe.py |
Adds stage switches and recipe-sized communicators. |
aiter/ops/flydsl/kernels/tensor_shim.py |
Adds flat aliases for strided raw-buffer arguments. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/transport.py |
Coordinates stages and shared resource cleanup. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/stages/dispatch_mori.py |
Implements mori dispatch planning and staging. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/stages/dispatch_compact.py |
Encapsulates compact dispatch and plan prefetching. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/stages/combine_mori.py |
Implements mori combine with in-place staging. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/stages/combine_fused.py |
Encapsulates fused scatter and reduction. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/stages/base.py |
Defines stage contracts and shared buffers. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/stages/__init__.py |
Registers dispatch and combine implementations. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/recipe.py |
Defines recipes, geometry, and compatibility checks. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/mori_caps.py |
Centralizes mori APIs, sizing, and tuning lookup. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/arena.py |
Implements arena layout, allocation, and rounding. |
aiter/ops/flydsl/kernels/mega_moe_gfx1250/__init__.py |
Exports the recipe API. |
aiter/ops/flydsl/kernels/flydsl_dispatch_combine_intranode_op.py |
Updates a comment’s source-file reference. |
aiter/ops/flydsl/grouped_moe_gfx1250.py |
Accepts a caller-provided output buffer. |
aiter/ops/flydsl/grouped_gemm_mxfp4.py |
Uses flat aliases for strided scales. |
aiter/fused_moe.py |
Forwards the output buffer to grouped MoE. |
.github/scripts/aiter_test.sh |
Switches the benchmark invocation to stage flags. |
Review effort: Balanced
- Compact dispatch: with no recv_token_bound the step is sized for the arena's capacity; a plan started for another alignment is refused; the plan's segment and wave limits are checked before the arena exists; plans are compiled when created, ahead of any graph capture. - A quantizing dispatch wire sets fused_moe's quant_dtype_a. - bench_mega_moe runs on gfx1250 only. - Tests: fp8 dispatch and fp8 combine cases, rank-local failures raised on every rank, CPU tests skip only without flydsl. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- The package's kernel modules import mori.cco, so the test skips when mori is not installed instead of failing collection. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks, all addressed in new commits on top, with no force-push.
Verified on gfx1250 with mori main: bit-exact against the original functional commits, and the multi-GPU test and bench accuracy pass. |
# Conflicts: # aiter/fused_moe.py # aiter/ops/flydsl/grouped_moe_gfx1250.py
NOT READY FOR HUMAN REVIEWPR 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 |
- Take main's _launch_address (ROCm#6557) for the grouped GEMM's strided scale views; drop this branch's tensor_shim.flat_arg and its test. - Port ROCm#6557's compact-plan change (ep_fused=True lookup, logged AITER_TDM_TILE_M override) to stages/dispatch_compact.py. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- bench_mega_moe: keep this branch's stage1/stage2 configurations and bring in ROCm#7074 on top: the kernel table on multi-stream graphs, --fused_shared_experts, and the split profile/time passes, now taken when any configuration runs stage1_fused. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… dispatch Per the ROCr rollout contract (all SW consumes the exact GFX ID ROCr reports), global normalization in _detect_native() is the wrong boundary. Once ROCr reports gfx1250-strict for A0, folding it to gfx1250 there makes _needs_arch_rebuild() treat a strict .so as not covering a strict device and rebuild in a loop; it also remixes A0/B0 in tuned configs, caches, and logs. - chip_info._detect_native: drop the strict->gfx1250 fold; return the exact ROCr-reported identity. get_gfx_runtime()/get_gfx() now report gfx1250-strict on A0. - build_targets.py: add the single source of truth for family folding -- GFX_BASE_ARCH, base_gfx_arch(), is_gfx1250_family(). Torch-free, so build scripts and tests import it without side effects. - Opus: replace its two private strict->gfx1250 folds (gen_instances _registry_arch, opus_gemm_common _get_registry_records/get_registry/ default_compiled_keys) with base_gfx_arch(), so there is no second mapping. hipcc still gets --offload-arch=gfx1250-strict and the .co stays mach-0xeb. - mega_moe _require_gfx1250: restore the gfx1250-family guard (via is_gfx1250_family) that main's #6430 refactor collapsed to bare gfx1250. - Build/cache/tuning/.so/.co/ASM keep the exact identity: _needs_arch_rebuild and _so_offload_archs already key on it, so A0 never loads a B0 object. - Pre-existing gfx1250-only dispatch sites authored by other PRs stay exact; with the fold gone they correctly distinguish strict (fall back) instead of silently reusing a B0 path. - Tests: flip the native-detection test into a regression lock that strict identity is preserved; add family-helper and 4-way code-object rebuild-guard tests (runtime/built strict x gfx1250 -> accept/reject). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…/stage2 switches) (#2765) * feat(moe): map mega stage1/stage2_fused to aiter, add decode combine quant * feat(moe): build MegaMoE from an aiter MegaMoERecipe On an aiter that has MegaMoERecipe (ROCm/aiter#6430), init_mega_transport hands aiter a recipe instead of the stage flags: ATOM still picks the dispatch, the combine and the wires from ATOM_MEGA_STAGE1_FUSED / ATOM_MEGA_STAGE2_FUSED / MEGA_DISPATCH_WIRE / ATOM_MEGA_COMBINE_WIRE, the layer supplies the expert GEMM, and whether the pairing can run is aiter's to say. - The shared instance is keyed by (recipe, geometry). - The communicator is sized by MegaMoEGfx1250.required_vmm_bytes(recipe, geometry) -- the arena exactly -- plus the granule the DevComm created right after takes. - It is built with MegaMoEGfx1250.from_recipe, and the log and the per-layer recipe check read mega.recipe. - Each step names its combine as a wire (combine_wire=bf16|fp8|fp4); combine_quant_for_step is now combine_wire_for_step. An aiter without MegaMoERecipe keeps the flag path as it was. The Triton experts path still drives MegaMoE's _dispatch/_combine, which aiter keeps. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * refactor(moe): MegaMoE borrows the EP all2all manager's cco communicator aiter's MoriV2All2AllManager (ROCm/aiter#6618) owns the EP group's cco communicator and lends it through get_or_create_cco_communicator(). MegaMoE now takes it from there instead of creating and caching one of its own: - make_mori_v2_prepare_finalize hands the all2all manager to MoriV2PrepareAndFinalize, which passes it to init_mega_transport. - The capacity is asked for in full before the communicator exists: the arena's required_vmm_bytes() plus the DevComm's granule. - The communicator cannot grow, so it serves the first MegaMoE; a second, differently shaped one, or one on an aiter whose manager lends none, gets its own as before (with a warning in the first case). - close_mega_transports() closes every MegaMoE; ModelRunner.exit calls it before destroy_dist_env(), so the arenas go before the manager destroys the communicator. The recipe is built with aiter's nested ExpertComputeConfig, and the per-layer recipe check and the creation log read it from recipe.compute. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(moe): MegaMoE takes the MoRI v2 manager, closes cleanly; drop the v2 gather path - ATOM_MORI_V2 asks for the "mori_v2" all2all manager before anything reads .all2all_manager, so MegaMoE borrows its cco communicator; an aiter without that manager keeps the default one. - Communicators ATOM creates for MegaMoE itself are destroyed after the MegaMoE instances close; every close is attempted, and destroy_dist_env() runs even if one fails. - Remove the unreachable v2 gather transport (init_mori_v2_op and its prepare/finalize); fix the stale weight-check message. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(moe): Triton experts branch passes _recv_bound only the arena rows - MoriV2ModularKernel's triton_experts branch called _recv_bound with (topk_ids, arena_rows) and raised TypeError on its first forward. - tests/model_ops/test_mori_v2_triton_experts.py drives that branch with MegaMoE and triton_mega_moe stand-ins, no GPU. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(moe): MegaMoE review follow-ups - Layers share one MegaMoE by recipe and geometry; a layer with other Situv2 betas is refused - The borrowed communicator is tracked explicitly; each DevComm closes before its communicator, in a documented order - Ranks with different MegaMoE settings are refused at the first build - Combine-wire support is left to aiter; recipe kinds compare as enum members - The MegaMoE tests cover the recipe path and teardown, and run without aiter; the DeepSeek-V4 log example matches the new format Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * fix(moe): MegaMoE communicators, settings check order, exit teardown - Each MegaMoE that cannot borrow the manager's communicator gets its own - The EP-rank settings check now includes the gate mode and runs before the recipe is built - ModelRunner.exit releases the dist env, CUDA graphs, KV cache and model even when a MegaMoE close fails - Tests cover the production communicator path, the check order and the exit teardown Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * refactor(moe): call the MoRI v2 all2all manager directly - moe.py asks the EP device communicator for the "mori_v2" manager directly; mori_v2_all2all_manager is gone - MegaMoE borrows the manager's cco communicator without probing for the method Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * refactor(moe): drop the pre-recipe aiter path - MegaMoE is built from a recipe only; the stage-flag path and the per-token VMM fallback are gone - The default bf16 combine wire is passed once - The Situv2 betas check compares what ATOM built with Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: yanboshao <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: JiaoliangYu <[email protected]>
…tches, mori combine path, current mori EPv2 (#6430) * MegaMoE: stage1_fused/stage2_fused switches, mori combine path * bench_mega_moe: fix kernel table on multi-stream graphs * MegaMoE: follow mori tokoff-ext and selfFirst defaults * bench_mega_moe: --fused_shared_experts as ATOM DP+EP runs them * MegaMoE: follow mori#726 and size mori's fp4 combine flags Four fixes to the mori dispatch/combine path (stage1_fused/stage2_fused off), each from driving mori's plans without its op layer: - dispatch: since ROCm/mori#726 the plan takes tok_off_ext and derives selfFirst itself; self_first_enabled() is gone, so importing it fails. - tuning lookup: key it on the dispatch wire the way mori's op layer does ("fp4_disp_bf16_comb" for fp4). Under the hard-coded "bf16" key topk 9 matched no entry and both dispatch and the fp4 combine fell back to the single-shot default. - comb_inp: add the overlapped fp4 combine's u64 flag per landing row (four ranks up). Its 24-warp geometries write them past the region, i.e. past the arena: a page fault at 16384 tokens a rank. - close(): synchronize first, so a launch still in flight does not read a window that has been freed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: zero-copy hand-off from fused_moe to mori's combine With stage2_fused off, fused_moe's rows went into a fresh tensor and then into mori's staging rows (comb_inp): the bf16 combine copied them in its own kernel, the fp4 one through a host-issued copy whenever the recv bound was below max_recv -- every decode step under ATOM. Have fused_moe write them there directly. fused_moe(output=) already existed but the gfx1250 grouped path ignored it and copied at the end; thread it down to the gather-reduce. mori's bf16 combine then sees its input at the staging base and skips the copy, and the fp4 send reads the staging rows in place. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: follow mori#745/#746 on the mori dispatch/combine path mori's gfx1250 dispatch now reserves its slots once per destination (the aggregated reservation, ROCm/mori#745) and hands the push combine its landing offsets through the dispatch. MegaMoE drives the plans directly, so it has to size and pass what mori's op layer does: - dest_pe_token_counter holds 2 * world_size ints: send counts, then per destination the reservation base and the push combine's landing offset. It held world_size; the dispatch wrote the second half into allocator padding. - recv_num signals are 8 bytes a source. The region held 4 bytes a source; the arena's 256-byte alignment hid the overrun. - The combine reads its landing offsets from dest_pe_token_counter, which MegaMoE did not pass, so the mxfp4 combine (stage2_fused=False) got a null pointer there. - MORI_EP_TOKOFF_EXT=1 turns the aggregated reservation off, so a mori push combine is refused with it, as mori's op layer refuses it. - The push landing rows come from mori's push_land_rows(): one per (token, destination rank), max_tokens * min(world_size, topk) rather than world_size * max_recv. - The mori dispatch launcher drops total_recv.zero_(): gfx1250's dispatch overwrites the count (since ROCm/mori#599), and mori's op layer skips the same zero there. Against a mori from before #745 the landing rows keep the old count and the two larger buffers have unused tails. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: bind mori's dispatch staging buffer (ROCm/mori#703) mori#703 moves the gfx1250 dispatch's staging arrays out of each kernel module's .bss into one buffer the caller allocates and binds as staging_base; an unbound plan is refused on the host. MegaMoE drives EpDispatchPlan directly, so it allocates ep_staging_bytes() once and binds it to every dispatch plan (they never run at the same time), and drops it after the plans on close(). A mori without ep_staging_bytes keeps the .bss arrays and is left as is. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: keep accepting dispatch_backend stage1_fused now picks the dispatch, and the dispatch_backend argument and config field went away with that. Callers still pass it (ATOM main passes dispatch_backend="mori" on a quantizing wire; ROCm/ATOM#2384 passes "flydsl" or "mori" alongside stage1_fused) and log mega._config.dispatch_backend, so both would fail on this aiter. Accept the argument again and check it against stage1_fused: "mori" is stage1_fused=False, "flydsl" is the compact plan. A "flydsl" without stage1_fused asked for the FlyDSL token-major dispatch, which no longer exists, so it is refused rather than run on mori. MegaMoEConfig gets a read-only dispatch_backend derived from stage1_fused. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * ci: run the MegaMoE bench on mori's dispatch stage1_fused=false with stage2_fused=true is mori's fp4 dispatch with the fused combine (the bench's auto wire is fp4 for a4w4_mxfp4), the configuration DeepSeek-R1 serves with. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: gfx1250 behaviour tests ahead of the refactor test_mega_moe_gfx1250.py pins what a change to MegaMoEGfx1250's dispatch/combine wiring must keep, through the constructor and members its callers use today: - every dispatch/combine pairing matches the fp32 reference, and a captured graph replays bit for bit what eager produced; - the pairings MegaMoE rejects fail before the symmetric arena is allocated; - mori's combine reads fused_moe's rows in place (zero-copy staging); - close() releases the plans before the window, the window before its memory; - the members ATOM's Triton experts reach (_dispatch, _combine, _arena, _config). It spawns its own ranks and skips (exit 0) off gfx1250, below two GPUs or without mori, so CI's MULTIGPU job can run it on gfx950. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: build from a MegaMoERecipe and a MegaMoEGeometry A caller now says what to run once, as a recipe, and MegaMoE builds it: recipe = MegaMoERecipe(dispatch=DispatchKind.MORI, combine=CombineKind.FUSED_SCATTER, dispatch_wire="fp4", combine_wires=("bf16", "fp4"), activation=..., quant_type=...) geometry = MegaMoEGeometry(rank, world_size, model_dim, inter_dim, experts, topk, max_tokens_per_rank) mega = MegaMoEGfx1250.from_recipe(recipe, geometry, communicator=comm) - MegaMoERecipe holds the transport (dispatch and combine kind, dispatch wire, the combine wires to build) and the expert-GEMM recipe; frozen and hashable, so a caller can key its cache of instances on it. MegaMoEGeometry holds the model and EP shape. - MegaMoERecipe.from_legacy is the one reader of stage1_fused, stage2_fused, dispatch_backend and the $MEGA_DISPATCH_WIRE / $MEGA_COMBINE_QUANT defaults. The keyword constructor goes through it, so both entries build the same thing. - MegaMoEConfig is now that recipe resolved against a geometry: frozen, with the same properties as before (stage1_fused, stage2_fused and dispatch_backend included, for the callers that read them). The dispatch schedule it used to have written into it lives on the instance; the dispatch_block_num / dispatch_warp_num_per_block fallback it carried was never reached. - forward() takes combine_wire= (bf16 | fp8 | fp4), the recipe's vocabulary, alongside combine_quant=. Every check and its message is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: probe mori once, and decide everything before the arena exists _MoriCapabilities gathers what MegaMoE needs to know about the installed mori -- the plan classes, the tuning lookup, and each helper a mori PR added (scale_stride_bytes #593, push_wire_nbytes #719, push_land_rows #745, ep_staging_bytes #703, TokOffExt.wanted #726, self_first_enabled) -- into one cached probe, and the decisions that hang off them into its methods: the tuned schedules, the landing-row sizes, the staging size, where the slot word lives. The ImportError/hasattr branches are gone from the pipeline; the RuntimeError messages for an mori that is too old are unchanged. _plan_transport runs all of it, plus the fused reduce's tiles and mori combine's block/epoch-slot check, before the symmetric arena is allocated. A configuration that cannot run -- mori missing, MORI_EP_TOKOFF_EXT=1 with mori's fp4 combine, no reduce tile, too many combine blocks -- now fails with nothing allocated instead of leaking the arena. TokOffExt.wanted, collective when MORI_EP_TOKOFF_EXT is on, moves ahead of the arena's own collective allocation on every rank alike. The compact dispatch with the fused combine still never loads mori's ops. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: one arena layout, and required_vmm_bytes from it The arena's regions now come from one formula, _arena_layout: the dispatch says what it writes (_dispatch_regions: the routing both kinds share, then its own rows), the combine what it stages through (_combine_regions), and _ArenaLayout.merge lays them down in the order the pipeline always used, so every pairing keeps the offsets it had. SymmetricArena takes the layout (or a region list, as before) and frees its memory if the window registration fails. MegaMoEGfx1250.required_vmm_bytes(recipe, geometry) reports the same layout, rounded the way ccoMemAlloc rounds an allocation -- the per_rank_vmm a caller needs for this MegaMoE, before any communicator exists, and exactly what the constructor then allocates. It is MegaMoE's share only; a communicator that also carries mori's own EP ops needs theirs on top. required_vmm_bytes(world_size=, hidden_dim=, max_tokens_per_rank=, experts=, topk=, stage1_fused=), the keyword form #6525 proposed and ATOM's yanbo/mega already calls, still works: it names neither wires nor combine nor inter_dim, so it returns the largest any recipe with that dispatch takes. _compact_gemm_align_m reads activation, quant type and inter_dim off the config instead of taking them separately. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: dispatch and combine stages under one dispatcher; linear forward The transport is now two stages the recipe picks, over one shared arena: _MoriDispatch / _CompactDispatch tokens out to their experts' ranks _MoriCombine / _FusedScatterCombine results back, summed per token Each declares its arena regions (regions(), pure -- what _arena_layout and required_vmm_bytes merge), plans in __init__ with nothing allocated, and allocates in build(). They meet only through _EpResources (the arena, the routing state both ends read, TokOffExt), the _DispatchBatch the dispatch hands the expert GEMM, and the _ComputeTarget the combine has it write into. _EpDispatcher picks the two from tables, runs every check before the arena is allocated, and frees what was built when a later step fails -- the arena and plans used to leak. close() goes: synchronize, combine plans, dispatch plans, staging, arena, TokOffExt. forward() is now: pick the step's combine wire, check the inputs, dispatch, prepare, compute, finish. The compact plan's machinery -- slots, side stream, per-step geometry (_CompactStep, now immutable) -- lives in _CompactDispatch, and the next layer's plan launches at the end of its dispatch, the same place on the GPU streams as before. The recv views are made once at build instead of per step. The TDM dispatch keeps only its compact arm; the token-major arms were unreachable once stage1_fused=False went through mori. Kept for the callers that reach past forward(), ATOM's Triton experts among them: _config, _arena, _dispatch() and its 5-tuple, _combine(), _recv_dispatch_scales(), prefetch_compact_plan(), warmup_compact_plan(). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: size mori's regions from describe(); the bench sizes cco from the recipe On a mori with Plan.describe() (ROCm/mori#844), the mori stages ask it for their arena regions and the dispatch's staging bytes -- the numbers mori's own kernels and its bind-time size check use -- instead of keeping formulas that mirror them. Each stage builds its plan request in one place (request()), which both describe() and the plan take. describe() compiles nothing and resolves against gfx1250 by name, so required_vmm_bytes stays off the GPU; the slot word's kwargs stay out of it, since where that word lives sizes nothing and asking would be collective. An older mori keeps the formulas. SymmetricArena.size() lets a #844 plan check its regions at bind. bench_mega_moe builds from a MegaMoERecipe and sizes its communicator with required_vmm_bytes(recipe, geometry) instead of a fixed 16 GiB. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: CPU tests for the recipe and the arena it sizes tests/test_mega_moe_gfx1250_recipe.py needs no GPU and skips where MegaMoE does not import. It checks how the legacy flags map to a recipe and that the rejections keep their wording, and lays the arena out over a grid of geometries and every pairing against the region list #6430 built inline -- through a fake mori both with and without Plan.describe(), the describe one following mori's rules, which add no overlapped-reduce flags on a wide EP. required_vmm_bytes is held to the layout as cco rounds it, and its keyword form to at least that. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: bind mori's dispatch staging as a tensor A mori with ROCm/mori#844 checks a staging tensor against the plan's stagingBytes, device and alignment at bind, and holds it; an address is taken on trust. An older mori reads the tensor's address at each launch, as it did the int. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TEMP: grouped GEMM takes a strided scale view again (fixup for #6946) #6946 flattens the grouped GEMM's scale arguments with .view(-1), which a non-contiguous tensor cannot do. MegaMoE's compact rows hand over exactly that -- each row's e8m0 scales sit inside its wire row -- so every stage1_fused MegaMoE step raises. The kernel only takes the base address and walks the rows by a_scale_row_stride_bytes, so a strided scale view becomes a one-dimensional view over the same base, as it was before #6946. Temporary: drop this commit once main fixes it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * bench_mega_moe: take out the kernel-table and --fused_shared_experts changes They are bench fixes rather than part of the MegaMoE recipe work, and move to #7074. This reverts "bench_mega_moe: fix kernel table on multi-stream graphs" and "bench_mega_moe: --fused_shared_experts as ATOM DP+EP runs them". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * FlyDSL grouped GEMM: pass a strided scale view at its base address Replaces the temporary workaround for the cached launcher (#6946), which flattens the grouped GEMM's scale arguments with .view(-1). A non-contiguous tensor cannot do that, and MegaMoE's expert-grouped dispatch hands over exactly one: each row's e8m0 scales sit inside its wire row, read by a_scale_row_stride_bytes. The kernel reads these arguments only through their base pointer. tensor_shim gains flat_arg(), beside ptr_arg(): a contiguous tensor is .view(-1), as before, so no other caller changes; a strided one becomes the run of elements from its first to its last, at the same base. tests/test_grouped_gemm_strided_scales.py checks flat_arg and what the launcher hands the compiled kernel, without a GPU. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: stage contracts, mori sizing from describe() only, from_recipe first The recipe - The expert GEMM's fields move into ExpertComputeConfig, nested as MegaMoERecipe.compute; the recipe's own fields are the transport's. - Which pairings run is declared by the stages: a dispatch names the wires it carries and the BatchLayout it delivers (token-major or expert-grouped), a combine the layouts it accepts and the wires it offers. The recipe checks against those, and its errors name recipe fields (dispatch=, combine=, dispatch_wire=, combine_wires=). Each stage's geometry check (check()) runs from MegaMoEConfig. - from_recipe is the entry point. The keyword constructor warns DeprecationWarning; the underscored members ATOM's Triton experts use are documented as kept for them. The facade reads geometry and compute fields through properties rather than copying them. The stages - DispatchStage and CombineStage (Protocols) say what each provides; every stage has regions(config, caps) and check(config), and is built as Stage(config, caps). The compact- and mori-only attributes are gone from the shared base. - Each dispatch stage owns the stride its e8m0 rows arrive at (scale_stride), replacing MegaMoEConfig.dispatch_scale_dst_nbytes. - The batch carries its layout explicitly, and an expert-grouped one an ExpertGrouping; the combine hands the grouped GEMM its dispatch context in the _ComputeTarget, so the expert GEMM does not branch on the layout. - Whether the combine needs mori's aggregated reservation and whether the dispatch makes it are each stage's to say; the dispatcher refuses the pair before the arena exists. - One schedule pick (_pick) serves both mori plans and the compact kernels; _quantize returns the scale rows' address instead of leaving it in state. - _EpDispatcher has dispatch/prepare/combine/prefetch/warmup and the recv views, so forward() does not reach into the stages, and close() releases the rest even when one part raises. mori - _MoriCapabilities needs Plan.describe() (ROCm/mori#844). Regions, staging bytes and the scale stride come from there, so the copies of mori's formulas and the older-mori branches are gone; such a mori also overwrites total_recv in its dispatch, which is why nothing zeroes it. - _XDB_FLAG_SLOTS, TokOffExt and the plan constructors are reached only through _MoriCapabilities. Checks - An out-of-range recv_token_bound (and next_recv_token_bound) raises on the compact dispatch as on mori's, in dispatch, prefetch and warmup. - a1_scale on a quantizing dispatch wire raises ValueError (was an assert). - The keyword form of required_vmm_bytes raises when no candidate recipe runs at the geometry, instead of returning 0. - _MoriCombine.prepare documents why writing fused_moe's rows straight into comb_inp is safe: the next dispatch does not finish until every peer has dispatched, which each does only after its own combine. Tests: the CPU test fakes mori from describe() alone and covers the stage contract messages, the bound checks and the keyword-bound refusal; the multi-GPU test builds through from_recipe and checks the deprecated keyword constructor against it. bench_moe_gemm_a4w4_cudagraph builds through from_recipe. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: split mega_moe.py into recipe, mori_caps, arena, stages, transport A move, no change in behaviour: each block of mega_moe.py lands in one module as it was, and mega_moe.py keeps only MegaMoEGfx1250. - recipe.py: the wires, DispatchKind / CombineKind, ExpertComputeConfig, MegaMoERecipe, MegaMoEGeometry, MegaMoEConfig. - mori_caps.py: _MoriCapabilities and mori's region names. - arena.py: SymmetricArena, the region order, _ArenaLayout, cco's rounding. - stages/base.py: DispatchStage / CombineStage and what the stages share (routing, resources, batch, compute target, schedule pick). - stages/dispatch_mori.py, dispatch_compact.py, combine_fused.py, combine_mori.py: one stage each; stages/__init__.py maps each kind to its stage. - transport.py: _EpDispatcher and the one arena layout. The only edit: recipe.py looks the stages up when asked for (the stages import recipe.py). mega_moe.py still exports the package's public names, and Routing, which a bench imports from there. The CPU test imports the private names it checks from the modules that define them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: compact dispatch bound and plan fixes, wire-picked GEMM A dtype - Compact dispatch: with no recv_token_bound the step is sized for the arena's capacity; a plan started for another alignment is refused; the plan's segment and wave limits are checked before the arena exists; plans are compiled when created, ahead of any graph capture. - A quantizing dispatch wire sets fused_moe's quant_dtype_a. - bench_mega_moe runs on gfx1250 only. - Tests: fp8 dispatch and fp8 combine cases, rank-local failures raised on every rank, CPU tests skip only without flydsl. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE CPU test: skip without mori as well - The package's kernel modules import mori.cco, so the test skips when mori is not installed instead of failing collection. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: yanboshao <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…cture plumbing (#6767) * [JIT] Add gfx1250-strict architecture plumbing * [JIT] Fix ruff F821 and black formatting in gfx1250-strict plumbing Add the missing build_targets._parse_gpu_archs_env import in core.py (F821 flagged by CI ruff) and apply black to core.py and test_build_targets_architecture.py. Co-Authored-By: Claude Code <[email protected]> * [JIT] Add gfx1250-strict kernel inventory and WS2 build driver Skeleton inventory for every JIT/FlyDSL/Triton path plus the driver that fills its strict-build column from a strict-capable container. Driver verified offline on a non-strict host (module enumeration, child plumbing, skip classification, --update-md folding): - CHILD called os.chdir without importing os, so every module would have failed with NameError and the whole matrix would have read "fail". - optCompilerConfig lists 135 modules but get_args_of_build("all") yields 123. The other 12 are not failures: 10 end in "tune" (skipped by design) and 2 are experimental (gated by AITER_ENABLE_EXPERIMENTAL). They are now recorded as skip-tune / skip-experimental instead of "missing", so the matrix keeps an explicit result for all 135. Actual pass/fail rows still require the strict toolchain; stock ROCm 7.0.0 rejects gfx1250-strict as an invalid target ID. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Fix empty GPU_ARCHS raising out of build_module The gfx1250-strict plumbing routed GPU_ARCHS through build_targets._parse_gpu_archs_env, which raises when the value holds no architecture names. GPU_ARCHS set but empty -- what a Dockerfile's `ENV GPU_ARCHS=` or a bare `export GPU_ARCHS=` produces -- previously just meant "no cluster-launch flag, build normally"; it now raised RuntimeError inside build_module and failed every JIT build. Blank, whitespace-only and ";" values had the same problem. Fall back to the detected arch instead, matching aiter/ops/opus/_arch.py, which treats an empty or "native" GPU_ARCHS as "probe the device" and never raises. The arch test moves into _build_archs_from_env / _cluster_launch_target so it is reachable from a CPU-only test. Covered by TestClusterLaunchBuildArchs: blank/unset/"native" fall back to detection, explicit archs win, and -DAITER_ENABLE_CLUSTER_LAUNCH still follows gfx1250 or gfx1250-strict anywhere in a multi-arch GPU_ARCHS. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Inventory the gfx1250 dispatch sites a strict device silently misses The infra PR keeps gfx1250-strict distinct through parsing, build selection and the asm guard, but Python dispatch still compares against the exact literal "gfx1250". On A0 get_gfx() returns "gfx1250-strict", so those comparisons are False and the constant arch allowlists do not contain it: the gfx1250 path is skipped with no error, which reads as a kernel-selection change rather than a failure. ws2_gfx1250_dispatch_sites.py enumerates them -- 150 uses across 65 files, 132 runtime comparisons and 18 allowlist entries -- and records where the compared string comes from. get_gfx/get_gfx_runtime sites keep the hyphenated spelling and are known to miss; triton-arch sites read Triton's own target name, whose strict spelling stays unverified until the toolchain lands. The table is generated into the inventory between HTML markers and the rewrite is idempotent, so it can be refreshed as owners decide each site. No dispatch behaviour is changed here: every row is an explicit pending decision, which is what workstream 2 asks for. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Pin the offload-target parser against hyphenated target names _so_offload_archs backs the guard that keeps a gfx1250 and a gfx1250-strict .so from standing in for each other, so the shapes it must parse deserve a test of their own: a feature list after ':', the strict suffix, both together, and a ROCm generic target. The previous gfx\w+ pattern truncated at the first hyphen. That reported a strict .so as plain gfx1250 -- the substitution this guard exists to prevent -- and also read gfx9-4-generic as gfx9, which matches no running arch and so rebuilt such a module on every import. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Inventory the arch-keyed tables that have no strict entry The dispatch-site scan only saw comparisons against the "gfx1250" literal, which left a blind spot: tables keyed by architecture. A strict device is simply absent from those, so it takes whatever the lookup does with a missing key. Four of them carry a gfx1250 entry and no strict entry, and they do not behave alike: - radix_topk_one_block._LONG_RADIX_BY_ARCH and ._ONE_BLOCK_LDS_BUDGET_BYTES read with a default, so A0 quietly falls back to the generic radix layout and a zero LDS budget, losing the 320 KiB one-block path with nothing logged. - pa_decode's inline fp8 dtype table reads with .get() and raises NotImplementedError naming the arch -- the "fail clearly" behaviour the enablement plan asks for. - mhc.MHC_FUSED_POST_PRE_M_UPPER_BOUND reads with a default of 1024, which happens to equal the gfx1250 entry, so A0 is correct today only by coincidence. The generated table records the lookup style per row so the difference between a silent fallback and a clear failure is visible to the owner making the call. Behaviour is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Extend the gfx1250 site inventory to C++ and skip handled sites get_gpu_arch() in aiter_hip_common.h cuts the target id at ':' and keeps everything before it, so a strict device reports "gfx1250-strict" in C++ too and the arch_id == "gfx1250" branches miss exactly as the Python ones do. 27 of them across 14 files, 11 in mha_bwd.cu alone, where several pick launch geometry rather than a code path -- a miss changes a block size instead of raising. Worth recording for the Opus owner: opus_co_launch_gfx1250.cuh builds its code-object path from get_gpu_arch(), so A0 looks for gen_co/gfx1250-strict and fails with a clear AITER_CHECK rather than loading a B0 object. That is what the plan asks for, so it is called out in the table's preamble instead of being listed as a gap. The scan now skips any site with a strict spelling within four lines, so the asm gate's own early return no longer pads the table and a site drops out once an owner has handled it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Count the tuned rows a strict device cannot use Tuned GEMM and MoE configs carry a gfx column and are looked up through get_gfx(), which reports gfx1250-strict on A0. 1620 rows across 18 config files are keyed to gfx1250 and none to gfx1250-strict, so on A0 every shape they cover falls back to the default path. That is what the plan asks for -- strict tuning has to be explicit and measured, not a filename alias -- so the generated table is the workstream 3 worklist rather than a defect list: each file needs either measured strict rows or a recorded decision that the B0 rows hold on A0. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Generate the module table's gfx1250 signal column The column was hand-filled and followed no single rule: 13 of 135 rows disagreed with any consistent reading of the sources, in both directions. module_custom_all_reduce_gfx1250 was marked by its module name while module_cache was marked `guard` although its sources also compare against the "gfx1250" string literal. Owners use this column to decide where to look, so wrong values send them to the wrong file. --refresh-signals now computes it from the sources that core.get_args_of_build actually resolves, falling back to the raw config expressions for the tune and experimental modules that call skips. The markers are explicit and can combine: `name` for the module name, `str` for the "gfx1250" string literal, `macro` for the __gfx1250__ guard. The distinction matters for A0 risk. `macro` rows keep compiling, because the strict target defines both __gfx1250_strict__ and __gfx1250__. `str` rows are the runtime decisions a strict device silently misses. The refresh changed 27 cells and is idempotent. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Tie the three arch tables together with a test Adding a target means editing GFX_MAP, GFX_CU_NUM_MAP and core.py's allowed_archs, and nothing tied them together. allowed_archs carried a duplicate "gfx1250" entry until this series removed it, which is what that drift looks like in practice. Two invariants hold today and are now pinned: every arch with an offline CU default is accepted by validate_and_update_archs and maps back through GFX_MAP, and gfx1250-strict does the same. Deleting gfx1250-strict from allowed_archs fails both tests, so a half-landed target is caught in CPU-only CI rather than at build time. The check is behavioural -- it drives validate_and_update_archs and get_gfx_custom_op_core with GPU_ARCHS set -- so it also covers the arch reaching hipcc unchanged as --offload-arch, hyphen included. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Record CK modules as skipped when the submodule is not checked out aiter's CK-free auto-exclusion tests os.path.isdir(CK_3RDPARTY_DIR), which is True for an uninitialised submodule: the directory exists, it is simply empty. A checkout without `git submodule update` therefore still tries to build the CK modules, and they fail on missing sources. core._get_ck_exclude_modules() reports 69 of the 135 modules as CK-dependent, so on such a checkout more than half the build matrix would fill with failures that say nothing about the strict target. The driver now treats an empty composable_kernel directory as CK-free and records those modules as skip-no-ck, keeping pass/fail for results that are actually about gfx1250-strict. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Pin PYTORCH_ROCM_ARCH in the build driver Setting GPU_ARCHS alone does not reach the compiler. torch's cpp_extension takes --offload-arch from PYTORCH_ROCM_ARCH, so with GPU_ARCHS=gfx1250 the modules still compiled for torch's own default list -- observed in a ROCm 10.0.0 container as --offload-arch=gfx90a ... --offload-arch=gfx1151 with no gfx1250 anywhere. Every row of the matrix would have been a result for the wrong architectures while looking like a validated one. The driver now derives PYTORCH_ROCM_ARCH from GPU_ARCHS; with that fixed, module_aiter_unary builds for gfx1250 and build.ninja carries exactly one --offload-arch. Failures also kept the wrong 15 lines: ninja echoes the whole compile command, which pushes the diagnostic out of a plain tail, so a failing module recorded only the Python traceback. The recorded tail now leads with up to five "error:" lines. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Record what ROCm 10.0.0 does and does not provide for strict Checked in rocm/atom-dev:latest-rocm10.0 -- ROCm 10.0.0, AMD clang 23.0.0git (ROCm/llvm-project 8f497e0992fb), HIP 7.15.26333. hipcc compiles gfx942 and gfx1250 and rejects gfx1250-strict as an unsupported HIP gpu architecture. The processor list is gfx1250 and gfx1251, and neither libLLVM nor amdclang contains the string gfx1250-strict or __gfx1250_strict__ at all. The only A0/B0 notion in that toolchain is the AMDGPU subtarget feature gfx1250-b0-specific, and it is not reachable from the driver: not a processor, rejected inside a target id, and ignored as a clang target feature. So the build matrix cannot be filled from the public ROCm 10 container -- the plan's toolchain dependency is unmet rather than satisfied -- and there is a question worth settling before the identity model is locked in. If the mechanism that ships is a subtarget feature on gfx1250 rather than a separate processor name, an A0 and a B0 object both carry the target id gfx1250, which is exactly what _so_offload_archs reads, so that guard would need a different discriminator. The survey records the evidence and the question without presuming the answer. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Lead the recorded failure tail with the real compiler diagnostic The error capture grabbed the first five lines containing "error:", which on a failing build are usually the Python RuntimeError and CalledProcessError wrapper lines, not the compiler's own message. Prefer "file:line:col: error:" frontend diagnostics when present, fall back to any "error:" line otherwise (backend errors such as the gfx1250 DPP rejection have no file:line prefix), and de-duplicate -- clang repeats each diagnostic once per offload arch. Verified against a real ROCm 10 matrix run: the ck_tile "extraneous closing brace" / "template exec" and ck "operator[] in Tuple<>" errors now lead their tails instead of the wrapper, and the opus DPP "broadcasts are not supported on GFX10+" backend error still surfaces via the fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Record the measured gfx1250 build matrix on ROCm 10.0.0 Ran the full 135-module matrix in rocm/atom-dev:latest-rocm10.0 with GPU_ARCHS/PYTORCH_ROCM_ARCH=gfx1250: 102 pass, 21 fail, 12 skip. Strict itself does not compile in this toolchain, so this is the gfx1250 baseline -- anything that fails for gfx1250 cannot build for strict, which is gfx1250 plus an A0 code-object identity. Every failure was rebuilt for gfx942 as a control, which corrected my first read of them. They are not a ROCm-10/clang-23 regression: 18 of 21 build cleanly on gfx942 and fail only on gfx1250, and the 3 FMHA-bwd modules that timed out on gfx942 were compiling without error (module_mha_bwd from the same family finished and passed). Every failure is a genuine gfx1250 porting gap: - DPP broadcast dpp_ctrl modes GFX12 removed (moe_sorting_opus, moe_mxfp4_aux) - MFMA / buffer-load-LDS intrinsics GFX12 lacks (iq2r_moe, mha_fwd_native_splitkv) - a wavefrontsize64 request on a wave32 part (chunk_gdr_fwd_h) - warp-size and gfx950-trait static assertions (topk_plain, moe_opus) - CK's ck_tile TDM path, selected on gfx1250 by CK_TILE_USE_BUFFER_ADDRESSING_BUILTIN=0 (the cktile/blockscale GEMMs, activation, sample, the ck_tile FMHA fwd/prefill) - fmha-v3-bwd asm configs not generated for gfx1250 (the mha_bwd family) The inventory now carries the result table with the gfx942 control column and the per-module cause, as the workstream-2 porting worklist. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Correct the strict macro model and inventory __gfx1250__ guards The plan claimed the strict target defines both __gfx1250_strict__ and __gfx1250__, so existing __gfx1250__ guards keep compiling. ROCm 10.1's actual behaviour is the opposite: strict defines __gfx1250_strict__ and does NOT define __gfx1250__ (ROCm/rocm-systems#12068). A __gfx1250__-only device guard therefore compiles its body away on a strict agent -- a silent empty kernel, the upstream TDM_Basic_load_2d failure, with no build error. JAX hit the matching compiler-side fact and dropped strict from its ROCm 10.0 defaults (jax-ml/jax#41187), and ROCm 10.1 adds gfx1250-strict as a distinct --offload-arch target across the stack (RCCL, CK, rocSHMEM), which confirms this PR's distinct-name identity model and the .so guard that keys on it. Fixes, docs only -- no source guard is touched, because the change must not break the shipping ROCm 7 build, whose compiler knows only __gfx1250__ and has no strict target: - plan and inventory legend now state the real macro behaviour and the backward-compatible fix, `defined(__gfx1250__) || defined(__gfx1250_strict__)`, whose strict arm is simply never taken on ROCm 7. - the ROCm 10.0 survey's open "name vs feature" question is resolved: 10.1 ships a distinct target name; the 10.0 gfx1250-b0-specific subtarget feature was an early-LLVM artifact. - ws2_gfx1250_dispatch_sites.py now also inventories the __gfx1250__ preprocessor guards (95 across 24 csrc files) as a generated review table, flagging which already combine with ||/&& to read first. This is the class the earlier string-comparison scan did not cover. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Make every __gfx1250__ device guard also fire on strict Non-asm operators are meant to run on both MI450 SKUs (A0 = gfx1250-strict, B0 = gfx1250); only the shipped asm is B0-only. But the strict compiler defines __gfx1250_strict__ and not __gfx1250__, so every `#if defined(__gfx1250__)` device guard took its #else branch on a strict build -- a silent wrong path that still compiles. Read on A0 this is: get_smem_size returning 64 KB instead of 320 KB, mhc falling back to fp32 instead of the WMMA path, make_gmem returning the 0xffffffff sentinel so stores drop, and the TDM sync counters using the legacy lgkmcnt/vmcnt instead of the split dscnt/loadcnt. Rewrite all 97 `defined(__gfx1250__)` occurrences across 24 csrc files to `(defined(__gfx1250__) || defined(__gfx1250_strict__))`. The parentheses keep it correct in every context: positive guards, `!(...)` exclusion lists (strict is excluded exactly as gfx1250 is), and `||`/`&&` family lists. The strict arm is never taken on the shipping ROCm 7 build, which has no strict target, so that build is unaffected. Compile-verified on ROCm 10.1 (clang 24.0.0git) for both gfx1250-strict and gfx1250 on module_mhc and module_top_k_per_row; both pass for both targets at low parallelism (the earlier full-matrix failures for these were -j179 contention, not real). Runtime correctness on A0 is left to the daily A0 op-test once the modules are built as gfx1250-strict. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the compiled-path gfx1250 dispatch comparisons Non-asm operators run on both MI450 SKUs, and strict is gfx1250 (A0) hardware, so a `get_gfx() == "gfx1250"` dispatch that selects a compiled path must also fire on gfx1250-strict -- otherwise A0 silently takes the generic fallback and, where the gfx1250 branch picks an arch-specific layout (wave32 tiling, LDS budget), gets a wrong result, not just a slow one. Rewrite the 101 compiled-path comparisons across 51 files from `== "gfx1250"` / `in ("gfx1250",)` to `in ("gfx1250", "gfx1250-strict")`. Deliberately NOT changed: the one asm-selecting dispatch, gemm_op_a4w4.py `if gfx_arch in ["gfx1250"]`. Adding strict there would route A0 into the f4gemm asm path, which the asm gate then throws on -- and the policy is that asm is simply unavailable on A0, so strict must keep missing that comparison and fall to the compiled path. The classifier that split compiled from asm sites flagged exactly this one site. py_compile, ruff and black clean (topk.py's pre-existing fmt:skip parse issue aside); the CPU-only arch/dispatch tests still pass. Multi-element arch allowlists (gluon_archs, SUPPORTED_ARCHS) are left for a follow-up -- those are a capability/feature gap on strict, not the correctness-level layout divergence this commit closes. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Cover != "gfx1250" and post-merge dispatch sites for strict The first dispatch pass only rewrote == and single-element `in (...)` comparisons, so `!= "gfx1250"` negations were left behind -- on strict `arch != "gfx1250"` is True and the kernel takes the non-gfx1250 branch, the same silent-wrong-path class the == sites had. The main merge also added fresh gfx1250 comparisons (flydsl pa_decode, triton quant/mla, mla backend plan). Fix the 30 compiled-path sites: `!= "gfx1250"` -> `not in ("gfx1250", "gfx1250-strict")`, `== "gfx1250"` -> `in (...)`. Three asm-selecting sites are deliberately left (attention.py:1752, mha.py:3779, mla_sparse_prefill.py:100) so strict keeps missing them and A0 errors on asm rather than loading it, per the policy that asm is unavailable on A0. py_compile, ruff and black clean; CPU-only arch tests pass. Only the three asm sites now compare against the bare "gfx1250" literal. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the C++ arch_id == "gfx1250" dispatch comparisons get_gpu_arch() in aiter_hip_common.h keeps the full target id, so a strict device reports "gfx1250-strict" and every `arch_id == "gfx1250"` branch in csrc misses -- the same silent-wrong-path class the Python and __gfx1250__ guards had. has_tdm_arch() returned false on strict even though A0 has TDM; mha_bwd picked the wrong launch geometry; and so on. Rewrite the 28 comparisons across 14 files: `X == "gfx1250"` -> `(X == "gfx1250" || X == "gfx1250-strict")`, `X != "gfx1250"` -> `(X != "gfx1250" && X != "gfx1250-strict")`, where X is a plain identifier or get_gpu_arch(). The asm-dispatch sites are included too: the actual asm load still funnels through require_gfx1250_asm_or_throw, which throws on A0, so computing the dispatch as gfx1250 is safe and A0 still cannot load asm. The already-strict-aware asm gate in aiter_hip_common.h is left untouched. Paren balance verified; the gfx942/gfx950 C++ build in CI compiles it. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the multi-element arch allowlists The capability allowlists -- gluon_archs, SUPPORTED_ARCHS, _SUPPORTED_GFX, DEVICE_ARCH tuples, the triton tuning kernel decorators -- list gfx1250 as a supported arch but not gfx1250-strict, so strict (which is gfx1250 hardware) was treated as unsupported: no gluon path, excluded from the tuned kernel sets, etc. Add "gfx1250-strict" next to each "gfx1250" element in those arch tuples and lists (41 across 22 files), skipping the substring-match helper (quick_all_reduce's `gfx in arch`, where "gfx1250" already matches "gfx1250-strict") and any asm-selecting context. With the gemm_a4w4 path main restructured, the gfx1250 branch now routes plain MXFP4 to FlyDSL and the rest to asm, so strict correctly gets the FlyDSL path and the asm gate still handles A0. ruff and black clean; CPU-only arch tests pass. This closes the last aiter-side strict dispatch gap; what remains is A0 runtime validation and the Opus .co rebuild. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Pin flydsl to 0.4.0.dev973 for gfx1250-strict LDS support FlyDSL's arch handling is otherwise strict-ready because it matches by prefix (arch.startswith("gfx1250") / "gfx12"), which gfx1250-strict satisfies -- WMMA instruction selection, warp_size (32) and the compile target all come out right. The one gap was the LDS-capacity map, keyed on the exact "gfx1250" string, so on strict the lookup missed and check_smem_capacity silently skipped the overflow guard. 0.4.0.dev973 adds "gfx1250-strict": 327680 to SMEM_CAPACITY_MAP (now in flydsl.runtime.device), closing that gap. Bump the pin in requirements.txt and setup.py (the version assertion and auto-install both derive from FLYDSL_VERSION). Revert to the default release once the fix ships there. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Clean up: drop investigation tooling, tidy strict macro guards Self-review cleanup, no behaviour change: - Remove the ws2_* enumeration/matrix scripts and the generated kernel-inventory doc. Those were one-off investigation flow (build matrix, dispatch-site enumeration) and do not belong in the repo; nothing in aiter imports them. - Drop the dangling "former hotswap path" bullet from the enablement plan; the term exists nowhere in the tree. - Flatten the redundant parentheses the strict sweep left behind: the mechanical `defined(__gfx1250__)` -> `(defined(__gfx1250__) || defined(__gfx1250_strict__))` wrapped the pair even inside OR chains. Unwrap it where the context is pure-OR (90 sites); keep the parentheses only where they are load-bearing -- negation `!(...)` and `&&` operands (7 sites). Compile-verified on ROCm 10.1 for both gfx1250-strict and gfx1250 (module_mhc, module_top_k_per_row); CPU-only arch tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: pin flydsl build-system dep to 0.4.0.dev973 to match setup.py pyproject.toml build-system.requires still pinned flydsl==0.4.0 while setup.py (FLYDSL_VERSION) and requirements.txt use 0.4.0.dev973. Under build isolation pip installed 0.4.0 as the build dep, then setup.py's version assertion rejected it and the build failed. Align all three. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: asm-gate error message covers both A0 detection routes The gate blocks B0 asm on A0 via two routes: gcnArchName == gfx1250-strict, or gcnArchName == gfx1250 with asicRevision 0. The message hardcoded 'gfx1250-strict/A0', which misleads when A0 is caught by the asicRevision route (device name is literally gfx1250, rev 0). State both forms. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: strict Opus codegen + 4 CI-red CPU tests gen_instances: GPU_ARCHS=gfx1250-strict looked up KERNEL_REGISTRY by the strict name, which has no registry key, so Opus codegen emitted an empty header and module_deepgemm_opus failed to build (the only strict-specific failure of the strict build matrix). Fold the registry key to the gfx1250 family (mirroring chip_info._detect_native) while keeping the gfx1250-strict build target, so hipcc still compiles for mach 0xeb. Strict now resolves to 256 CU, same as gfx1250. Tests (Draft CI had skipped these): - test_opus_co_profile load_chip_parsers: keep the _GFX_ARCH_PATTERN constant in the extracted AST namespace (the strict PR added it; parsers NameError'd). - test_build_targets preserve->normalize: _detect_native now folds strict to gfx1250 for dispatch; assert the new behavior. - test_launcher_does_not_pin_the_first_device: use the first declared local kid instead of hard-coded global kid 21016 (removed by #6937). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: strict Opus codegen emits the gfx1250 family (routes>0), not an empty module The earlier fix only folded the target list; the real route generation still queried the registry by the strict name and produced routes=0 (empty module_deepgemm_opus). Apply the gfx1250 family name at every registry/namespace lookup -- available's 'if gfx in arches', get_registry, default_compiled_keys -- and at the OPUS_BUILD_HAS_* macro (C checks #ifdef OPUS_BUILD_HAS_GFX1250, and a hyphenated STRICT macro is invalid C). KernelKey and the build target keep the gfx1250-strict spelling, so hipcc still offloads for mach 0xeb. Verified: GPU_ARCHS=gfx1250-strict now yields routes=228 (== gfx1250) with OPUS_BUILD_HAS_GFX1250; CPU tests stay green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Opus codegen: normalize gfx1250-strict targets to the gfx1250 family at the source Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: bump flydsl pin to 0.4.0 to match main (dev973 would downgrade it on merge) main pins flydsl==0.4.0; this PR still carried the 0.4.0.dev973 prerelease, so merging would silently downgrade the whole repo. 0.4.0 is a superset of dev973 (contains the gfx1250-strict LDS fix) and is what main already uses. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test: drop redundant test_strict_resolves_through_all_three_tables test_every_offline_target_resolves_through_all_three_tables already loops over GFX_CU_NUM_MAP, which contains gfx1250-strict, so the strict-specific case was an exact duplicate of one loop iteration. * fix: avoid 'in' tuple test in gluon kernel constexpr (unsupported by gluon) The strict-allowlist sweep turned 'ARCH == "gfx1250"' into 'ARCH in ("gfx1250", "gfx1250-strict")' inside gluon kernel bodies/constexpr. Triton's gluon compiler does not implement the 'In' AST operator, so these kernels failed to compile ('AST comparison operator In is not implemented'), breaking test_pa_mqa_logits_2d_context_lens[gluon*] on gfx942/gfx950. Use '(x == a or x == b)', which gluon supports, in kernel scope. Host-side Python 'in' checks are unaffected and left as-is. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Preserve exact gfx1250-strict identity; map to gfx1250 family only at dispatch Per the ROCr rollout contract (all SW consumes the exact GFX ID ROCr reports), global normalization in _detect_native() is the wrong boundary. Once ROCr reports gfx1250-strict for A0, folding it to gfx1250 there makes _needs_arch_rebuild() treat a strict .so as not covering a strict device and rebuild in a loop; it also remixes A0/B0 in tuned configs, caches, and logs. - chip_info._detect_native: drop the strict->gfx1250 fold; return the exact ROCr-reported identity. get_gfx_runtime()/get_gfx() now report gfx1250-strict on A0. - build_targets.py: add the single source of truth for family folding -- GFX_BASE_ARCH, base_gfx_arch(), is_gfx1250_family(). Torch-free, so build scripts and tests import it without side effects. - Opus: replace its two private strict->gfx1250 folds (gen_instances _registry_arch, opus_gemm_common _get_registry_records/get_registry/ default_compiled_keys) with base_gfx_arch(), so there is no second mapping. hipcc still gets --offload-arch=gfx1250-strict and the .co stays mach-0xeb. - mega_moe _require_gfx1250: restore the gfx1250-family guard (via is_gfx1250_family) that main's #6430 refactor collapsed to bare gfx1250. - Build/cache/tuning/.so/.co/ASM keep the exact identity: _needs_arch_rebuild and _so_offload_archs already key on it, so A0 never loads a B0 object. - Pre-existing gfx1250-only dispatch sites authored by other PRs stay exact; with the fold gone they correctly distinguish strict (fall back) instead of silently reusing a B0 path. - Tests: flip the native-detection test into a regression lock that strict identity is preserved; add family-helper and 4-way code-object rebuild-guard tests (runtime/built strict x gfx1250 -> accept/reject). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Apply ruff import sort and black formatting to the identity refactor Fixes the pre-checks (ruff I001 import order in mega_moe, black reformat of mega_moe and test_build_targets_architecture) that gated check-signal and skipped the Triton/Aiter test runs. No logic change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * black: wrap the long gfx1250/gfx1250-strict dispatch conditions in the gluon kernels The in->or fix in the pa_mqa_logits / unified_attention_2d gluon kernels left two over-length boolean conditions that Black wraps. Formatting only; the gluon compiler still sees the same (x == a or x == b) expression. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Define Opus base_gfx_arch locally instead of importing build_targets The cross-package `from build_targets import base_gfx_arch` (via a __file__-relative sys.path insert) breaks the Aiter wheel build: gen_instances.py runs from a staging tree (aiter_meta/csrc/opus_gemm) where ../../aiter/jit/utils does not exist, so module_deepgemm_opus failed with ModuleNotFoundError: No module named 'build_targets'. Duplicate the one-line helper locally in opus_gemm_common (documented to mirror build_targets.base_gfx_arch) so the standalone Opus codegen has no cross-tree import dependency. gen_instances keeps importing it from opus_gemm_common. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test(jit_cache): seed _cluster_launch_target in the build_module sandbox test_jit_cache_transaction AST-extracts build_module into a sandbox namespace with CPU deps injected. Since the gfx1250-strict work added a _cluster_launch_target(get_gfx) call inside MainFunc, the sandbox hit NameError: name '_cluster_launch_target' is not defined (25 TestBuildPublication errors on MI35X). This surfaced only now because the earlier Opus wheel-build failure skipped the standard tests. Inject the dependency like the others; for the gfx942 test context the real function returns False, so the mock matches. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: root <[email protected]>
* CI: auto-update split test times (#7290) Co-authored-by: gyohuangxin <[email protected]> * [HIP] [FlyDSL] perf(mega_moe): fuse the gfx1250 compact dispatch and GEMM1 into one stage-1 kernel (#6564) * [ASM] [HIP] [OPUS] Add gfx950 MLA v4.1 a8w4 prefill kernels for an NVFP4 prefix KV (#7124) * Add a gfx950 MLA v4.1 a8w4 prefill kernel for an NVFP4 prefix KV * Add a gfx950 MLA v4.1 a8w4 16mx4_64nx1 prefill kernel and run the NVFP4 prefix in f16 * Run the dsa_v41 a8w4 NVFP4 prefix in bf16 to keep MXFP8 Q exact * [Perf] Avoid torch Stream construction across grouped MoE launches (#7219) * Avoid constructing a torch Stream for default grouped GEMM launches * Reuse raw stream arguments through MoE route, quant and reduction wrappers * [Bugfix] MLA decode: merge only the splits gfx950 bf16 gqa32 stage 1 writes (#7182) On gfx950, mla_a16w16_qh16_m16x4_n32x1_coex0_mask1 (bf16, gqa 32, non-persistent) deals KV to splits round-robin in 32-token tiles and exits without writing a split that gets no tile. mla_decode_fwd used mgc = 16 for nhead 32, so stage 2 merged min(splits, cdiv(kv, 16)) splits and read up to twice as many as stage 1 wrote, from torch.empty buffers. Rows with less KV than splits * 32 came back wrong, or NaN when that memory held NaN. Use mgc = 32 for this kernel, as the fp8 qh64 kernel already does with mgc = 64. gfx942's gqa32 kernel uses 16-token tiles and keeps mgc = 16. The new op test runs that case with NaN-filled split buffers. Signed-off-by: Batzorig Zorigoo <[email protected]> * [Config] [gfx1250] Tune MiniMax-M3 TP4 BF16, indexer-CP QKV and MoE token 1024 (#7209) * [Triton/Gluon] Window-aware split-KV for sliding-window verify on gfx950 (#6889) * [Triton/Gluon] Split window-trimmed sliding-window verify on gfx950 On gfx950 a sliding-window call with q > 1 never takes the split grid (_gfx950_split_grid returns False, and kv_split["SW"] caps MAX_SEGMENTS at 1), so a spec-decode verify on a sliding layer runs num_kv_heads programs per sequence over the whole window. Splitting it only pays once the KV range is cut to the window: the split carves seq_len, so over a full context the window lands in one or two segments and the rest are empty (31.9-37.6 us vs 29 us unsplit when forced). Split only when the KV range is bounded by the window. Row i of a q-row sequence of length L reads keys from L - q + i - (SW - 1) on, so a block table trimmed to whole pages holds at most SW + q - 1 + block_size - 1 keys. The new SWB config axis is sliding_window_bounds_kv(): q > 1 and max_seqlen_k <= sliding_window + max_seqlen_q + block_size - 2. A batch whose contexts are all that short is bounded as well, trimmed or not, and takes the same path. _gfx950_split_grid lets verify-sized SWB calls (max_seqlen_q <= 16 and max_seqlen_q * num_queries_per_kv <= 128) through and then decides like any other batch (NUM_SEGMENTS > 1). Longer queries (prefill chunks) keep the 2d grid: with q rows per sequence in the reduce, MHA q = 128 at window 256-512 ran up to 1.33x slower split. The gfx950 gluon kv_split table gains an "SW.SWB" entry, the SW entry without its segment cap, plus: - SPLIT_FIT_BUDGET (new): the largest power-of-two split that keeps the launch within SEGMENTS_PER_CU (1) programs per CU, sized by the real one-block-per-sequence query grid (_gfx950_split_params). The default ceil-rounded share splits 2 ways up to B = 51 and loses 30-40% from B = 36 (39.7-43.0 us vs 30.4-30.8 us on the 2d grid). - SPLIT_KV_WINDOW (new): count the KV tiles over the sliding_window + max_seqlen_q - 1 keys the rows can see, not the page slack of a trimmed table, so SPLIT_MIN_TILES 4 keeps window 128 unsplit at block 128 too (64 q / 8 kv heads, q = 4: 8.2 us split vs 6.7 us 2d). - SPLIT_SEQS_PER_TILE 1.5 (new): no split once num_seqs exceeds 1.5 x the KV tiles. The triton reduce_segments pass that every gfx950 split pays costs more with the batch (7.6 us at B = 32, 2 segments), while the 2d kernel's time follows the KV length, so at windows 256-1024 a split at B = 12-32 ran up to 1.87x slower than the 2d grid. Kernel: a split whose tiles all fall before the window start stores an empty partial, and split 0 is the only one that counts the attention sink, so a window starting past tile 0 (block size > 64, or a shorter row in an untrimmed bounded batch) dropped the sink from the softmax. The empty-partial path of split 0 now stores M = sink, L = 1. Unchanged dispatch: SW calls with a context past the bound, SW decode (q == 1 keeps the cap), q > 16, window 128, full attention, gfx1250 and the triton backend. Of 328,800 no-launch shapes (window 128-32768, q 1-128, B 1-128, 5 head layouts, D 64-256, bf16/fp8, block 16-256, ctx bound -300..+5000) only gluon SW calls with 1 < q <= 16 inside the bound change grid (22,392). MI355X, 16 q / 2 kv heads, head 64, bf16, block 16, window 2048, q = 8, ctx 32768 (us per call, CUDA-graph replay, natural dispatch): B 1 2 4 8 16 32 48 64 full 29.0 29.0 29.1 29.5 30.0 30.5 30.6 30.9 trimmed 6.7 7.2 8.6 10.9 15.8 25.1 30.6 30.8 segments 64 32 16 8 4 2 2d 2d Full-attention floor at 2056 keys: 6.6 / 6.8 / 8.1 / 9.4 / 14.4 / 21.9. The natural pick matches the fastest forced count (1-128) at every B. Shorter windows, trimmed, same heads (base 2d -> split, us): W 512: B4 9.78 -> 6.79, B8 9.79 -> 7.61, B12 9.82 -> 9.19, B16+ 2d W 1024: B4 16.30 -> 7.66, B8 16.35 -> 8.61, B16 16.71 -> 12.27, B32 2d W 256: B4 6.54 -> 6.30, B8+ 2d Known cost: a caller that captures a graph at max_seqlen_k = window bound and replays it for batches whose real contexts are a few hundred keys pays the split + reduce where the 2d kernel was cheaper (B >= 12, ctx <= 1000). A cheaper gfx950 reduce would remove that. Test: test_triton_unified_attn_sw_verify_split (full and trimmed tables vs reference with a dominant sink, exact segment counts: trimmed verify splits, full context stays 2d, SW decode stays 1 segment, q = 17 and q = 128 prefill chunks stay 2d, block 128 and an untrimmed bounded batch leave split 0 empty) and test_unified_attn_sw_kv_split_config (CPU-only kv_split picks at the bound edge, untrimmed, decode, window 128, and the batch sizes where the split stops). Signed-off-by: Oxana Korzh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * [Triton/Gluon] Drop SPLIT_KV_WINDOW; clamp every window-bounded split Review follow-up. The SPLIT_KV_WINDOW knob was set only in the SW.SWB entry, so it configured nothing. compute_segment_params now counts KV tiles over the sliding_window + max_seqlen_q - 1 keys the rows can see whenever sliding_window_bounds_kv() holds, with no config switch. The clamp is gated on the bound, not on sliding_window > 0. The split carves the whole seq_len, so on an untrimmed long context a window-sized count leaves most segments idle. No unbounded sliding-window call reaches a split lookup today, so the two gates pick the same grid. CPU dispatch sweep vs the previous commit, 2,048,256 shapes per arch on gfx950 (gluon and triton), gfx1250, gfx1100 and gfx1201: no 2d/3d, NUM_SEGMENTS or TILE_SIZE change. 1,184 gfx950 gluon shapes change only the triton reduce num_warps (head 256, block >= 64, window + q - 1 of about 257-512), since the reduce lookup now sees the same clamped length. test_unified_attn_sw_kv_split_config: 11 passed on CPU; removing the clamp fails the window 128, block 128 case. Signed-off-by: Oxana Korzh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * [Triton/Gluon] Key the SWA split on window size: numeric SW axis Review follow-up. The SW axis was a bool, so a table could not target a window size. SW is now "opt_num": the keys a row can see, min(sliding_window, max_seqlen_k), floored at 1, and 0 with no window. SW_EQ/LEQ/GEQ_<n> keys pick by size, a bare SW matches any window, and no window matches only "any". Tables that only use a bare SW key (gfx950 gluon and triton, gfx1250 gluon, gfx1201 triton) resolve as before. _index rejects a table that mixes SW_LEQ and SW_GEQ keys, because every matching LEQ key would outrank every GEQ key. It is cached on the key names, so the check runs once per table. The gfx950 gluon kv_split entry SW.SWB becomes SW_GEQ_256.SWB. Bare SW, with MAX_SEGMENTS 1, stays the fallback for every other window and for SW decode. 256 keys is 4 tiles of 64, the smallest window measured to win. Window 128 now falls back through the threshold, not SPLIT_MIN_TILES. SWB stays: an untrimmed long context also gives SW = window, and splitting that table was measured slower. CPU dispatch sweep vs the previous commit, 3,692,160 shapes per arch (grid, NUM_SEGMENTS, reduce config, and attn_2d/attn_3d configs for both backends) on gfx950, gfx1250, gfx1100 and gfx1201: the only change is 6,300 gfx950 gluon shapes at window 255 (q 4-16, just under the threshold), split -> 2d. Windows above 2048 still split; their perf is not measured. Tests: test_unified_attn_sw_kv_split_config gains window 255 vs 256 at the threshold and window 256 at block 128 (the clamp case). test_unified_attn_sw_axis_lookup covers the candidate order, the axis value and its floor, and the LEQ/GEQ guard. 15 passed on CPU. Each of these mutants fails at least one test: threshold, clamp, guard, bare-SW fallback, the no-window check, min(), and the floor. Signed-off-by: Oxana Korzh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * [Triton/Gluon] Test the SWA split without sinks on long pages Review follow-up (Copilot). Without sinks, a sliding-window split over a bounded table whose page is much longer than a tile can leave 32 or more empty leading segments. One example is head 256, q 8, KV 10246, window 2048, block 8192, 64 segments. Before #6888 that made the first SEGMENT_BLOCK chunk of reduce_segments all -inf, and the merge returned NaN. #6888's two-pass merge takes the global max first, so those chunks now weigh 0. Under TRITON_INTERPRET=1, main's reduce_segments on the partials both shapes leave gives no NaN and matches the single-chunk reduce within 1.2e-7. test_triton_unified_attn_sw_split_no_sinks runs both of Copilot's shapes on gfx950 with head 256 and no sinks, against the reference. Signed-off-by: Oxana Korzh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * [Triton/Gluon] SWA split tests: check accuracy only Review follow-up. Tests here target accuracy, not configs or routing. - Remove test_unified_attn_sw_kv_split_config and test_unified_attn_sw_axis_lookup. They pinned kv_split picks and lookup order, which couples the tests to the tuned configs and heuristics. - test_triton_unified_attn_sw_verify_split and test_triton_unified_attn_sw_split_no_sinks no longer record or assert the grid. Both still compare full and trimmed tables, or the no-sink long-page shapes, against the reference. Signed-off-by: Oxana Korzh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * [Triton/Gluon] Window-aware split-KV for sliding-window attention With a sliding window, every split-KV launch carved [0, seq_len) into NUM_SEGMENTS tile ranges, so over an untrimmed long context only the few segments that overlap the window did work. That is why this PR so far split only tables bounded by the window. Carve only the window instead. For SLIDING_WINDOW > 0 each sequence splits the tiles [tile_lo, cdiv(seq_len, TILE_SIZE)), where tile_lo is the tile of row 0's first visible key, max(context_len - SLIDING_WINDOW + 1, 0) // TILE_SIZE. It is per sequence, so every query block and the reduce agree. The split launch already puts a sequence's spec-decode rows in one query block when q * num_queries_per_kv <= 128. The window's tiles are now what gets split across the segment workgroups. - The gfx950 gluon split, kernel_unified_attention_3d and reduce_segments carve this way. The triton pair shares split_window_tiles, and reduce_segments gets SLIDING_WINDOW from the launch. The gfx1250 3d wrapper asserts no window: its split still carves seq_len, and use_2d_kernel never sends a window there. With no window, all three kernels compile to the same gfx950 instructions as before. - Dispatch: an untrimmed table now splits like a trimmed one. _gfx950_split_grid drops the bound check and keeps the q <= 16 and q * num_queries_per_kv <= 128 gates. The kv_len clamp applies to every sliding-window call. The SWB axis and sliding_window_bounds_kv are gone, and the split entry is SW_GEQ_256.Q_GEQ_2, so sliding-window decode stays on the capped bare SW entry. CPU dispatch sweep vs the previous commit, 3,692,160 shapes per arch: on gfx950 the only change is 75,220 gluon sliding-window calls with 1 < q <= 16 past the old bound going 2d -> split. Each gets exactly the dispatch the bounded table already had. gfx1250 and gfx1100 do not change. The existing accuracy tests now run the full-table rows through the window carve: test_triton_unified_attn_sw_verify_split and test_triton_unified_attn_sw_split_no_sinks. Signed-off-by: Oxana Korzh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Signed-off-by: Oxana Korzh <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Satya Nikhil Kodukula <[email protected]> * [FlyDSL] gfx1201 (RDNA4) FlyDSL BF16 attention optimizations & FP8 attention implementation (#4188) * feat(flydsl): add per-tensor fp8 gfx1201 flash-attention kernel * feat(flydsl): generalize the gfx1201 bf16 flash-attention kernel and wire fp8 dispatch * feat(flydsl): fully-FlyDSL fp8 per-tensor quant+rotation for gfx1201 * refactor(flydsl): share and harden gfx1201 attention * test(flydsl): cover gfx1201 bf16 and fp8 attention * bench(flydsl): add gfx1201 fmha benchmark * merge(main): resolve gfx1201 FlyDSL attention conflict * fix(flydsl): validate attention softmax scale * fix(flydsl): address gfx1201 attention review * refactor(flydsl): centralize gfx1201 attention build parameters * test(flydsl): execute gfx1201 pytest suite in op-test shards * refactor(flydsl): share gfx1201 attention helpers and localize FP8 intrinsics * refactor(flydsl): clean up gfx1201 kernels * refactor(flydsl): organize gfx1201 FMHA modules * refactor(flydsl): localize gfx1201 stream readiness * refactor(flydsl): use typed pointers in fp8 quant * refactor(flydsl): use public gfx1201 kernel attributes * refactor(flydsl): export gfx1201 fp8 quant directly * test(flydsl): keep gfx1201 FMHA public regressions * feat(flydsl): add native gfx1201 1 FP8 quantization for more shapes * flydsl: simplify gfx1201 FMHA stream/quant integration * op_tests: modernize gfx1201 FMHA validation and benchmark * flydsl: harden gfx1201 FMHA stream validation and multi-device tests * flydsl: remove empty gfx1201 FMHA package init * flydsl: migrate gfx1201 FP8 flash-attn to FlyDSL buffer-view/copy API * flydsl: use static layouts and coordinate helpers for gfx1201 FP8 KV loads * flydsl: validate gfx1201 FP8 buffer indices against signed Int32 limits * flydsl: replace raw arith intrinsics with typed FlyDSL scalar/vector ops in gfx1201 FP8 FMHA * refactor(flydsl): use typed exp2 in gfx1201 BF16 attention * test(flydsl): tighten gfx1201 FMHA validation * refactor: modernize gfx1201 FlyDSL FP8 paths * test: consolidate FlyDSL gfx1201 op tests * fix: support wide FlyDSL FP8 quantizer loads * fix: validate FlyDSL quant offsets and stream coverage * fix(flydsl): harden gfx1201 FMHA correctness * fix(flydsl): align FP8 softmax normalization to prevent long-sequence normalization bias --------- Co-authored-by: vivienfanghuagood <[email protected]> Co-authored-by: Cursor <[email protected]> * [Triton/Gluon] Enable and tune pipelined unshuffled MLA decode on gfx1250 (#6545) * Allow the pipelined version of the kernel to be used * Add tuning config * More tuning changes * Pad fp8 rows * Update reduce waves_per_eu * Fit 64 heads into two waves * Add unit test * Formatting * Attend to Copilot review comments * Test fixes * Update tuning params * Attend to Copilot review comments * Fix formatting issues * Add extra guards * Add params to desc * Fix arch name for test * [Triton/Gluon] [Kernel] Add dual-layout H16 MXFP4 quantization (#6458) * [Triton/Gluon] [Kernel] Add dual-layout H16 MXFP4 quantization Fuse row-wise MXFP4 quantization with signed-H16 quantization of the transposed input. Support independent stochastic rounding and GEMM layouts on gfx950, with tests, benchmarks and a tuning configuration. Signed-off-by: DaiXindi-AMD <[email protected]> * [Misc] Rename fused MXFP4 tuning configuration directory Signed-off-by: DaiXindi-AMD <[email protected]> * [Bugfix] Address fused transpose Hadamard MXFP4 review feedback Use the specific fused API and config key, relocate the four unchanged device helpers to quant.py, and document sign validation and physical scale shapes. Fix module-object monkeypatching after the API/module rename. Validated all eight changed Python files with Ruff 0.16.0, Black 26.3.0 and 26.10.1, compile and diff checks. Kernel and helper AST equivalence plus isolated CPU helper checks passed. Full package import and GPU tests were not rerun: prior import/collection is blocked by missing Ninja, and no GPU allocation is authorized. Signed-off-by: DaiXindi-AMD <[email protected]> * [Docs] Use GPU graph capture terminology for H16 signs Signed-off-by: DaiXindi-AMD <[email protected]> * [Misc] Keep MXFP4 layout constants in the host utility Move the five unchanged layout constants to utils/mxfp4.py and remove the constants-only utils/_triton/mxfp4.py module. The public wrapper still passes the same values as constexpr arguments; device kernel and helper code remain unchanged. Signed-off-by: DaiXindi-AMD <[email protected]> --------- Signed-off-by: DaiXindi-AMD <[email protected]> * [Triton/Gluon] [Perf] fused_reduce_act_mul_and_mxfp4_quant: wider launch tile, add round_to_input_dtype and transpose_scale (#6024) * [Triton/Gluon] [Perf] fused_reduce_act_mul_and_mxfp4_quant: wider launch tile, add round_to_input_dtype and transpose_scale For N_half > 1024 (no shuffle, no scale padding, no split-K) launch one warp per row over 256 (M <= 64) or 512 columns instead of a 1x128 tile on 4 warps. On MI355X thats 1.02-3.77x faster over N_half 2048..28672 and M 1..8192 (9.85 -> 4.29 us at M=64, N_half=14336), output bytes unchanged. round_to_input_dtype rounds act(x) * x_mul to the input dtype before the quant, so the result is bitwise equal to act_mul in that dtype followed by dynamic_mxfp4_quant. transpose_scale (also added to fused_rms_mxfp4_quant) returns the scales column-major, the layout dynamic_mxfp4_quant returns. Both default to False. Signed-off-by: adlashab <[email protected]> * Fix a typo in the act_mul launch tile comment Signed-off-by: adlashab <[email protected]> * [Triton/Gluon] fused_reduce_act_mul_and_mxfp4_quant: honor scaling_mode="ceil" scaling_mode was accepted but the act_mul kernel always used the "even" scale. Pass it through to _mxfp4_quant_op, which already has "ceil" as SCALING_MODE 1: 2^ceil(log2(amax / 6)), the RoundUp scale per_1x32_f4_quant_hip uses by default. With round_to_input_dtype the output is then the same fp4 bytes and the same scales as silu_mul followed by per_1x32_f4_quant_hip, in the same scale layout (plain, padded or shuffled), so it can stand in for that quant in front of gemm_afp4wfp4_preshuffle / gemm_a4w4. That is what vLLM's MXFP4 linears on the ASM layout run. One difference: a 32-block thats all zeros gets scale byte 1 here and 92 from the HIP kernel. All its fp4 values are 0, so the GEMM output is the same. Also let the wider launch tile run with scale_shuffle_padding when shuffle is off. The padding only changes the allocation, the scale store is the same. New test against per_1x32_f4_quant_hip for plain, padded and shuffled scales. Signed-off-by: adlashab <[email protected]> * [Triton/Gluon] [Test] Check fused act_mul + MXFP4 quant against a torch reference Add a plain torch reference for the per-1x32 MXFP4 quant and compare fused_reduce_act_mul_and_mxfp4_quant against it bit for bit. The reference uses the shared CPU helpers from aiter.utility.fp4_utils: the e8m0 scale from f32_to_mx_e8m0_scale (Even for "even", RoundUp for "ceil"), then x / scale rounded to nearest even on the E2M1 grid with f32_to_mxfp4. The test covers both scaling modes, round_to_input_dtype on and off, bf16 and fp16 input, plain / transposed / padded / shuffled scales, odd M, and an all-zero 32-block at each end of the output. In "ceil" mode the Triton scale clamps amax to 6 * 2^-126, so an all-zero block gets scale 1 where RoundUp gives 0. The fp4 values of that block are 0 either way, the test expects 1. Also use device="cuda" in the tests this PR adds, like the rest of the file since #6783. Signed-off-by: adlashab <[email protected]> --------- Signed-off-by: adlashab <[email protected]> Co-authored-by: Shao-Chun Lee <[email protected]> * [CI] Run the selected Triton tests on each merge to main (#7229) Since #7029, main runs Triton Test only once a night, as the full suite. A merge that breaks a Triton test then shows up only the next day, and the nightly cannot say which merge it was. A push to main now runs Triton Test again, with the same test selection as a PR: the tests that the merged commit affects, against its parent on main. MI300X runs only when the selection asks for it, as on a PR. Each push gets a concurrency group of its own, so a merge no longer cancels the run of the one before. A push run does not wait for the pre-checks and does not post on the nightly status issue. The nightly and manual runs still run the full suite on MI35X and MI300X. Co-authored-by: Xin Huang <[email protected]> * [FlyDSL] [gfx1250] mega_moe S1F: reachable stage-1 hook, plan precompile, tuned defaults (on by default) (#7315) * [FlyDSL] [gfx1250] mega_moe S1F: reachable stage-1 hook, plan precompile, opt-in tuning knobs On top of the stage-1 fusion (#6564): - Fix: swap the stage-1 hook into dispatch_context as well as scatter. The grouped GEMM reads it off dispatch_context, so replacing scatter alone left the probe / fused stage-1 path unreachable on the compact path. - Precompile every stage-1 compact-plan variant at setup (compile only, AITER_S1F_PRECOMPILE=0 skips). Eager widths otherwise JIT-compiled inside the serving loop: 250-470 ms prefill steps for the first ~100 s of a run. - AITER_S1F_MAX_RECV=N: steps whose receive bound exceeds N run the whole S1F=0 path (plan, GEMM1, no probe), e.g. fuse decode only. - AITER_S1F_ANY_TILE=1: fuse when the tuned GEMM1's tile_m matches; the stage-1 kernel runs its own 256x256 n/k tiles. - AITER_S1F_PRODUCERS / AITER_S1F_BLOCK_RUNS: per tokens-per-rank bucket overrides of the stage-1 tables. - AITER_TDM_COMPACT_ROUTE_UPTO / _ROUTE_SPEC / _ROUTE_PARALLEL: keep the route-parallel compact walk up to N tokens per rank. All knobs default to the current behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]> * [FlyDSL] [gfx1250] mega_moe S1F: make S1F and its tuned settings the default Make S1F and its tuned settings the default on gfx1250; env vars become optional overrides. With nothing set, gfx1250 MegaMoE now runs the configuration measured on DSV4.1-Flash DEP4 (MI455X, MLPerf Endpoints agentic c512, +2.1% gen tok/s/GPU over S1F off): - AITER_MEGA_S1F: on by default; =0 turns the stage-1 fusion off. Configs or steps that do not fit still fall back to dispatch + GEMM1; the fallback logs at info level unless AITER_MEGA_S1F=1 was set explicitly. - S1F_BLOCK_RUNS table: (4, 2, 8, 8). AITER_S1F_BLOCK_RUNS / AITER_S1F_PRODUCERS still override the tables. - AITER_S1F_MAX_RECV: 4096 by default; 0 means no limit. - AITER_S1F_ANY_TILE: on by default; =0 requires all GEMM1 tiles to match. - AITER_TDM_COMPACT_ROUTE_UPTO / _ROUTE_SPEC: 1024 / 384,16 by default (config._COMPACT_ROUTE_UPTO / _SPEC); UPTO=0 keeps _DISPATCH_COMPACT. - AITER_S1F_PRECOMPILE stays on by default. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Read the new S1F/route env vars through the shared env module Register the env vars this PR adds or changes (AITER_MEGA_S1F, AITER_S1F_PRECOMPILE / MAX_RECV / ANY_TILE / PRODUCERS / BLOCK_RUNS, AITER_TDM_COMPACT_ROUTE_UPTO / SPEC / PARALLEL) in mega_moe/envs.py, with their defaults and parsing, and read them as envs.<NAME> instead of os.environ. Env vars that were already on main are left as they are. No behavior change. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Drop the new env vars; the tuned S1F/route settings are fixed defaults This PR no longer adds any environment variable. mega_moe/envs.py is back to main, and the settings tuned on DSV4.1-Flash DEP4 (MI455X, MLPerf Endpoints agentic c512) are now plain defaults: - stage-1 plans are always precompiled when S1F is on; - _S1F_MAX_RECV = 4096 (s1f_ctl.py); - GEMM1 fuses whenever its tile_m matches (stage-1 runs its own n/k tiles); - S1F_PRODUCERS / S1F_BLOCK_RUNS come from the s1f_stage1.py tables (block runs 4, 2, 8, 8); - the compact dispatch always walks routes up to _COMPACT_ROUTE_UPTO = 1024 tokens/rank with _COMPACT_ROUTE_SPEC = (384, 16) (config.py); the AITER_TDM_COMPACT_BLOCKS/WARPS override behaves as on main. AITER_MEGA_S1F keeps its original os.environ read; only its default changes to on (0 turns it off). S1F fallbacks log at info level. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> * [CI] Reuse FlyDSL AOT cache and reduce A8W8 GEMM test overhead (#7316) * [CI] Reduce A8W8 GEMM benchmark repetition and preserve scale-mode coverage Signed-off-by: yifehuan <[email protected]> * Use supported MXFP8 row sizes in focused numerical tests Signed-off-by: yifehuan <yifehuan@local> * [CI] Reuse FlyDSL AOT cache and sample A8W8 benchmark timing Signed-off-by: yifehuan <[email protected]> --------- Signed-off-by: yifehuan <[email protected]> Signed-off-by: yifehuan <yifehuan@local> Signed-off-by: yifehuan <[email protected]> Co-authored-by: yifehuan <[email protected]> Co-authored-by: yifehuan <yifehuan@local> * [FlyDSL] Fix grouped GEMM C ABI overflow for large EP buffers (#7299) Pass address-only grouped GEMM operands as typed pointers instead of flattened tensors. FlyDSL packs runtime tensor dimensions as int32, so buffers with more than 2^31-1 elements fail in the generated C ABI fill function. The EP arena handle remains a constexpr and is already excluded from runtime packing. Remove redundant scale-view normalization and replace its tests with host ABI coverage for large buffers, storage offsets, pitched layouts, cached dispatch, 48-bit addresses, and changed arena specializations. Signed-off-by: Felix Li <[email protected]> * [Triton/Gluon] [HIP] [OPUS] [AITERKER-209] Add gfx1250-strict architecture plumbing (#6767) * [JIT] Add gfx1250-strict architecture plumbing * [JIT] Fix ruff F821 and black formatting in gfx1250-strict plumbing Add the missing build_targets._parse_gpu_archs_env import in core.py (F821 flagged by CI ruff) and apply black to core.py and test_build_targets_architecture.py. Co-Authored-By: Claude Code <[email protected]> * [JIT] Add gfx1250-strict kernel inventory and WS2 build driver Skeleton inventory for every JIT/FlyDSL/Triton path plus the driver that fills its strict-build column from a strict-capable container. Driver verified offline on a non-strict host (module enumeration, child plumbing, skip classification, --update-md folding): - CHILD called os.chdir without importing os, so every module would have failed with NameError and the whole matrix would have read "fail". - optCompilerConfig lists 135 modules but get_args_of_build("all") yields 123. The other 12 are not failures: 10 end in "tune" (skipped by design) and 2 are experimental (gated by AITER_ENABLE_EXPERIMENTAL). They are now recorded as skip-tune / skip-experimental instead of "missing", so the matrix keeps an explicit result for all 135. Actual pass/fail rows still require the strict toolchain; stock ROCm 7.0.0 rejects gfx1250-strict as an invalid target ID. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Fix empty GPU_ARCHS raising out of build_module The gfx1250-strict plumbing routed GPU_ARCHS through build_targets._parse_gpu_archs_env, which raises when the value holds no architecture names. GPU_ARCHS set but empty -- what a Dockerfile's `ENV GPU_ARCHS=` or a bare `export GPU_ARCHS=` produces -- previously just meant "no cluster-launch flag, build normally"; it now raised RuntimeError inside build_module and failed every JIT build. Blank, whitespace-only and ";" values had the same problem. Fall back to the detected arch instead, matching aiter/ops/opus/_arch.py, which treats an empty or "native" GPU_ARCHS as "probe the device" and never raises. The arch test moves into _build_archs_from_env / _cluster_launch_target so it is reachable from a CPU-only test. Covered by TestClusterLaunchBuildArchs: blank/unset/"native" fall back to detection, explicit archs win, and -DAITER_ENABLE_CLUSTER_LAUNCH still follows gfx1250 or gfx1250-strict anywhere in a multi-arch GPU_ARCHS. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Inventory the gfx1250 dispatch sites a strict device silently misses The infra PR keeps gfx1250-strict distinct through parsing, build selection and the asm guard, but Python dispatch still compares against the exact literal "gfx1250". On A0 get_gfx() returns "gfx1250-strict", so those comparisons are False and the constant arch allowlists do not contain it: the gfx1250 path is skipped with no error, which reads as a kernel-selection change rather than a failure. ws2_gfx1250_dispatch_sites.py enumerates them -- 150 uses across 65 files, 132 runtime comparisons and 18 allowlist entries -- and records where the compared string comes from. get_gfx/get_gfx_runtime sites keep the hyphenated spelling and are known to miss; triton-arch sites read Triton's own target name, whose strict spelling stays unverified until the toolchain lands. The table is generated into the inventory between HTML markers and the rewrite is idempotent, so it can be refreshed as owners decide each site. No dispatch behaviour is changed here: every row is an explicit pending decision, which is what workstream 2 asks for. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Pin the offload-target parser against hyphenated target names _so_offload_archs backs the guard that keeps a gfx1250 and a gfx1250-strict .so from standing in for each other, so the shapes it must parse deserve a test of their own: a feature list after ':', the strict suffix, both together, and a ROCm generic target. The previous gfx\w+ pattern truncated at the first hyphen. That reported a strict .so as plain gfx1250 -- the substitution this guard exists to prevent -- and also read gfx9-4-generic as gfx9, which matches no running arch and so rebuilt such a module on every import. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Inventory the arch-keyed tables that have no strict entry The dispatch-site scan only saw comparisons against the "gfx1250" literal, which left a blind spot: tables keyed by architecture. A strict device is simply absent from those, so it takes whatever the lookup does with a missing key. Four of them carry a gfx1250 entry and no strict entry, and they do not behave alike: - radix_topk_one_block._LONG_RADIX_BY_ARCH and ._ONE_BLOCK_LDS_BUDGET_BYTES read with a default, so A0 quietly falls back to the generic radix layout and a zero LDS budget, losing the 320 KiB one-block path with nothing logged. - pa_decode's inline fp8 dtype table reads with .get() and raises NotImplementedError naming the arch -- the "fail clearly" behaviour the enablement plan asks for. - mhc.MHC_FUSED_POST_PRE_M_UPPER_BOUND reads with a default of 1024, which happens to equal the gfx1250 entry, so A0 is correct today only by coincidence. The generated table records the lookup style per row so the difference between a silent fallback and a clear failure is visible to the owner making the call. Behaviour is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Extend the gfx1250 site inventory to C++ and skip handled sites get_gpu_arch() in aiter_hip_common.h cuts the target id at ':' and keeps everything before it, so a strict device reports "gfx1250-strict" in C++ too and the arch_id == "gfx1250" branches miss exactly as the Python ones do. 27 of them across 14 files, 11 in mha_bwd.cu alone, where several pick launch geometry rather than a code path -- a miss changes a block size instead of raising. Worth recording for the Opus owner: opus_co_launch_gfx1250.cuh builds its code-object path from get_gpu_arch(), so A0 looks for gen_co/gfx1250-strict and fails with a clear AITER_CHECK rather than loading a B0 object. That is what the plan asks for, so it is called out in the table's preamble instead of being listed as a gap. The scan now skips any site with a strict spelling within four lines, so the asm gate's own early return no longer pads the table and a site drops out once an owner has handled it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Count the tuned rows a strict device cannot use Tuned GEMM and MoE configs carry a gfx column and are looked up through get_gfx(), which reports gfx1250-strict on A0. 1620 rows across 18 config files are keyed to gfx1250 and none to gfx1250-strict, so on A0 every shape they cover falls back to the default path. That is what the plan asks for -- strict tuning has to be explicit and measured, not a filename alias -- so the generated table is the workstream 3 worklist rather than a defect list: each file needs either measured strict rows or a recorded decision that the B0 rows hold on A0. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Generate the module table's gfx1250 signal column The column was hand-filled and followed no single rule: 13 of 135 rows disagreed with any consistent reading of the sources, in both directions. module_custom_all_reduce_gfx1250 was marked by its module name while module_cache was marked `guard` although its sources also compare against the "gfx1250" string literal. Owners use this column to decide where to look, so wrong values send them to the wrong file. --refresh-signals now computes it from the sources that core.get_args_of_build actually resolves, falling back to the raw config expressions for the tune and experimental modules that call skips. The markers are explicit and can combine: `name` for the module name, `str` for the "gfx1250" string literal, `macro` for the __gfx1250__ guard. The distinction matters for A0 risk. `macro` rows keep compiling, because the strict target defines both __gfx1250_strict__ and __gfx1250__. `str` rows are the runtime decisions a strict device silently misses. The refresh changed 27 cells and is idempotent. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Tie the three arch tables together with a test Adding a target means editing GFX_MAP, GFX_CU_NUM_MAP and core.py's allowed_archs, and nothing tied them together. allowed_archs carried a duplicate "gfx1250" entry until this series removed it, which is what that drift looks like in practice. Two invariants hold today and are now pinned: every arch with an offline CU default is accepted by validate_and_update_archs and maps back through GFX_MAP, and gfx1250-strict does the same. Deleting gfx1250-strict from allowed_archs fails both tests, so a half-landed target is caught in CPU-only CI rather than at build time. The check is behavioural -- it drives validate_and_update_archs and get_gfx_custom_op_core with GPU_ARCHS set -- so it also covers the arch reaching hipcc unchanged as --offload-arch, hyphen included. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Record CK modules as skipped when the submodule is not checked out aiter's CK-free auto-exclusion tests os.path.isdir(CK_3RDPARTY_DIR), which is True for an uninitialised submodule: the directory exists, it is simply empty. A checkout without `git submodule update` therefore still tries to build the CK modules, and they fail on missing sources. core._get_ck_exclude_modules() reports 69 of the 135 modules as CK-dependent, so on such a checkout more than half the build matrix would fill with failures that say nothing about the strict target. The driver now treats an empty composable_kernel directory as CK-free and records those modules as skip-no-ck, keeping pass/fail for results that are actually about gfx1250-strict. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Pin PYTORCH_ROCM_ARCH in the build driver Setting GPU_ARCHS alone does not reach the compiler. torch's cpp_extension takes --offload-arch from PYTORCH_ROCM_ARCH, so with GPU_ARCHS=gfx1250 the modules still compiled for torch's own default list -- observed in a ROCm 10.0.0 container as --offload-arch=gfx90a ... --offload-arch=gfx1151 with no gfx1250 anywhere. Every row of the matrix would have been a result for the wrong architectures while looking like a validated one. The driver now derives PYTORCH_ROCM_ARCH from GPU_ARCHS; with that fixed, module_aiter_unary builds for gfx1250 and build.ninja carries exactly one --offload-arch. Failures also kept the wrong 15 lines: ninja echoes the whole compile command, which pushes the diagnostic out of a plain tail, so a failing module recorded only the Python traceback. The recorded tail now leads with up to five "error:" lines. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Record what ROCm 10.0.0 does and does not provide for strict Checked in rocm/atom-dev:latest-rocm10.0 -- ROCm 10.0.0, AMD clang 23.0.0git (ROCm/llvm-project 8f497e0992fb), HIP 7.15.26333. hipcc compiles gfx942 and gfx1250 and rejects gfx1250-strict as an unsupported HIP gpu architecture. The processor list is gfx1250 and gfx1251, and neither libLLVM nor amdclang contains the string gfx1250-strict or __gfx1250_strict__ at all. The only A0/B0 notion in that toolchain is the AMDGPU subtarget feature gfx1250-b0-specific, and it is not reachable from the driver: not a processor, rejected inside a target id, and ignored as a clang target feature. So the build matrix cannot be filled from the public ROCm 10 container -- the plan's toolchain dependency is unmet rather than satisfied -- and there is a question worth settling before the identity model is locked in. If the mechanism that ships is a subtarget feature on gfx1250 rather than a separate processor name, an A0 and a B0 object both carry the target id gfx1250, which is exactly what _so_offload_archs reads, so that guard would need a different discriminator. The survey records the evidence and the question without presuming the answer. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Lead the recorded failure tail with the real compiler diagnostic The error capture grabbed the first five lines containing "error:", which on a failing build are usually the Python RuntimeError and CalledProcessError wrapper lines, not the compiler's own message. Prefer "file:line:col: error:" frontend diagnostics when present, fall back to any "error:" line otherwise (backend errors such as the gfx1250 DPP rejection have no file:line prefix), and de-duplicate -- clang repeats each diagnostic once per offload arch. Verified against a real ROCm 10 matrix run: the ck_tile "extraneous closing brace" / "template exec" and ck "operator[] in Tuple<>" errors now lead their tails instead of the wrapper, and the opus DPP "broadcasts are not supported on GFX10+" backend error still surfaces via the fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Record the measured gfx1250 build matrix on ROCm 10.0.0 Ran the full 135-module matrix in rocm/atom-dev:latest-rocm10.0 with GPU_ARCHS/PYTORCH_ROCM_ARCH=gfx1250: 102 pass, 21 fail, 12 skip. Strict itself does not compile in this toolchain, so this is the gfx1250 baseline -- anything that fails for gfx1250 cannot build for strict, which is gfx1250 plus an A0 code-object identity. Every failure was rebuilt for gfx942 as a control, which corrected my first read of them. They are not a ROCm-10/clang-23 regression: 18 of 21 build cleanly on gfx942 and fail only on gfx1250, and the 3 FMHA-bwd modules that timed out on gfx942 were compiling without error (module_mha_bwd from the same family finished and passed). Every failure is a genuine gfx1250 porting gap: - DPP broadcast dpp_ctrl modes GFX12 removed (moe_sorting_opus, moe_mxfp4_aux) - MFMA / buffer-load-LDS intrinsics GFX12 lacks (iq2r_moe, mha_fwd_native_splitkv) - a wavefrontsize64 request on a wave32 part (chunk_gdr_fwd_h) - warp-size and gfx950-trait static assertions (topk_plain, moe_opus) - CK's ck_tile TDM path, selected on gfx1250 by CK_TILE_USE_BUFFER_ADDRESSING_BUILTIN=0 (the cktile/blockscale GEMMs, activation, sample, the ck_tile FMHA fwd/prefill) - fmha-v3-bwd asm configs not generated for gfx1250 (the mha_bwd family) The inventory now carries the result table with the gfx942 control column and the per-module cause, as the workstream-2 porting worklist. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Correct the strict macro model and inventory __gfx1250__ guards The plan claimed the strict target defines both __gfx1250_strict__ and __gfx1250__, so existing __gfx1250__ guards keep compiling. ROCm 10.1's actual behaviour is the opposite: strict defines __gfx1250_strict__ and does NOT define __gfx1250__ (ROCm/rocm-systems#12068). A __gfx1250__-only device guard therefore compiles its body away on a strict agent -- a silent empty kernel, the upstream TDM_Basic_load_2d failure, with no build error. JAX hit the matching compiler-side fact and dropped strict from its ROCm 10.0 defaults (jax-ml/jax#41187), and ROCm 10.1 adds gfx1250-strict as a distinct --offload-arch target across the stack (RCCL, CK, rocSHMEM), which confirms this PR's distinct-name identity model and the .so guard that keys on it. Fixes, docs only -- no source guard is touched, because the change must not break the shipping ROCm 7 build, whose compiler knows only __gfx1250__ and has no strict target: - plan and inventory legend now state the real macro behaviour and the backward-compatible fix, `defined(__gfx1250__) || defined(__gfx1250_strict__)`, whose strict arm is simply never taken on ROCm 7. - the ROCm 10.0 survey's open "name vs feature" question is resolved: 10.1 ships a distinct target name; the 10.0 gfx1250-b0-specific subtarget feature was an early-LLVM artifact. - ws2_gfx1250_dispatch_sites.py now also inventories the __gfx1250__ preprocessor guards (95 across 24 csrc files) as a generated review table, flagging which already combine with ||/&& to read first. This is the class the earlier string-comparison scan did not cover. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Make every __gfx1250__ device guard also fire on strict Non-asm operators are meant to run on both MI450 SKUs (A0 = gfx1250-strict, B0 = gfx1250); only the shipped asm is B0-only. But the strict compiler defines __gfx1250_strict__ and not __gfx1250__, so every `#if defined(__gfx1250__)` device guard took its #else branch on a strict build -- a silent wrong path that still compiles. Read on A0 this is: get_smem_size returning 64 KB instead of 320 KB, mhc falling back to fp32 instead of the WMMA path, make_gmem returning the 0xffffffff sentinel so stores drop, and the TDM sync counters using the legacy lgkmcnt/vmcnt instead of the split dscnt/loadcnt. Rewrite all 97 `defined(__gfx1250__)` occurrences across 24 csrc files to `(defined(__gfx1250__) || defined(__gfx1250_strict__))`. The parentheses keep it correct in every context: positive guards, `!(...)` exclusion lists (strict is excluded exactly as gfx1250 is), and `||`/`&&` family lists. The strict arm is never taken on the shipping ROCm 7 build, which has no strict target, so that build is unaffected. Compile-verified on ROCm 10.1 (clang 24.0.0git) for both gfx1250-strict and gfx1250 on module_mhc and module_top_k_per_row; both pass for both targets at low parallelism (the earlier full-matrix failures for these were -j179 contention, not real). Runtime correctness on A0 is left to the daily A0 op-test once the modules are built as gfx1250-strict. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the compiled-path gfx1250 dispatch comparisons Non-asm operators run on both MI450 SKUs, and strict is gfx1250 (A0) hardware, so a `get_gfx() == "gfx1250"` dispatch that selects a compiled path must also fire on gfx1250-strict -- otherwise A0 silently takes the generic fallback and, where the gfx1250 branch picks an arch-specific layout (wave32 tiling, LDS budget), gets a wrong result, not just a slow one. Rewrite the 101 compiled-path comparisons across 51 files from `== "gfx1250"` / `in ("gfx1250",)` to `in ("gfx1250", "gfx1250-strict")`. Deliberately NOT changed: the one asm-selecting dispatch, gemm_op_a4w4.py `if gfx_arch in ["gfx1250"]`. Adding strict there would route A0 into the f4gemm asm path, which the asm gate then throws on -- and the policy is that asm is simply unavailable on A0, so strict must keep missing that comparison and fall to the compiled path. The classifier that split compiled from asm sites flagged exactly this one site. py_compile, ruff and black clean (topk.py's pre-existing fmt:skip parse issue aside); the CPU-only arch/dispatch tests still pass. Multi-element arch allowlists (gluon_archs, SUPPORTED_ARCHS) are left for a follow-up -- those are a capability/feature gap on strict, not the correctness-level layout divergence this commit closes. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Cover != "gfx1250" and post-merge dispatch sites for strict The first dispatch pass only rewrote == and single-element `in (...)` comparisons, so `!= "gfx1250"` negations were left behind -- on strict `arch != "gfx1250"` is True and the kernel takes the non-gfx1250 branch, the same silent-wrong-path class the == sites had. The main merge also added fresh gfx1250 comparisons (flydsl pa_decode, triton quant/mla, mla backend plan). Fix the 30 compiled-path sites: `!= "gfx1250"` -> `not in ("gfx1250", "gfx1250-strict")`, `== "gfx1250"` -> `in (...)`. Three asm-selecting sites are deliberately left (attention.py:1752, mha.py:3779, mla_sparse_prefill.py:100) so strict keeps missing them and A0 errors on asm rather than loading it, per the policy that asm is unavailable on A0. py_compile, ruff and black clean; CPU-only arch tests pass. Only the three asm sites now compare against the bare "gfx1250" literal. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the C++ arch_id == "gfx1250" dispatch comparisons get_gpu_arch() in aiter_hip_common.h keeps the full target id, so a strict device reports "gfx1250-strict" and every `arch_id == "gfx1250"` branch in csrc misses -- the same silent-wrong-path class the Python and __gfx1250__ guards had. has_tdm_arch() returned false on strict even though A0 has TDM; mha_bwd picked the wrong launch geometry; and so on. Rewrite the 28 comparisons across 14 files: `X == "gfx1250"` -> `(X == "gfx1250" || X == "gfx1250-strict")`, `X != "gfx1250"` -> `(X != "gfx1250" && X != "gfx1250-strict")`, where X is a plain identifier or get_gpu_arch(). The asm-dispatch sites are included too: the actual asm load still funnels through require_gfx1250_asm_or_throw, which throws on A0, so computing the dispatch as gfx1250 is safe and A0 still cannot load asm. The already-strict-aware asm gate in aiter_hip_common.h is left untouched. Paren balance verified; the gfx942/gfx950 C++ build in CI compiles it. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the multi-element arch allowlists The capability allowlists -- gluon_archs, SUPPORTED_ARCHS, _SUPPORTED_GFX, DEVICE_ARCH tuples, the triton tuning kernel decorators -- list gfx1250 as a supported arch but not gfx1250-strict, so strict (which is gfx1250 hardware) was treated as unsupported: no gluon path, excluded from the tuned kernel sets, etc. Add "gfx1250-strict" next to each "gfx1250" element in those arch tuples and lists (41 across 22 files), skipping the substring-match helper (quick_all_reduce's `gfx in arch`, where "gfx1250" already matches "gfx1250-strict") and any asm-selecting context. With the gemm_a4w4 path main restructured, the gfx1250 branch now routes plain MXFP4 to FlyDSL and the rest to asm, so strict correctly gets the FlyDSL path and the asm gate still handles A0. ruff and black clean; CPU-only arch tests pass. This closes the last aiter-side strict dispatch gap; what remains is A0 runtime validation and the Opus .co rebuild. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Pin flydsl to 0.4.0.dev973 for gfx1250-strict LDS support FlyDSL's arch handling is otherwise strict-ready because it matches by prefix (arch.startswith("gfx1250") / "gfx12"), which gfx1250-strict satisfies -- WMMA instruction selection, warp_size (32) and the compile target all come out right. The one gap was the LDS-capacity map, keyed on the exact "gfx1250" string, so on strict the lookup missed and check_smem_capacity silently skipped the overflow guard. 0.4.0.dev973 adds "gfx1250-strict": 327680 to SMEM_CAPACITY_MAP (now in flydsl.runtime.device), closing that gap. Bump the pin in requirements.txt and setup.py (the version assertion and auto-install both derive from FLYDSL_VERSION). Revert to the default release once the fix ships there. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Clean up: drop investigation tooling, tidy strict macro guards Self-review cleanup, no behaviour change: - Remove the ws2_* enumeration/matrix scripts and the generated kernel-inventory doc. Those were one-off investigation flow (build matrix, dispatch-site enumeration) and do not belong in the repo; nothing in aiter imports them. - Drop the dangling "former hotswap path" bullet from the enablement plan; the term exists nowhere in the tree. - Flatten the redundant parentheses the strict sweep left behind: the mechanical `defined(__gfx1250__)` -> `(defined(__gfx1250__) || defined(__gfx1250_strict__))` wrapped the pair even inside OR chains. Unwrap it where the context is pure-OR (90 sites); keep the parentheses only where they are load-bearing -- negation `!(...)` and `&&` operands (7 sites). Compile-verified on ROCm 10.1 for both gfx1250-strict and gfx1250 (module_mhc, module_top_k_per_row); CPU-only arch tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: pin flydsl build-system dep to 0.4.0.dev973 to match setup.py pyproject.toml build-system.requires still pinned flydsl==0.4.0 while setup.py (FLYDSL_VERSION) and requirements.txt use 0.4.0.dev973. Under build isolation pip installed 0.4.0 as the build dep, then setup.py's version assertion rejected it and the build failed. Align all three. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: asm-gate error message covers both A0 detection routes The gate blocks B0 asm on A0 via two routes: gcnArchName == gfx1250-strict, or gcnArchName == gfx1250 with asicRevision 0. The message hardcoded 'gfx1250-strict/A0', which misleads when A0 is caught by the asicRevision route (device name is literally gfx1250, rev 0). State both forms. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: strict Opus codegen + 4 CI-red CPU tests gen_instances: GPU_ARCHS=gfx1250-strict looked up KERNEL_REGISTRY by the strict name, which has no registry key, so Opus codegen emitted an empty header and module_deepgemm_opus failed to build (the only strict-specific failure of the strict build matrix). Fold the registry key to the gfx1250 family (mirroring chip_info._detect_native) while keeping the gfx1250-strict build target, so hipcc still compiles for mach 0xeb. Strict now resolves to 256 CU, same as gfx1250. Tests (Draft CI had skipped these): - test_opus_co_profile load_chip_parsers: keep the _GFX_ARCH_PATTERN constant in the extracted AST namespace (the strict PR added it; parsers NameError'd). - test_build_targets preserve->normalize: _detect_native now folds strict to gfx1250 for dispatch; assert the new behavior. - test_launcher_does_not_pin_the_first_device: use the first declared local kid instead of hard-coded global kid 21016 (removed by #6937). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: strict Opus codegen emits the gfx1250 family (routes>0), not an empty module The earlier fix only folded the target list; the real route generation still queried the registry by the strict name and produced routes=0 (empty module_deepgemm_opus). Apply the gfx1250 family name at every registry/namespace lookup -- available's 'if gfx in arches', get_registry, default_compiled_keys -- and at the OPUS_BUILD_HAS_* macro (C checks #ifdef OPUS_BUILD_HAS_GFX1250, and a hyphenated STRICT macro is invalid C). KernelKey and the build target keep the gfx1250-strict spelling, so hipcc still offloads for mach 0xeb. Verified: GPU_ARCHS=gfx1250-strict now yields routes=228 (== gfx1250) with OPUS_BUILD_HAS_GFX1250; CPU tests stay green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Opus codegen: normalize gfx1250-strict targets to the gfx1250 family at the source Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: bump flydsl pin to 0.4.0 to match main (dev973 would downgrade it on merge) main pins flydsl==0.4.0; this PR still carried the 0.4.0.dev973 prerelease, so merging would silently downgrade the whole repo. 0.4.0 is a superset of dev973 (contains the gfx1250-strict LDS fix) and is what main already uses. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test: drop redundant test_strict_resolves_through_all_three_tables test_every_offline_target_resolves_through_all_three_tables already loops over GFX_CU_NUM_MAP, which contains gfx1250-strict, so the strict-specific case was an exact duplicate of one loop iteration. * fix: avoid 'in' tuple test in gluon kernel constexpr (unsupported by gluon) The strict-allowlist sweep turned 'ARCH == "gfx1250"' into 'ARCH in ("gfx1250", "gfx1250-strict")' inside gluon kernel bodies/constexpr. Triton's gluon compiler does not implement the 'In' AST operator, so these kernels failed to compile ('AST comparison operator In is not implemented'), breaking test_pa_mqa_logits_2d_context_lens[gluon*] on gfx942/gfx950. Use '(x == a or x == b)', which gluon supports, in kernel scope. Host-side Python 'in' checks are unaffected and left as-is. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Preserve exact gfx1250-strict identity; map to gfx1250 family only at dispatch Per the ROCr rollout contract (all SW consumes the exact GFX ID ROCr reports), global normalization in _detect_native() is the wrong boundary. Once ROCr reports gfx1250-strict for A0, folding it to gfx1250 there makes _needs_arch_rebuild() treat a strict .so as not covering a strict device and rebuild in a loop; it also remixes A0/B0 in tuned configs, caches, and logs. - chip_info._detect_native: drop the strict->gfx1250 fold; return the exact ROCr-reported identity. get_gfx_runtime()/get_gfx() now report gfx1250-strict on A0. - build_targets.py: add the single source of truth for family folding -- GFX_BASE_ARCH, base_gfx_arch(), is_gfx1250_family(). Torch-free, so build scripts and tests import it without side effects. - Opus: replace its two private strict->gfx1250 folds (gen_instances _registry_arch, opus_gemm_common _get_registry_records/get_registry/ default_compiled_keys) with base_gfx_arch(), so there is no second mapping. hipcc still gets --offload-arch=gfx1250-strict and the .co stays mach-0xeb. - mega_moe _require_gfx1250: restore the gfx1250-family guard (via is_gfx1250_family) that main's #6430 refactor collapsed to bare gfx1250. - Build/cache/tuning/.so/.co/ASM keep the exact identity: _needs_arch_rebuild and _so_offload_archs already key on it, so A0 never loads a B0 object. - Pre-existing gfx1250-only dispatch sites authored by other PRs stay exact; with the fold gone they correctly distinguish strict (fall back) instead of silently reusing a B0 path. - Tests: flip the native-detection test into a regression lock that strict identity is preserved; add family-helper and 4-way code-object rebuild-guard tests (runtime/built strict x gfx1250 -> accept/reject). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Apply ruff import sort and black formatting to the identity refactor Fixes the pre-checks (ruff I001 import order in mega_moe, black reformat of mega_moe and test_build_targets_architecture) that gated check-signal and skipped the Triton/Aiter test runs. No logic change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * black: wrap the long gfx1250/gfx1250-strict dispatch conditions in the gluon kernels The in->or fix in the pa_mqa_logits / unified_attention_2d gluon kernels left two over-length boolean conditions that Black wraps. Formatting only; the gluon compiler still sees the same (x == a or x == b) expression. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Define Opus base_gfx_arch locally instead of importing build_targets The cross-package `from build_targets import base_gfx_arch` (via a __file__-relative sys.path insert) breaks the Aiter wheel build: gen_instances.py runs from a staging tree (aiter_meta/csrc/opus_gemm) where ../../aiter/jit/utils does not exist, so module_deepgemm_opus failed with ModuleNotFoundError: No module named 'build_targets'. Duplicate the one-line helper locally in opus_gemm_common (documented to mirror build_targets.base_gfx_arch) so the standalone Opus codegen has no cross-tree import dependency. gen_instances keeps importing it from opus_gemm_common. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test(jit_cache): seed _cluster_launch_target in the build_module sandbox test_jit_cache_transaction AST-extracts build_module into a sandbox namespace with CPU deps injected. Since the gfx1250-strict work added a _cluster_launch_target(get_gfx) call inside MainFunc, the sandbox hit NameError: name '_cluster_launch_target' is not defined (25 TestBuildPublication errors on MI35X). This surfaced only now because the earlier Opus wheel-build failure skipped the standard tests. Inject the dependency like the others; for the gfx942 test context the real function returns False, so the mock matches. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: root <[email protected]> * [HIP] [FlyDSL] optimize dsv41 perf for decode shape (#7309) * optimize the mxfp8 op for decode shape * retune mxfp8 tables with optimize decode shape --------- Co-authored-by: solin <[email protected]> * [HIP] [CK] [JIT] [Tuner] Rank accuracy-qualified kernels by package energy (#6970) * [Tuner] Rank accuracy-qualified kernels by package energy Add --select power so shared tuners keep the lowest runtime times PPT watts. The accuracy gate is unchanged, and latency remains the default. Co-authored-by: Cursor <[email protected]> * [Tuner] Satisfy black and ruff on the power-selection change Format the tuner edits and replace the NaN self-comparisons and bare exception handlers that the pre-check jobs reject. Co-authored-by: Cursor <[email protected]> * [Tuner] Keep latency order when package power is missing Sort power candidates by energy and then latency so an unread sensor cannot drop the fastest kernel. A single AITER_POWER_PATH is rejected when more than one tuner process is running. Co-authored-by: Cursor <[email protected]> * [Tuner] Keep power-tuned rows apart from latency tables Power tunes of shipped tables now write to aiter/configs/power_configs/, which loads only with AITER_SELECT=power and replaces only the shapes it covers. Each power row records perf level, power cap, and SCLK range, and the config merge refuses to auto-resolve power rows against latency rows or rows tuned under different conditions. Power mode is marked experimental. Co-authored-by: Cursor <[email protected]> * [Tuner] Isolate power-kernel selection from the tuner and JIT path Ranking, package-power measurement, and power_configs loading each have one owner. Latency CSV columns stay unchanged unless --select power. Co-authored-by: Cursor <[email protected]> * [Tuner] Measure power with the same call the timer uses The replay was passing run_perftest keywords into the kernel, so watts came back NaN and the row was still stamped select=power. A batch with no finite watts stays a latency result, and --select power is rejected on tuners that do not record it. Co-authored-by: Cursor <[email protected]> * [Tuner] Give the MXFP4 power retime test a supported shape Main now rejects an MXFP4 row before the scan unless dtype and quant fields match the port. The energy-ranking fixture was missing those fields, so it never reached the retime. Co-authored-by: Cursor <[email protected]> * [Tuner] Format the power-selection files with Black CI skipped the GPU tests because Black rejected these three files. Co-authored-by: Cursor <[email protected]> * [Tuner] Keep the wheel build from importing the aiter package setup.py loads jit.core before aiter exists. Importing the power overlay from that path ran aiter/__init__.py while module_aiter_core was still being registered. Co-authored-by: Cursor <[email protected]> * [Tuner] Decide latency or power in one policy and measure in one place A tuner builds a SelectionPolicy from --select and asks it for the candidate rank, frame order, pair energy, accurate-pass count, and the power sample. Tuners no longer branch on the select mode or write AITER_SELECT; that variable only picks the tables jit/core loads. mp_tuner reads the policy TunerCommon.run activates. package_power.measure_kernel is the one power read. mp_tuner hands it the kernel launch with the run_perftest options removed, so the window replays the kernel back to back. Replaying run_perftest itself left the GPU idle for most of the window. The duplicate-shape dedup in jit/core sorts by lowest us without importing the aiter package when setup.py loads it as jit.core. Co-authored-by: Cursor <[email protected]> * [Tuner] Fix power-tune paths found by end-to-end runs on MI355X - TunerCommon.run wrapped its body in _run, which IQ2R already defines as its kernel launcher, so every IQ2R tune failed. Use _run_selected. - The a16w16 tuner built gradlib's Gemm without the policy, so hipBLASLt was never power-measured and always ranked last. Pass the policy, and default Gemm and the K5 sweep to the active policy. - The power window queued launches without bound. IQ2R graph replays crash inside the HIP runtime when hundreds are queued. Keep a few events in flight, one per ~200 us of work, so the GPU never drains. - IQ2R times a captured CUDA graph; sample power from that graph too. - Staged MXFP4 logs each pair's watts like the other loops. Co-authored-by: Cursor <[email protected]> * [Tuner] Correct the power sample for host launch gaps A kernel whose Python launch takes longer than its GPU time leaves the GPU idle between launches, so the window read close to idle and the kernel looked efficient (split-K FlyDSL GEMMs at 256x4096x4096 read ~370 W against ~990 W replayed from a CUDA graph, and won power mode). Every measurement site now passes the call's timed us. When the loop never waited on the GPU, the window's busy fraction is launches * us / window, and the reading is scaled to active power over the between-launch baseline (a one-element kernel loop, ~300 W on MI355X). A window that waited on the GPU kept it saturated and stands as read. Under 20% busy the candidate stays unmeasured. Co-authored-by: Cursor <[email protected]> * [Tuner] Keep latency profiles as main and write only measured power rows - MoE latency tunes write the -o2 profile and profile_fmoe.csv with main's columns and row order. Stage watts, rank, energy, and tflops_per_w appear only with --select power. - A power tune drops rows whose watts were not measured instead of writ…
…tches, mori combine path, current mori EPv2 (ROCm#6430) * MegaMoE: stage1_fused/stage2_fused switches, mori combine path * bench_mega_moe: fix kernel table on multi-stream graphs * MegaMoE: follow mori tokoff-ext and selfFirst defaults * bench_mega_moe: --fused_shared_experts as ATOM DP+EP runs them * MegaMoE: follow mori#726 and size mori's fp4 combine flags Four fixes to the mori dispatch/combine path (stage1_fused/stage2_fused off), each from driving mori's plans without its op layer: - dispatch: since ROCm/mori#726 the plan takes tok_off_ext and derives selfFirst itself; self_first_enabled() is gone, so importing it fails. - tuning lookup: key it on the dispatch wire the way mori's op layer does ("fp4_disp_bf16_comb" for fp4). Under the hard-coded "bf16" key topk 9 matched no entry and both dispatch and the fp4 combine fell back to the single-shot default. - comb_inp: add the overlapped fp4 combine's u64 flag per landing row (four ranks up). Its 24-warp geometries write them past the region, i.e. past the arena: a page fault at 16384 tokens a rank. - close(): synchronize first, so a launch still in flight does not read a window that has been freed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: zero-copy hand-off from fused_moe to mori's combine With stage2_fused off, fused_moe's rows went into a fresh tensor and then into mori's staging rows (comb_inp): the bf16 combine copied them in its own kernel, the fp4 one through a host-issued copy whenever the recv bound was below max_recv -- every decode step under ATOM. Have fused_moe write them there directly. fused_moe(output=) already existed but the gfx1250 grouped path ignored it and copied at the end; thread it down to the gather-reduce. mori's bf16 combine then sees its input at the staging base and skips the copy, and the fp4 send reads the staging rows in place. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: follow mori#745/ROCm#746 on the mori dispatch/combine path mori's gfx1250 dispatch now reserves its slots once per destination (the aggregated reservation, ROCm/mori#745) and hands the push combine its landing offsets through the dispatch. MegaMoE drives the plans directly, so it has to size and pass what mori's op layer does: - dest_pe_token_counter holds 2 * world_size ints: send counts, then per destination the reservation base and the push combine's landing offset. It held world_size; the dispatch wrote the second half into allocator padding. - recv_num signals are 8 bytes a source. The region held 4 bytes a source; the arena's 256-byte alignment hid the overrun. - The combine reads its landing offsets from dest_pe_token_counter, which MegaMoE did not pass, so the mxfp4 combine (stage2_fused=False) got a null pointer there. - MORI_EP_TOKOFF_EXT=1 turns the aggregated reservation off, so a mori push combine is refused with it, as mori's op layer refuses it. - The push landing rows come from mori's push_land_rows(): one per (token, destination rank), max_tokens * min(world_size, topk) rather than world_size * max_recv. - The mori dispatch launcher drops total_recv.zero_(): gfx1250's dispatch overwrites the count (since ROCm/mori#599), and mori's op layer skips the same zero there. Against a mori from before ROCm#745 the landing rows keep the old count and the two larger buffers have unused tails. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: bind mori's dispatch staging buffer (ROCm/mori#703) mori#703 moves the gfx1250 dispatch's staging arrays out of each kernel module's .bss into one buffer the caller allocates and binds as staging_base; an unbound plan is refused on the host. MegaMoE drives EpDispatchPlan directly, so it allocates ep_staging_bytes() once and binds it to every dispatch plan (they never run at the same time), and drops it after the plans on close(). A mori without ep_staging_bytes keeps the .bss arrays and is left as is. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: keep accepting dispatch_backend stage1_fused now picks the dispatch, and the dispatch_backend argument and config field went away with that. Callers still pass it (ATOM main passes dispatch_backend="mori" on a quantizing wire; ROCm/ATOM#2384 passes "flydsl" or "mori" alongside stage1_fused) and log mega._config.dispatch_backend, so both would fail on this aiter. Accept the argument again and check it against stage1_fused: "mori" is stage1_fused=False, "flydsl" is the compact plan. A "flydsl" without stage1_fused asked for the FlyDSL token-major dispatch, which no longer exists, so it is refused rather than run on mori. MegaMoEConfig gets a read-only dispatch_backend derived from stage1_fused. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * ci: run the MegaMoE bench on mori's dispatch stage1_fused=false with stage2_fused=true is mori's fp4 dispatch with the fused combine (the bench's auto wire is fp4 for a4w4_mxfp4), the configuration DeepSeek-R1 serves with. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: gfx1250 behaviour tests ahead of the refactor test_mega_moe_gfx1250.py pins what a change to MegaMoEGfx1250's dispatch/combine wiring must keep, through the constructor and members its callers use today: - every dispatch/combine pairing matches the fp32 reference, and a captured graph replays bit for bit what eager produced; - the pairings MegaMoE rejects fail before the symmetric arena is allocated; - mori's combine reads fused_moe's rows in place (zero-copy staging); - close() releases the plans before the window, the window before its memory; - the members ATOM's Triton experts reach (_dispatch, _combine, _arena, _config). It spawns its own ranks and skips (exit 0) off gfx1250, below two GPUs or without mori, so CI's MULTIGPU job can run it on gfx950. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: build from a MegaMoERecipe and a MegaMoEGeometry A caller now says what to run once, as a recipe, and MegaMoE builds it: recipe = MegaMoERecipe(dispatch=DispatchKind.MORI, combine=CombineKind.FUSED_SCATTER, dispatch_wire="fp4", combine_wires=("bf16", "fp4"), activation=..., quant_type=...) geometry = MegaMoEGeometry(rank, world_size, model_dim, inter_dim, experts, topk, max_tokens_per_rank) mega = MegaMoEGfx1250.from_recipe(recipe, geometry, communicator=comm) - MegaMoERecipe holds the transport (dispatch and combine kind, dispatch wire, the combine wires to build) and the expert-GEMM recipe; frozen and hashable, so a caller can key its cache of instances on it. MegaMoEGeometry holds the model and EP shape. - MegaMoERecipe.from_legacy is the one reader of stage1_fused, stage2_fused, dispatch_backend and the $MEGA_DISPATCH_WIRE / $MEGA_COMBINE_QUANT defaults. The keyword constructor goes through it, so both entries build the same thing. - MegaMoEConfig is now that recipe resolved against a geometry: frozen, with the same properties as before (stage1_fused, stage2_fused and dispatch_backend included, for the callers that read them). The dispatch schedule it used to have written into it lives on the instance; the dispatch_block_num / dispatch_warp_num_per_block fallback it carried was never reached. - forward() takes combine_wire= (bf16 | fp8 | fp4), the recipe's vocabulary, alongside combine_quant=. Every check and its message is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: probe mori once, and decide everything before the arena exists _MoriCapabilities gathers what MegaMoE needs to know about the installed mori -- the plan classes, the tuning lookup, and each helper a mori PR added (scale_stride_bytes ROCm#593, push_wire_nbytes ROCm#719, push_land_rows ROCm#745, ep_staging_bytes ROCm#703, TokOffExt.wanted ROCm#726, self_first_enabled) -- into one cached probe, and the decisions that hang off them into its methods: the tuned schedules, the landing-row sizes, the staging size, where the slot word lives. The ImportError/hasattr branches are gone from the pipeline; the RuntimeError messages for an mori that is too old are unchanged. _plan_transport runs all of it, plus the fused reduce's tiles and mori combine's block/epoch-slot check, before the symmetric arena is allocated. A configuration that cannot run -- mori missing, MORI_EP_TOKOFF_EXT=1 with mori's fp4 combine, no reduce tile, too many combine blocks -- now fails with nothing allocated instead of leaking the arena. TokOffExt.wanted, collective when MORI_EP_TOKOFF_EXT is on, moves ahead of the arena's own collective allocation on every rank alike. The compact dispatch with the fused combine still never loads mori's ops. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: one arena layout, and required_vmm_bytes from it The arena's regions now come from one formula, _arena_layout: the dispatch says what it writes (_dispatch_regions: the routing both kinds share, then its own rows), the combine what it stages through (_combine_regions), and _ArenaLayout.merge lays them down in the order the pipeline always used, so every pairing keeps the offsets it had. SymmetricArena takes the layout (or a region list, as before) and frees its memory if the window registration fails. MegaMoEGfx1250.required_vmm_bytes(recipe, geometry) reports the same layout, rounded the way ccoMemAlloc rounds an allocation -- the per_rank_vmm a caller needs for this MegaMoE, before any communicator exists, and exactly what the constructor then allocates. It is MegaMoE's share only; a communicator that also carries mori's own EP ops needs theirs on top. required_vmm_bytes(world_size=, hidden_dim=, max_tokens_per_rank=, experts=, topk=, stage1_fused=), the keyword form ROCm#6525 proposed and ATOM's yanbo/mega already calls, still works: it names neither wires nor combine nor inter_dim, so it returns the largest any recipe with that dispatch takes. _compact_gemm_align_m reads activation, quant type and inter_dim off the config instead of taking them separately. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: dispatch and combine stages under one dispatcher; linear forward The transport is now two stages the recipe picks, over one shared arena: _MoriDispatch / _CompactDispatch tokens out to their experts' ranks _MoriCombine / _FusedScatterCombine results back, summed per token Each declares its arena regions (regions(), pure -- what _arena_layout and required_vmm_bytes merge), plans in __init__ with nothing allocated, and allocates in build(). They meet only through _EpResources (the arena, the routing state both ends read, TokOffExt), the _DispatchBatch the dispatch hands the expert GEMM, and the _ComputeTarget the combine has it write into. _EpDispatcher picks the two from tables, runs every check before the arena is allocated, and frees what was built when a later step fails -- the arena and plans used to leak. close() goes: synchronize, combine plans, dispatch plans, staging, arena, TokOffExt. forward() is now: pick the step's combine wire, check the inputs, dispatch, prepare, compute, finish. The compact plan's machinery -- slots, side stream, per-step geometry (_CompactStep, now immutable) -- lives in _CompactDispatch, and the next layer's plan launches at the end of its dispatch, the same place on the GPU streams as before. The recv views are made once at build instead of per step. The TDM dispatch keeps only its compact arm; the token-major arms were unreachable once stage1_fused=False went through mori. Kept for the callers that reach past forward(), ATOM's Triton experts among them: _config, _arena, _dispatch() and its 5-tuple, _combine(), _recv_dispatch_scales(), prefetch_compact_plan(), warmup_compact_plan(). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: size mori's regions from describe(); the bench sizes cco from the recipe On a mori with Plan.describe() (ROCm/mori#844), the mori stages ask it for their arena regions and the dispatch's staging bytes -- the numbers mori's own kernels and its bind-time size check use -- instead of keeping formulas that mirror them. Each stage builds its plan request in one place (request()), which both describe() and the plan take. describe() compiles nothing and resolves against gfx1250 by name, so required_vmm_bytes stays off the GPU; the slot word's kwargs stay out of it, since where that word lives sizes nothing and asking would be collective. An older mori keeps the formulas. SymmetricArena.size() lets a ROCm#844 plan check its regions at bind. bench_mega_moe builds from a MegaMoERecipe and sizes its communicator with required_vmm_bytes(recipe, geometry) instead of a fixed 16 GiB. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: CPU tests for the recipe and the arena it sizes tests/test_mega_moe_gfx1250_recipe.py needs no GPU and skips where MegaMoE does not import. It checks how the legacy flags map to a recipe and that the rejections keep their wording, and lays the arena out over a grid of geometries and every pairing against the region list ROCm#6430 built inline -- through a fake mori both with and without Plan.describe(), the describe one following mori's rules, which add no overlapped-reduce flags on a wide EP. required_vmm_bytes is held to the layout as cco rounds it, and its keyword form to at least that. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: bind mori's dispatch staging as a tensor A mori with ROCm/mori#844 checks a staging tensor against the plan's stagingBytes, device and alignment at bind, and holds it; an address is taken on trust. An older mori reads the tensor's address at each launch, as it did the int. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * TEMP: grouped GEMM takes a strided scale view again (fixup for ROCm#6946) ROCm#6946 flattens the grouped GEMM's scale arguments with .view(-1), which a non-contiguous tensor cannot do. MegaMoE's compact rows hand over exactly that -- each row's e8m0 scales sit inside its wire row -- so every stage1_fused MegaMoE step raises. The kernel only takes the base address and walks the rows by a_scale_row_stride_bytes, so a strided scale view becomes a one-dimensional view over the same base, as it was before ROCm#6946. Temporary: drop this commit once main fixes it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * bench_mega_moe: take out the kernel-table and --fused_shared_experts changes They are bench fixes rather than part of the MegaMoE recipe work, and move to ROCm#7074. This reverts "bench_mega_moe: fix kernel table on multi-stream graphs" and "bench_mega_moe: --fused_shared_experts as ATOM DP+EP runs them". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * FlyDSL grouped GEMM: pass a strided scale view at its base address Replaces the temporary workaround for the cached launcher (ROCm#6946), which flattens the grouped GEMM's scale arguments with .view(-1). A non-contiguous tensor cannot do that, and MegaMoE's expert-grouped dispatch hands over exactly one: each row's e8m0 scales sit inside its wire row, read by a_scale_row_stride_bytes. The kernel reads these arguments only through their base pointer. tensor_shim gains flat_arg(), beside ptr_arg(): a contiguous tensor is .view(-1), as before, so no other caller changes; a strided one becomes the run of elements from its first to its last, at the same base. tests/test_grouped_gemm_strided_scales.py checks flat_arg and what the launcher hands the compiled kernel, without a GPU. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: stage contracts, mori sizing from describe() only, from_recipe first The recipe - The expert GEMM's fields move into ExpertComputeConfig, nested as MegaMoERecipe.compute; the recipe's own fields are the transport's. - Which pairings run is declared by the stages: a dispatch names the wires it carries and the BatchLayout it delivers (token-major or expert-grouped), a combine the layouts it accepts and the wires it offers. The recipe checks against those, and its errors name recipe fields (dispatch=, combine=, dispatch_wire=, combine_wires=). Each stage's geometry check (check()) runs from MegaMoEConfig. - from_recipe is the entry point. The keyword constructor warns DeprecationWarning; the underscored members ATOM's Triton experts use are documented as kept for them. The facade reads geometry and compute fields through properties rather than copying them. The stages - DispatchStage and CombineStage (Protocols) say what each provides; every stage has regions(config, caps) and check(config), and is built as Stage(config, caps). The compact- and mori-only attributes are gone from the shared base. - Each dispatch stage owns the stride its e8m0 rows arrive at (scale_stride), replacing MegaMoEConfig.dispatch_scale_dst_nbytes. - The batch carries its layout explicitly, and an expert-grouped one an ExpertGrouping; the combine hands the grouped GEMM its dispatch context in the _ComputeTarget, so the expert GEMM does not branch on the layout. - Whether the combine needs mori's aggregated reservation and whether the dispatch makes it are each stage's to say; the dispatcher refuses the pair before the arena exists. - One schedule pick (_pick) serves both mori plans and the compact kernels; _quantize returns the scale rows' address instead of leaving it in state. - _EpDispatcher has dispatch/prepare/combine/prefetch/warmup and the recv views, so forward() does not reach into the stages, and close() releases the rest even when one part raises. mori - _MoriCapabilities needs Plan.describe() (ROCm/mori#844). Regions, staging bytes and the scale stride come from there, so the copies of mori's formulas and the older-mori branches are gone; such a mori also overwrites total_recv in its dispatch, which is why nothing zeroes it. - _XDB_FLAG_SLOTS, TokOffExt and the plan constructors are reached only through _MoriCapabilities. Checks - An out-of-range recv_token_bound (and next_recv_token_bound) raises on the compact dispatch as on mori's, in dispatch, prefetch and warmup. - a1_scale on a quantizing dispatch wire raises ValueError (was an assert). - The keyword form of required_vmm_bytes raises when no candidate recipe runs at the geometry, instead of returning 0. - _MoriCombine.prepare documents why writing fused_moe's rows straight into comb_inp is safe: the next dispatch does not finish until every peer has dispatched, which each does only after its own combine. Tests: the CPU test fakes mori from describe() alone and covers the stage contract messages, the bound checks and the keyword-bound refusal; the multi-GPU test builds through from_recipe and checks the deprecated keyword constructor against it. bench_moe_gemm_a4w4_cudagraph builds through from_recipe. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: split mega_moe.py into recipe, mori_caps, arena, stages, transport A move, no change in behaviour: each block of mega_moe.py lands in one module as it was, and mega_moe.py keeps only MegaMoEGfx1250. - recipe.py: the wires, DispatchKind / CombineKind, ExpertComputeConfig, MegaMoERecipe, MegaMoEGeometry, MegaMoEConfig. - mori_caps.py: _MoriCapabilities and mori's region names. - arena.py: SymmetricArena, the region order, _ArenaLayout, cco's rounding. - stages/base.py: DispatchStage / CombineStage and what the stages share (routing, resources, batch, compute target, schedule pick). - stages/dispatch_mori.py, dispatch_compact.py, combine_fused.py, combine_mori.py: one stage each; stages/__init__.py maps each kind to its stage. - transport.py: _EpDispatcher and the one arena layout. The only edit: recipe.py looks the stages up when asked for (the stages import recipe.py). mega_moe.py still exports the package's public names, and Routing, which a bench imports from there. The CPU test imports the private names it checks from the modules that define them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE: compact dispatch bound and plan fixes, wire-picked GEMM A dtype - Compact dispatch: with no recv_token_bound the step is sized for the arena's capacity; a plan started for another alignment is refused; the plan's segment and wave limits are checked before the arena exists; plans are compiled when created, ahead of any graph capture. - A quantizing dispatch wire sets fused_moe's quant_dtype_a. - bench_mega_moe runs on gfx1250 only. - Tests: fp8 dispatch and fp8 combine cases, rank-local failures raised on every rank, CPU tests skip only without flydsl. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * MegaMoE CPU test: skip without mori as well - The package's kernel modules import mori.cco, so the test skips when mori is not installed instead of failing collection. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: yanboshao <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…cture plumbing (ROCm#6767) * [JIT] Add gfx1250-strict architecture plumbing * [JIT] Fix ruff F821 and black formatting in gfx1250-strict plumbing Add the missing build_targets._parse_gpu_archs_env import in core.py (F821 flagged by CI ruff) and apply black to core.py and test_build_targets_architecture.py. Co-Authored-By: Claude Code <[email protected]> * [JIT] Add gfx1250-strict kernel inventory and WS2 build driver Skeleton inventory for every JIT/FlyDSL/Triton path plus the driver that fills its strict-build column from a strict-capable container. Driver verified offline on a non-strict host (module enumeration, child plumbing, skip classification, --update-md folding): - CHILD called os.chdir without importing os, so every module would have failed with NameError and the whole matrix would have read "fail". - optCompilerConfig lists 135 modules but get_args_of_build("all") yields 123. The other 12 are not failures: 10 end in "tune" (skipped by design) and 2 are experimental (gated by AITER_ENABLE_EXPERIMENTAL). They are now recorded as skip-tune / skip-experimental instead of "missing", so the matrix keeps an explicit result for all 135. Actual pass/fail rows still require the strict toolchain; stock ROCm 7.0.0 rejects gfx1250-strict as an invalid target ID. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Fix empty GPU_ARCHS raising out of build_module The gfx1250-strict plumbing routed GPU_ARCHS through build_targets._parse_gpu_archs_env, which raises when the value holds no architecture names. GPU_ARCHS set but empty -- what a Dockerfile's `ENV GPU_ARCHS=` or a bare `export GPU_ARCHS=` produces -- previously just meant "no cluster-launch flag, build normally"; it now raised RuntimeError inside build_module and failed every JIT build. Blank, whitespace-only and ";" values had the same problem. Fall back to the detected arch instead, matching aiter/ops/opus/_arch.py, which treats an empty or "native" GPU_ARCHS as "probe the device" and never raises. The arch test moves into _build_archs_from_env / _cluster_launch_target so it is reachable from a CPU-only test. Covered by TestClusterLaunchBuildArchs: blank/unset/"native" fall back to detection, explicit archs win, and -DAITER_ENABLE_CLUSTER_LAUNCH still follows gfx1250 or gfx1250-strict anywhere in a multi-arch GPU_ARCHS. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Inventory the gfx1250 dispatch sites a strict device silently misses The infra PR keeps gfx1250-strict distinct through parsing, build selection and the asm guard, but Python dispatch still compares against the exact literal "gfx1250". On A0 get_gfx() returns "gfx1250-strict", so those comparisons are False and the constant arch allowlists do not contain it: the gfx1250 path is skipped with no error, which reads as a kernel-selection change rather than a failure. ws2_gfx1250_dispatch_sites.py enumerates them -- 150 uses across 65 files, 132 runtime comparisons and 18 allowlist entries -- and records where the compared string comes from. get_gfx/get_gfx_runtime sites keep the hyphenated spelling and are known to miss; triton-arch sites read Triton's own target name, whose strict spelling stays unverified until the toolchain lands. The table is generated into the inventory between HTML markers and the rewrite is idempotent, so it can be refreshed as owners decide each site. No dispatch behaviour is changed here: every row is an explicit pending decision, which is what workstream 2 asks for. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Pin the offload-target parser against hyphenated target names _so_offload_archs backs the guard that keeps a gfx1250 and a gfx1250-strict .so from standing in for each other, so the shapes it must parse deserve a test of their own: a feature list after ':', the strict suffix, both together, and a ROCm generic target. The previous gfx\w+ pattern truncated at the first hyphen. That reported a strict .so as plain gfx1250 -- the substitution this guard exists to prevent -- and also read gfx9-4-generic as gfx9, which matches no running arch and so rebuilt such a module on every import. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Inventory the arch-keyed tables that have no strict entry The dispatch-site scan only saw comparisons against the "gfx1250" literal, which left a blind spot: tables keyed by architecture. A strict device is simply absent from those, so it takes whatever the lookup does with a missing key. Four of them carry a gfx1250 entry and no strict entry, and they do not behave alike: - radix_topk_one_block._LONG_RADIX_BY_ARCH and ._ONE_BLOCK_LDS_BUDGET_BYTES read with a default, so A0 quietly falls back to the generic radix layout and a zero LDS budget, losing the 320 KiB one-block path with nothing logged. - pa_decode's inline fp8 dtype table reads with .get() and raises NotImplementedError naming the arch -- the "fail clearly" behaviour the enablement plan asks for. - mhc.MHC_FUSED_POST_PRE_M_UPPER_BOUND reads with a default of 1024, which happens to equal the gfx1250 entry, so A0 is correct today only by coincidence. The generated table records the lookup style per row so the difference between a silent fallback and a clear failure is visible to the owner making the call. Behaviour is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Extend the gfx1250 site inventory to C++ and skip handled sites get_gpu_arch() in aiter_hip_common.h cuts the target id at ':' and keeps everything before it, so a strict device reports "gfx1250-strict" in C++ too and the arch_id == "gfx1250" branches miss exactly as the Python ones do. 27 of them across 14 files, 11 in mha_bwd.cu alone, where several pick launch geometry rather than a code path -- a miss changes a block size instead of raising. Worth recording for the Opus owner: opus_co_launch_gfx1250.cuh builds its code-object path from get_gpu_arch(), so A0 looks for gen_co/gfx1250-strict and fails with a clear AITER_CHECK rather than loading a B0 object. That is what the plan asks for, so it is called out in the table's preamble instead of being listed as a gap. The scan now skips any site with a strict spelling within four lines, so the asm gate's own early return no longer pads the table and a site drops out once an owner has handled it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Count the tuned rows a strict device cannot use Tuned GEMM and MoE configs carry a gfx column and are looked up through get_gfx(), which reports gfx1250-strict on A0. 1620 rows across 18 config files are keyed to gfx1250 and none to gfx1250-strict, so on A0 every shape they cover falls back to the default path. That is what the plan asks for -- strict tuning has to be explicit and measured, not a filename alias -- so the generated table is the workstream 3 worklist rather than a defect list: each file needs either measured strict rows or a recorded decision that the B0 rows hold on A0. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Generate the module table's gfx1250 signal column The column was hand-filled and followed no single rule: 13 of 135 rows disagreed with any consistent reading of the sources, in both directions. module_custom_all_reduce_gfx1250 was marked by its module name while module_cache was marked `guard` although its sources also compare against the "gfx1250" string literal. Owners use this column to decide where to look, so wrong values send them to the wrong file. --refresh-signals now computes it from the sources that core.get_args_of_build actually resolves, falling back to the raw config expressions for the tune and experimental modules that call skips. The markers are explicit and can combine: `name` for the module name, `str` for the "gfx1250" string literal, `macro` for the __gfx1250__ guard. The distinction matters for A0 risk. `macro` rows keep compiling, because the strict target defines both __gfx1250_strict__ and __gfx1250__. `str` rows are the runtime decisions a strict device silently misses. The refresh changed 27 cells and is idempotent. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Tie the three arch tables together with a test Adding a target means editing GFX_MAP, GFX_CU_NUM_MAP and core.py's allowed_archs, and nothing tied them together. allowed_archs carried a duplicate "gfx1250" entry until this series removed it, which is what that drift looks like in practice. Two invariants hold today and are now pinned: every arch with an offline CU default is accepted by validate_and_update_archs and maps back through GFX_MAP, and gfx1250-strict does the same. Deleting gfx1250-strict from allowed_archs fails both tests, so a half-landed target is caught in CPU-only CI rather than at build time. The check is behavioural -- it drives validate_and_update_archs and get_gfx_custom_op_core with GPU_ARCHS set -- so it also covers the arch reaching hipcc unchanged as --offload-arch, hyphen included. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Record CK modules as skipped when the submodule is not checked out aiter's CK-free auto-exclusion tests os.path.isdir(CK_3RDPARTY_DIR), which is True for an uninitialised submodule: the directory exists, it is simply empty. A checkout without `git submodule update` therefore still tries to build the CK modules, and they fail on missing sources. core._get_ck_exclude_modules() reports 69 of the 135 modules as CK-dependent, so on such a checkout more than half the build matrix would fill with failures that say nothing about the strict target. The driver now treats an empty composable_kernel directory as CK-free and records those modules as skip-no-ck, keeping pass/fail for results that are actually about gfx1250-strict. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Pin PYTORCH_ROCM_ARCH in the build driver Setting GPU_ARCHS alone does not reach the compiler. torch's cpp_extension takes --offload-arch from PYTORCH_ROCM_ARCH, so with GPU_ARCHS=gfx1250 the modules still compiled for torch's own default list -- observed in a ROCm 10.0.0 container as --offload-arch=gfx90a ... --offload-arch=gfx1151 with no gfx1250 anywhere. Every row of the matrix would have been a result for the wrong architectures while looking like a validated one. The driver now derives PYTORCH_ROCM_ARCH from GPU_ARCHS; with that fixed, module_aiter_unary builds for gfx1250 and build.ninja carries exactly one --offload-arch. Failures also kept the wrong 15 lines: ninja echoes the whole compile command, which pushes the diagnostic out of a plain tail, so a failing module recorded only the Python traceback. The recorded tail now leads with up to five "error:" lines. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Record what ROCm 10.0.0 does and does not provide for strict Checked in rocm/atom-dev:latest-rocm10.0 -- ROCm 10.0.0, AMD clang 23.0.0git (ROCm/llvm-project 8f497e0992fb), HIP 7.15.26333. hipcc compiles gfx942 and gfx1250 and rejects gfx1250-strict as an unsupported HIP gpu architecture. The processor list is gfx1250 and gfx1251, and neither libLLVM nor amdclang contains the string gfx1250-strict or __gfx1250_strict__ at all. The only A0/B0 notion in that toolchain is the AMDGPU subtarget feature gfx1250-b0-specific, and it is not reachable from the driver: not a processor, rejected inside a target id, and ignored as a clang target feature. So the build matrix cannot be filled from the public ROCm 10 container -- the plan's toolchain dependency is unmet rather than satisfied -- and there is a question worth settling before the identity model is locked in. If the mechanism that ships is a subtarget feature on gfx1250 rather than a separate processor name, an A0 and a B0 object both carry the target id gfx1250, which is exactly what _so_offload_archs reads, so that guard would need a different discriminator. The survey records the evidence and the question without presuming the answer. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * [JIT] Lead the recorded failure tail with the real compiler diagnostic The error capture grabbed the first five lines containing "error:", which on a failing build are usually the Python RuntimeError and CalledProcessError wrapper lines, not the compiler's own message. Prefer "file:line:col: error:" frontend diagnostics when present, fall back to any "error:" line otherwise (backend errors such as the gfx1250 DPP rejection have no file:line prefix), and de-duplicate -- clang repeats each diagnostic once per offload arch. Verified against a real ROCm 10 matrix run: the ck_tile "extraneous closing brace" / "template exec" and ck "operator[] in Tuple<>" errors now lead their tails instead of the wrapper, and the opus DPP "broadcasts are not supported on GFX10+" backend error still surfaces via the fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Record the measured gfx1250 build matrix on ROCm 10.0.0 Ran the full 135-module matrix in rocm/atom-dev:latest-rocm10.0 with GPU_ARCHS/PYTORCH_ROCM_ARCH=gfx1250: 102 pass, 21 fail, 12 skip. Strict itself does not compile in this toolchain, so this is the gfx1250 baseline -- anything that fails for gfx1250 cannot build for strict, which is gfx1250 plus an A0 code-object identity. Every failure was rebuilt for gfx942 as a control, which corrected my first read of them. They are not a ROCm-10/clang-23 regression: 18 of 21 build cleanly on gfx942 and fail only on gfx1250, and the 3 FMHA-bwd modules that timed out on gfx942 were compiling without error (module_mha_bwd from the same family finished and passed). Every failure is a genuine gfx1250 porting gap: - DPP broadcast dpp_ctrl modes GFX12 removed (moe_sorting_opus, moe_mxfp4_aux) - MFMA / buffer-load-LDS intrinsics GFX12 lacks (iq2r_moe, mha_fwd_native_splitkv) - a wavefrontsize64 request on a wave32 part (chunk_gdr_fwd_h) - warp-size and gfx950-trait static assertions (topk_plain, moe_opus) - CK's ck_tile TDM path, selected on gfx1250 by CK_TILE_USE_BUFFER_ADDRESSING_BUILTIN=0 (the cktile/blockscale GEMMs, activation, sample, the ck_tile FMHA fwd/prefill) - fmha-v3-bwd asm configs not generated for gfx1250 (the mha_bwd family) The inventory now carries the result table with the gfx942 control column and the per-module cause, as the workstream-2 porting worklist. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Correct the strict macro model and inventory __gfx1250__ guards The plan claimed the strict target defines both __gfx1250_strict__ and __gfx1250__, so existing __gfx1250__ guards keep compiling. ROCm 10.1's actual behaviour is the opposite: strict defines __gfx1250_strict__ and does NOT define __gfx1250__ (ROCm/rocm-systems#12068). A __gfx1250__-only device guard therefore compiles its body away on a strict agent -- a silent empty kernel, the upstream TDM_Basic_load_2d failure, with no build error. JAX hit the matching compiler-side fact and dropped strict from its ROCm 10.0 defaults (jax-ml/jax#41187), and ROCm 10.1 adds gfx1250-strict as a distinct --offload-arch target across the stack (RCCL, CK, rocSHMEM), which confirms this PR's distinct-name identity model and the .so guard that keys on it. Fixes, docs only -- no source guard is touched, because the change must not break the shipping ROCm 7 build, whose compiler knows only __gfx1250__ and has no strict target: - plan and inventory legend now state the real macro behaviour and the backward-compatible fix, `defined(__gfx1250__) || defined(__gfx1250_strict__)`, whose strict arm is simply never taken on ROCm 7. - the ROCm 10.0 survey's open "name vs feature" question is resolved: 10.1 ships a distinct target name; the 10.0 gfx1250-b0-specific subtarget feature was an early-LLVM artifact. - ws2_gfx1250_dispatch_sites.py now also inventories the __gfx1250__ preprocessor guards (95 across 24 csrc files) as a generated review table, flagging which already combine with ||/&& to read first. This is the class the earlier string-comparison scan did not cover. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Make every __gfx1250__ device guard also fire on strict Non-asm operators are meant to run on both MI450 SKUs (A0 = gfx1250-strict, B0 = gfx1250); only the shipped asm is B0-only. But the strict compiler defines __gfx1250_strict__ and not __gfx1250__, so every `#if defined(__gfx1250__)` device guard took its #else branch on a strict build -- a silent wrong path that still compiles. Read on A0 this is: get_smem_size returning 64 KB instead of 320 KB, mhc falling back to fp32 instead of the WMMA path, make_gmem returning the 0xffffffff sentinel so stores drop, and the TDM sync counters using the legacy lgkmcnt/vmcnt instead of the split dscnt/loadcnt. Rewrite all 97 `defined(__gfx1250__)` occurrences across 24 csrc files to `(defined(__gfx1250__) || defined(__gfx1250_strict__))`. The parentheses keep it correct in every context: positive guards, `!(...)` exclusion lists (strict is excluded exactly as gfx1250 is), and `||`/`&&` family lists. The strict arm is never taken on the shipping ROCm 7 build, which has no strict target, so that build is unaffected. Compile-verified on ROCm 10.1 (clang 24.0.0git) for both gfx1250-strict and gfx1250 on module_mhc and module_top_k_per_row; both pass for both targets at low parallelism (the earlier full-matrix failures for these were -j179 contention, not real). Runtime correctness on A0 is left to the daily A0 op-test once the modules are built as gfx1250-strict. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the compiled-path gfx1250 dispatch comparisons Non-asm operators run on both MI450 SKUs, and strict is gfx1250 (A0) hardware, so a `get_gfx() == "gfx1250"` dispatch that selects a compiled path must also fire on gfx1250-strict -- otherwise A0 silently takes the generic fallback and, where the gfx1250 branch picks an arch-specific layout (wave32 tiling, LDS budget), gets a wrong result, not just a slow one. Rewrite the 101 compiled-path comparisons across 51 files from `== "gfx1250"` / `in ("gfx1250",)` to `in ("gfx1250", "gfx1250-strict")`. Deliberately NOT changed: the one asm-selecting dispatch, gemm_op_a4w4.py `if gfx_arch in ["gfx1250"]`. Adding strict there would route A0 into the f4gemm asm path, which the asm gate then throws on -- and the policy is that asm is simply unavailable on A0, so strict must keep missing that comparison and fall to the compiled path. The classifier that split compiled from asm sites flagged exactly this one site. py_compile, ruff and black clean (topk.py's pre-existing fmt:skip parse issue aside); the CPU-only arch/dispatch tests still pass. Multi-element arch allowlists (gluon_archs, SUPPORTED_ARCHS) are left for a follow-up -- those are a capability/feature gap on strict, not the correctness-level layout divergence this commit closes. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Cover != "gfx1250" and post-merge dispatch sites for strict The first dispatch pass only rewrote == and single-element `in (...)` comparisons, so `!= "gfx1250"` negations were left behind -- on strict `arch != "gfx1250"` is True and the kernel takes the non-gfx1250 branch, the same silent-wrong-path class the == sites had. The main merge also added fresh gfx1250 comparisons (flydsl pa_decode, triton quant/mla, mla backend plan). Fix the 30 compiled-path sites: `!= "gfx1250"` -> `not in ("gfx1250", "gfx1250-strict")`, `== "gfx1250"` -> `in (...)`. Three asm-selecting sites are deliberately left (attention.py:1752, mha.py:3779, mla_sparse_prefill.py:100) so strict keeps missing them and A0 errors on asm rather than loading it, per the policy that asm is unavailable on A0. py_compile, ruff and black clean; CPU-only arch tests pass. Only the three asm sites now compare against the bare "gfx1250" literal. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the C++ arch_id == "gfx1250" dispatch comparisons get_gpu_arch() in aiter_hip_common.h keeps the full target id, so a strict device reports "gfx1250-strict" and every `arch_id == "gfx1250"` branch in csrc misses -- the same silent-wrong-path class the Python and __gfx1250__ guards had. has_tdm_arch() returned false on strict even though A0 has TDM; mha_bwd picked the wrong launch geometry; and so on. Rewrite the 28 comparisons across 14 files: `X == "gfx1250"` -> `(X == "gfx1250" || X == "gfx1250-strict")`, `X != "gfx1250"` -> `(X != "gfx1250" && X != "gfx1250-strict")`, where X is a plain identifier or get_gpu_arch(). The asm-dispatch sites are included too: the actual asm load still funnels through require_gfx1250_asm_or_throw, which throws on A0, so computing the dispatch as gfx1250 is safe and A0 still cannot load asm. The already-strict-aware asm gate in aiter_hip_common.h is left untouched. Paren balance verified; the gfx942/gfx950 C++ build in CI compiles it. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Add strict to the multi-element arch allowlists The capability allowlists -- gluon_archs, SUPPORTED_ARCHS, _SUPPORTED_GFX, DEVICE_ARCH tuples, the triton tuning kernel decorators -- list gfx1250 as a supported arch but not gfx1250-strict, so strict (which is gfx1250 hardware) was treated as unsupported: no gluon path, excluded from the tuned kernel sets, etc. Add "gfx1250-strict" next to each "gfx1250" element in those arch tuples and lists (41 across 22 files), skipping the substring-match helper (quick_all_reduce's `gfx in arch`, where "gfx1250" already matches "gfx1250-strict") and any asm-selecting context. With the gemm_a4w4 path main restructured, the gfx1250 branch now routes plain MXFP4 to FlyDSL and the rest to asm, so strict correctly gets the FlyDSL path and the asm gate still handles A0. ruff and black clean; CPU-only arch tests pass. This closes the last aiter-side strict dispatch gap; what remains is A0 runtime validation and the Opus .co rebuild. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Pin flydsl to 0.4.0.dev973 for gfx1250-strict LDS support FlyDSL's arch handling is otherwise strict-ready because it matches by prefix (arch.startswith("gfx1250") / "gfx12"), which gfx1250-strict satisfies -- WMMA instruction selection, warp_size (32) and the compile target all come out right. The one gap was the LDS-capacity map, keyed on the exact "gfx1250" string, so on strict the lookup missed and check_smem_capacity silently skipped the overflow guard. 0.4.0.dev973 adds "gfx1250-strict": 327680 to SMEM_CAPACITY_MAP (now in flydsl.runtime.device), closing that gap. Bump the pin in requirements.txt and setup.py (the version assertion and auto-install both derive from FLYDSL_VERSION). Revert to the default release once the fix ships there. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Clean up: drop investigation tooling, tidy strict macro guards Self-review cleanup, no behaviour change: - Remove the ws2_* enumeration/matrix scripts and the generated kernel-inventory doc. Those were one-off investigation flow (build matrix, dispatch-site enumeration) and do not belong in the repo; nothing in aiter imports them. - Drop the dangling "former hotswap path" bullet from the enablement plan; the term exists nowhere in the tree. - Flatten the redundant parentheses the strict sweep left behind: the mechanical `defined(__gfx1250__)` -> `(defined(__gfx1250__) || defined(__gfx1250_strict__))` wrapped the pair even inside OR chains. Unwrap it where the context is pure-OR (90 sites); keep the parentheses only where they are load-bearing -- negation `!(...)` and `&&` operands (7 sites). Compile-verified on ROCm 10.1 for both gfx1250-strict and gfx1250 (module_mhc, module_top_k_per_row); CPU-only arch tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: pin flydsl build-system dep to 0.4.0.dev973 to match setup.py pyproject.toml build-system.requires still pinned flydsl==0.4.0 while setup.py (FLYDSL_VERSION) and requirements.txt use 0.4.0.dev973. Under build isolation pip installed 0.4.0 as the build dep, then setup.py's version assertion rejected it and the build failed. Align all three. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: asm-gate error message covers both A0 detection routes The gate blocks B0 asm on A0 via two routes: gcnArchName == gfx1250-strict, or gcnArchName == gfx1250 with asicRevision 0. The message hardcoded 'gfx1250-strict/A0', which misleads when A0 is caught by the asicRevision route (device name is literally gfx1250, rev 0). State both forms. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: strict Opus codegen + 4 CI-red CPU tests gen_instances: GPU_ARCHS=gfx1250-strict looked up KERNEL_REGISTRY by the strict name, which has no registry key, so Opus codegen emitted an empty header and module_deepgemm_opus failed to build (the only strict-specific failure of the strict build matrix). Fold the registry key to the gfx1250 family (mirroring chip_info._detect_native) while keeping the gfx1250-strict build target, so hipcc still compiles for mach 0xeb. Strict now resolves to 256 CU, same as gfx1250. Tests (Draft CI had skipped these): - test_opus_co_profile load_chip_parsers: keep the _GFX_ARCH_PATTERN constant in the extracted AST namespace (the strict PR added it; parsers NameError'd). - test_build_targets preserve->normalize: _detect_native now folds strict to gfx1250 for dispatch; assert the new behavior. - test_launcher_does_not_pin_the_first_device: use the first declared local kid instead of hard-coded global kid 21016 (removed by ROCm#6937). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: strict Opus codegen emits the gfx1250 family (routes>0), not an empty module The earlier fix only folded the target list; the real route generation still queried the registry by the strict name and produced routes=0 (empty module_deepgemm_opus). Apply the gfx1250 family name at every registry/namespace lookup -- available's 'if gfx in arches', get_registry, default_compiled_keys -- and at the OPUS_BUILD_HAS_* macro (C checks #ifdef OPUS_BUILD_HAS_GFX1250, and a hyphenated STRICT macro is invalid C). KernelKey and the build target keep the gfx1250-strict spelling, so hipcc still offloads for mach 0xeb. Verified: GPU_ARCHS=gfx1250-strict now yields routes=228 (== gfx1250) with OPUS_BUILD_HAS_GFX1250; CPU tests stay green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * [JIT] Opus codegen: normalize gfx1250-strict targets to the gfx1250 family at the source Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: bump flydsl pin to 0.4.0 to match main (dev973 would downgrade it on merge) main pins flydsl==0.4.0; this PR still carried the 0.4.0.dev973 prerelease, so merging would silently downgrade the whole repo. 0.4.0 is a superset of dev973 (contains the gfx1250-strict LDS fix) and is what main already uses. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test: drop redundant test_strict_resolves_through_all_three_tables test_every_offline_target_resolves_through_all_three_tables already loops over GFX_CU_NUM_MAP, which contains gfx1250-strict, so the strict-specific case was an exact duplicate of one loop iteration. * fix: avoid 'in' tuple test in gluon kernel constexpr (unsupported by gluon) The strict-allowlist sweep turned 'ARCH == "gfx1250"' into 'ARCH in ("gfx1250", "gfx1250-strict")' inside gluon kernel bodies/constexpr. Triton's gluon compiler does not implement the 'In' AST operator, so these kernels failed to compile ('AST comparison operator In is not implemented'), breaking test_pa_mqa_logits_2d_context_lens[gluon*] on gfx942/gfx950. Use '(x == a or x == b)', which gluon supports, in kernel scope. Host-side Python 'in' checks are unaffected and left as-is. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Preserve exact gfx1250-strict identity; map to gfx1250 family only at dispatch Per the ROCr rollout contract (all SW consumes the exact GFX ID ROCr reports), global normalization in _detect_native() is the wrong boundary. Once ROCr reports gfx1250-strict for A0, folding it to gfx1250 there makes _needs_arch_rebuild() treat a strict .so as not covering a strict device and rebuild in a loop; it also remixes A0/B0 in tuned configs, caches, and logs. - chip_info._detect_native: drop the strict->gfx1250 fold; return the exact ROCr-reported identity. get_gfx_runtime()/get_gfx() now report gfx1250-strict on A0. - build_targets.py: add the single source of truth for family folding -- GFX_BASE_ARCH, base_gfx_arch(), is_gfx1250_family(). Torch-free, so build scripts and tests import it without side effects. - Opus: replace its two private strict->gfx1250 folds (gen_instances _registry_arch, opus_gemm_common _get_registry_records/get_registry/ default_compiled_keys) with base_gfx_arch(), so there is no second mapping. hipcc still gets --offload-arch=gfx1250-strict and the .co stays mach-0xeb. - mega_moe _require_gfx1250: restore the gfx1250-family guard (via is_gfx1250_family) that main's ROCm#6430 refactor collapsed to bare gfx1250. - Build/cache/tuning/.so/.co/ASM keep the exact identity: _needs_arch_rebuild and _so_offload_archs already key on it, so A0 never loads a B0 object. - Pre-existing gfx1250-only dispatch sites authored by other PRs stay exact; with the fold gone they correctly distinguish strict (fall back) instead of silently reusing a B0 path. - Tests: flip the native-detection test into a regression lock that strict identity is preserved; add family-helper and 4-way code-object rebuild-guard tests (runtime/built strict x gfx1250 -> accept/reject). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Apply ruff import sort and black formatting to the identity refactor Fixes the pre-checks (ruff I001 import order in mega_moe, black reformat of mega_moe and test_build_targets_architecture) that gated check-signal and skipped the Triton/Aiter test runs. No logic change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * black: wrap the long gfx1250/gfx1250-strict dispatch conditions in the gluon kernels The in->or fix in the pa_mqa_logits / unified_attention_2d gluon kernels left two over-length boolean conditions that Black wraps. Formatting only; the gluon compiler still sees the same (x == a or x == b) expression. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Define Opus base_gfx_arch locally instead of importing build_targets The cross-package `from build_targets import base_gfx_arch` (via a __file__-relative sys.path insert) breaks the Aiter wheel build: gen_instances.py runs from a staging tree (aiter_meta/csrc/opus_gemm) where ../../aiter/jit/utils does not exist, so module_deepgemm_opus failed with ModuleNotFoundError: No module named 'build_targets'. Duplicate the one-line helper locally in opus_gemm_common (documented to mirror build_targets.base_gfx_arch) so the standalone Opus codegen has no cross-tree import dependency. gen_instances keeps importing it from opus_gemm_common. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * test(jit_cache): seed _cluster_launch_target in the build_module sandbox test_jit_cache_transaction AST-extracts build_module into a sandbox namespace with CPU deps injected. Since the gfx1250-strict work added a _cluster_launch_target(get_gfx) call inside MainFunc, the sandbox hit NameError: name '_cluster_launch_target' is not defined (25 TestBuildPublication errors on MI35X). This surfaced only now because the earlier Opus wheel-build failure skipped the standard tests. Inject the dependency like the others; for the gfx942 test context the real function returns False, so the mock matches. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: zufayu <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: root <[email protected]>


Summary
Brings the gfx1250 MegaMoE mori path from
yanbo/megato main, follows mori's EPv2 plans (requires ROCm/mori#844), and builds MegaMoE from a recipe. MegaMoE drives mori'sEpDispatchPlan/EpCombinePlandirectly, so it sizes and binds what mori's op layer would.Usage
What changes
API
MegaMoERecipeis the transport. Itscomputefield, anExpertComputeConfig, is the expert GEMM.MegaMoEGeometryis the shape. All three are frozen and hashable.The stages declare which pairings run:
morifused_scattermorimoricompactfused_scatterfrom_recipeis the entry point. The keyword constructor is deprecated;MegaMoERecipe.from_legacymaps its flags.forward(combine_wire=)picks the step's combine wire.combine_quant=still works.required_vmm_bytes(recipe, geometry)is the per-rank cco VMM the arena takes, rounded asccoMemAllocrounds it. It is MegaMoE's share only. The [FlyDSL] feat(mega_moe): add required_vmm_bytes for cco sizing #6525 keyword form returns the largest arena any recipe with that dispatch takes.mori
Plan.describe()(feat(ep/v2): plans report the arena and staging sizes they need (info + describe) mori#844). mori checks the arena and the staging tensor against them at bind.MORI_EP_TOKOFF_EXT=1is refused.total_recv.zero_(): the dispatch overwrites it.combine=mori, GEMM2 writes its rows straight into mori's combine staging (zero copy).compact+fused_scatterdoes not use mori.Structure (
aiter/ops/flydsl/kernels/mega_moe_gfx1250/)recipe.pyholds the recipe, geometry and config.mori_caps.py: every mori name goes through it.arena.pyholds the arena layout and cco rounding.stages/holds one module per dispatch and combine stage;base.pyhas their protocols.transport.py(_EpDispatcher) checks everything before the arena is allocated and frees what it built on failure.mega_moe.pyis the facade. It keeps the members ATOM's Triton experts use:_config,_arena,_dispatch(),_combine(),_recv_dispatch_scales().Behavior changes
dispatch_backendruns mori's dispatch.dispatch_backend="flydsl"needsstage1_fused=True.$MEGA_DISPATCHis no longer read.MORI_EP_TOKOFF_EXT=1on a single host. Its ~8.5 GB per GPU (DeepSeek-R1, EP4) goes to the KV cache.recv_token_bound/next_recv_token_boundoutside(0, world_size * max_tokens_per_rank]raise on both dispatches, and must be the same on every rank.recv_token_bound, the compact dispatch is sized for the arena's capacity. A plan started for another bound's alignment is refused.AITER_FORCE_A8W4only matters on bf16.a1_scaleon a quantizing wire raisesValueError.forward(recv_counter_is_zero=)is accepted and ignored.bench_mega_moe.pyruns on gfx1250 only, builds from a recipe, and sizes cco withrequired_vmm_bytes.Tests
op_tests/multigpu_tests/test_mega_moe_gfx1250.pyneeds gfx1250, at least two GPUs and mori. It covers:from_recipe;required_vmm_bytesagainst the real allocation.tests/test_mega_moe_gfx1250_recipe.pyneeds no GPU. It covers the recipe, its errors, the arena layout over a grid of geometries,required_vmm_bytes, and the recv-token bound.Replaces #6272, which targeted
yanbo/mega.Co-authored-by: yanboshao [email protected]
🤖 Generated with Claude Code