Skip to content

[FlyDSL] [JIT] [gfx1250] Cut remaining host overhead in FlyDSL GEMM/MoE wrappers - #7006

Merged
yhl-amd merged 1 commit into
ROCm:mainfrom
yhl-amd:flydsl-host-fastpath
Oct 27, 2026
Merged

yhl-amd merged 1 commit into
ROCm:mainfrom
yhl-amd:flydsl-host-fastpath

Conversation

@yhl-amd

@yhl-amd yhl-amd commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What

FlyDSL-only split of #6948 (closed): the Triton gemm_a16w16 changes (gluon layout memoisation, nested gemm_a16w16_ dispatch) are dropped, as the review suggested separating the backends. Complements #6946 (merged; caches compiled FlyDSL launchers). No kernel changes; kernel selection and outputs are unchanged.

  • mxfp8_32 untuned-shape kernel pick memoised per M class (batched_gemm_a8w8_gfx1250): the heuristic depends on M only through ceil(M / tile_m) per candidate tile (saturated past the M-block limit), plus M parity when an A-preshuffle candidate exists, so that tuple is the cache key; kernel-name parsing is cached too. Identical result to the per-M heuristic; prefill hands every linear a new M each step.
  • get_mxscale_bpreshuffle_config: early return for an N/K with no tuned row at any M, and the "untuned" warning is logged once per (N, K, w_scale) instead of once per M.
  • Nested custom op calls the registered body directly (gemm_a8w8_blockscale → gemm_a8w8_blockscale_bpreshuffle) via torch_compile_guard's new _eager_body attribute, instead of a second torch.ops dispatch. A rebound module attribute is still honoured.
  • grouped_gemm_gfx1250_a8w4: _grouped_dbg strings are built only when AITER_GROUPED_DEBUG is on, and the arch-override env reads are skipped on native gfx1250.

Why

DeepSeek-V4.1-Flash serving on MI455X (gfx1250, ATOM TP4): prefill steps were dominated by Python dispatch in the op wrappers rather than GPU work.

Host us/call, gfx1250, DSV4.1 TP4 shapes, M=1758 (#6946 → #6946 + these changes, measured on #6948):

path before after
6 mx32 linears, new M each call 2962 157
6 mx32 linears, fixed M 164 151
fused_moe a8w4 229 206

Outputs bitwise identical.

Testing

Re-run on this branch (main 699d750 + this commit), gfx1250 (MI455X), single GPU:

🤖 Generated with Claude Code

…ppers

FlyDSL-only split of ROCm#6948 (the Triton gemm_a16w16 changes are
dropped). Complements ROCm#6946 (compiled FlyDSL launcher cache).

- batched mxfp8_32 GEMM: memoise the untuned-shape heuristic per M class
  (ceil(M / tile_m) per candidate tile, saturated past the M-block limit,
  plus M parity when an A-preshuffle candidate exists) instead of per exact
  M, and cache kernel-name parsing. Prefill hands every linear a new M each
  step; the pick is identical to the per-M heuristic.
- get_mxscale_bpreshuffle_config: answer an N/K with no tuned row at any M
  without walking the padded-M levels, and log an untuned weight shape once
  per (N, K, w_scale_block) instead of once per M.
- gemm_a8w8_blockscale -> gemm_a8w8_blockscale_bpreshuffle: the outer custom
  op's body calls the nested op's body directly instead of a second torch.ops
  dispatch. torch_compile_guard exposes the body it registered as
  ``_eager_body``; a rebound module attribute is still honoured.
- grouped_gemm_gfx1250_a8w4: build debug strings only when
  AITER_GROUPED_DEBUG is on and skip the arch-override env reads on gfx1250.

op_tests/test_gemm_host_dispatch_cache.py checks each cache against the
uncached answer (CPU contracts plus bitwise GPU comparisons).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yhl-amd
yhl-amd requested a review from a team October 27, 2026 08:54
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7006 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@github-actions github-actions Bot changed the title [FlyDSL] [gfx1250] Cut remaining host overhead in FlyDSL GEMM/MoE wrappers [FlyDSL] [JIT] [gfx1250] Cut remaining host overhead in FlyDSL GEMM/MoE wrappers Oct 27, 2026
@XiaobingSuper

Copy link
Copy Markdown
Contributor

Tested this PR in the matched MiniMax-M3 prefill workload on MI455/gfx1250.

Configuration: rocm/fw-bringup-mlperf:gfx1250-atom-20261016, TP4, FP8 KV, prefill tok=2517 / ctx=105301, identical ATOM tree and aiter M3 stack except for this commit. Each trace contains 57 MoE layers per rank.

Four-rank averages:

  • aiter::moe_forward: 62.865 -> 60.197 ms/step (-2.668 ms, -4.2%)
  • aiter::fused_moe_: 56.932 -> 54.335 ms/step (-2.597 ms, -4.6%)
  • mean of per-rank median moe_forward: 1076.8 -> 1023.7 us/layer (about -53 us/layer)
  • hipLaunchKernel count stayed at 954/rank, as expected for a host-dispatch-only optimization

start_sync_kernel should not be used as direct evidence for this PR: its four-rank average was effectively unchanged (133.395 vs 133.632 ms) while the wait moved between ranks. That confirms it is primarily an arrival-skew symptom. The whole traced step also contained multi-second cold JIT events, so I am not claiming an E2E latency delta from this one trace.

Validation on the combined tree: pytest -q op_tests/test_gemm_host_dispatch_cache.py -> 32 passed.

@aoli26 aoli26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yhl-amd
yhl-amd merged commit d5dc194 into ROCm:main Oct 27, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants