Skip to content

[FlyDSL] Tdm new interface refactor: make_tdm_atom -> make_tiled_tdm_atom - #7213

Merged
coderfeli merged 5 commits into
mainfrom
tdm-tiled-redo-20261030
Nov 3, 2026
Merged

coderfeli merged 5 commits into
mainfrom
tdm-tiled-redo-20261030

Conversation

@xudoyuan

Copy link
Copy Markdown
Contributor

Summary

make_tdm_atom -> make_tiled_tdm_atom

Motivation

Changes

Performance (if applicable)

Hardware Workload/configuration Before After Change

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

PR Self-Review

Reviewed revision

Behavior and intent

Validation and unverified scope

PR-specific question

Changed op tests

@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 7213 --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.

@aiter-bot

aiter-bot commented Oct 30, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision d9f2b0c90512 · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What is the most important boundary or failure mode introduced by this change, and what evidence covers it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@xudoyuan
xudoyuan marked this pull request as ready for review October 31, 2026 05:49
@xudoyuan
xudoyuan requested a review from a team October 31, 2026 05:49
@zufayu
zufayu requested a review from coderfeli November 2, 2026 01:22
xudoyuan and others added 4 commits November 2, 2026 17:59
Converts the five `fx.rocdl.make_tdm_atom` sites that are plain
(non-gather, non-split-padding) copies to
`fx.rocdl.cdna5.make_tiled_tdm_atom` + `tdm_partition`:

  gemm_a8w8_gfx1250.py:922          C store
  gemm_a4w4_256x256_gfx1250.py:848  C store
  gemm_a4w4_gfx1250.py:471          C store
  mla_pagesize1_fp8_fp8.py:1517     per-wave O store
  mla_pagesize1_bf16_bf16.py:1450   per-wave O store

All five are padded stores. A TDM store cannot drain a padded LDS tile, so
each spells the pad the way the old interface did: `tdm_tile` is the PADDED
width and the global view's inner extent is the REAL width, leaving the
derived padAmount at 0 and letting boundary_check drop the pad columns. The
old `tensor_extents` clamps move into the view's shape unchanged, including
the runtime ones (`mn_oob`, `store_rows`), so M tails, split-k offsets,
`batched` offsets and the zero-row invalid-wave store all behave as before.

Dropped `early_timeout=False` on the a8w8 C store (already false).

Verified against the FlyDSL wheel aiter pins (`flydsl==0.4.1`), not a local
FlyDSL checkout, with each variant in its own FLYDSL_RUNTIME_CACHE_DIR:

  test_gemm_a8w8_mxfp8_bpreshuffle.py   36 shapes, err 0, median -0.07%
  test_gemm_a4w4.py                    116 rows / 58 timed, err 0, median +0.03%
  test_mla_flydsl.py                    45 shapes, err 0, median -0.31%

Baselines came from a separate worktree at main. Outliers past +/-5% appear
in both directions on the a4w4 suite and match its known run-to-run spread.

Not converted, with reasons:
  - gemm_a8w8_gfx1250.py:318/332/348 -- the A load carries A_PAD_SPLIT split
    padding, which a flat LDS box cannot express; needs the K axis split into
    pad-interval chunks on box and view both, plus a K-extent audit at every
    caller. Its mx128 scale caller additionally needs FlyDSL #1309, which is
    NOT in the pinned 0.4.1.
  - mxfp4_preshuffle_gfx1250_tdm.py:680/801/2362 and
    mega_moe_gfx1250/combine.py:460 -- convertible, but no single-GPU op_test
    reaches them; they need an output-equivalence driver rather than a suite.
  - the gather/scatter family -- make_tiled_tdm_atom takes only
    TensorLoad()/TensorStore().

Co-Authored-By: Claude Opus 5 <[email protected]>
Continues the same refactor: gemm_a8w8_gfx1250.py:332's B load moves to the
layout-friendly interface. Its K advance becomes an i32 tile index on the
coordinate rest instead of a byte imm_offset, and the view spans the whole K,
which also retires the per-iteration "extent_1" write that handled the K
tail. B_LDS_ROW == tile_k * 16, so the box carries no padding, as before.

Verified per shape against main over the configurations the B path varies on
-- sk4, sk2 fused-splitk, sk1 and t256x256x128 -- err 0 on both sides, timing
within noise. The full-suite sequential run is currently unusable on this
machine: it takes a GPU memory access fault at a different shape each run on
main as well as on this branch, with other tenants on the same device.

Also removes the explanatory comments added by the previous commit.

Co-Authored-By: Claude Opus 5 <[email protected]>
Three more sites onto the layout-friendly interface:

  mxfp4_preshuffle_gfx1250_tdm.py  make_tdm_store helper + both C-store callers
  mega_moe_gfx1250/combine.py:460  scale-plane load

mxfp4's three store branches collapse into one tiled_store helper: with
STORE_PAD == 0 the padded width STORE_PITCH equals STORE_N, so the no-pad
branch is the same expression and no longer needs its own code path.

combine's scale plane was held back by the 16-byte tile_dim0 span floor, as
its own comment recorded. The pinned flydsl is now 0.4.1, which carries the
relaxed padAmount-gated rule, so the plane gets the SC_TILE the comment
described and its LDS view grows the size-1 rest that tdm_partition needs.

mxfp4: op_tests/test_flydsl_batched_gemm.py, 80 shapes passed before the run
hit a GPU memory access fault whose faulting kernel is a Tensile assembly
kernel (Cijk_Alik_Bljk_..._ISA1250_...), not a FlyDSL one -- the same
shared-device instability seen on main elsewhere in this branch.
combine: no single-GPU entry point; compile-checked only.

Not converted: mxfp4_preshuffle_gfx1250_tdm.py's segmented add_tdm_loads
folds each wave's inner offset into the base pointer. The tiled coordinate
rest counts tiles rather than rows, so that offset has to move into the
rest's starting index instead, across six callers with different geometries,
and it carries a per-iteration tail extent as well. That class of mistake
produces wrong addresses, not a compile error, so compile-only evidence
cannot cover it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
@yadaish
yadaish force-pushed the tdm-tiled-redo-20261030 branch from 19ad990 to 0e9beab Compare November 2, 2026 14:47
@zufayu
zufayu requested a review from aoli26 November 3, 2026 06:34
@coderfeli
coderfeli merged commit 7c163c8 into main Nov 3, 2026
@coderfeli
coderfeli deleted the tdm-tiled-redo-20261030 branch November 3, 2026 07:42
yadaish pushed a commit that referenced this pull request Nov 10, 2026
add_tdm_loads was the one site PR #7213 left behind: it carved each wave's
slice out by hand, folding the slice offset into the base pointer, and the
tiled coordinate rest counts tiles rather than rows, so that offset had to
move somewhere else across six callers with different geometries.

It does not have to move anywhere. The atom is now built with
num_warps=len(wv) and tdm_partition hands each owner its share of the same
compact LDS traversal, whichever axis that splits. The outer/inner segment
arithmetic, the per-wave base offsets and the split_inner flag that chose
between the two axes all go away, along with the Job fields that carried them.

Each view spans every k-tile its rest index reaches instead of one tile at a
runtime offset, so the ragged last tile is clamped by the view's own extent:
the per-iteration extent_1 write, its is_tail predicate and the tail_ext field
are gone, and imm_offset becomes the rest's tile number. pad_interval /
pad_amount are implicit in a box row wider than the tile, so the pad argument
survives only as an assertion that the two agree.

Net -5 lines, and the remaining asserts state the invariants the old form
computed: the rest steps exactly one tile per k-tile, and a padded row stays
inside the pad interval's encodable range.

No make_tdm_atom call sites remain in aiter.

Unverified: the GPU was busy and the AOT dry run reaches the GPU runtime for
every config on main as well, so neither path could gate this yet.

Co-Authored-By: Claude Opus 5 <[email protected]>
coderfeli pushed a commit that referenced this pull request Nov 11, 2026
…atom (#7655)

* [FlyDSL] Migrate the a8w8 gfx1250 A load and scale atoms to the tiled atom

Seven make_tdm_atom sites: the A load and the six scale atoms _tdm1 builds.

_tdm1 now returns (atom, blk). Every scale view spans the whole K rather than
one k-tile, because the rest index the copy uses carries the split-k base and a
one-split extent would put the later tiles out of bounds, where boundary_check
returns zeros instead of failing. The ragged last tile is clamped by that same
extent, so _tail -- which wrote extent_1 per iteration, a slot the tiled atom
does not expose -- is gone, and with it K_REM and the six sa_imm/sb_imm
closures.

The mx128 B scale is the site the migration notes recorded as unconvertible:
its (N_BLOCKS, K_WS) tile collapses to one element along the contiguous mode at
tile_k == 128, which deriveTdmAtom could not describe. flydsl 0.4.2 carries
ROCm/FlyDSL#1309, which puts the contiguous mode's filler dim at the front, so
it builds now. The non-m-major mx128 A scale keeps K on its outer axis and
takes its rest from there.

The A load pads once per A_PAD_INTERVAL. A flat (row, stride) box states a
single skip at the end, so a row needing more than one pad splits its K axis on
the global view and the LDS box alike; A_PAD_SPLIT == 1 keeps the flat form, so
the common path is untouched.

early_timeout is dropped rather than restored as atom state: on the tiled atom
bit 21 comes from a runtime slot guarded by assume(early == 0 || mask != 0),
and writing it under a zero mask is undefined behaviour.

Unverified: the AOT dry run reaches the GPU runtime on this machine for every
config on main as well (0 ok / 2011 failed either side), so it is not a usable
compile gate here, and the GPU was busy.

Co-Authored-By: Claude Opus 5 <[email protected]>

* [FlyDSL] Migrate the mxfp4 segmented TDM loader to the tiled atom

add_tdm_loads was the one site PR #7213 left behind: it carved each wave's
slice out by hand, folding the slice offset into the base pointer, and the
tiled coordinate rest counts tiles rather than rows, so that offset had to
move somewhere else across six callers with different geometries.

It does not have to move anywhere. The atom is now built with
num_warps=len(wv) and tdm_partition hands each owner its share of the same
compact LDS traversal, whichever axis that splits. The outer/inner segment
arithmetic, the per-wave base offsets and the split_inner flag that chose
between the two axes all go away, along with the Job fields that carried them.

Each view spans every k-tile its rest index reaches instead of one tile at a
runtime offset, so the ragged last tile is clamped by the view's own extent:
the per-iteration extent_1 write, its is_tail predicate and the tail_ext field
are gone, and imm_offset becomes the rest's tile number. pad_interval /
pad_amount are implicit in a box row wider than the tile, so the pad argument
survives only as an assertion that the two agree.

Net -5 lines, and the remaining asserts state the invariants the old form
computed: the rest steps exactly one tile per k-tile, and a padded row stays
inside the pad interval's encodable range.

No make_tdm_atom call sites remain in aiter.

Unverified: the GPU was busy and the AOT dry run reaches the GPU runtime for
every config on main as well, so neither path could gate this yet.

Co-Authored-By: Claude Opus 5 <[email protected]>

* [Docs] Record that make_tdm_atom is retired in aiter

Both skills still described fx.rocdl.make_tdm_atom as a live interface with a
migration pending. No aiter kernel calls it any more, so they now say so and
spell out what replaced each parameter: extents and strides move into the
global view's layout, imm_offset becomes the coordinate tensor's tile index,
pad_interval / pad_amount become row slack in the LDS box, and a hand-split
across waves becomes num_warps plus a matching tdm_partition warp layout.

early_timeout is called out as dropped rather than rewritten, because on the
tiled atom that bit comes from a runtime slot guarded by
assume(early == 0 || mask != 0) and writing it under a zero mask is undefined
behaviour.

The remaining exception is the gather/scatter family. The 16-byte innermost
span is noted as a FlyDSL check rather than an ISA rule, and the one-element
contiguous-mode tile is noted as fixed in flydsl 0.4.2 (ROCm/FlyDSL#1309).

Co-Authored-By: Claude Opus 5 <[email protected]>

* [FlyDSL] Define the pad-interval bound the mxfp4 loader asserts against

The assert added with the tiled-atom migration referenced
_TDM_MAX_PAD_INTERVAL_BYTES, which is defined in gemm_a8w8_gfx1250.py and not
here. It sits inside a traced function, so the NameError was a trace-time
crash rather than a lint error: every launch of this kernel died before the
migrated loader ran at all.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…atom (ROCm#7213)

* [FlyDSL] Migrate five gfx1250 TDM stores to the tiled atom

Converts the five `fx.rocdl.make_tdm_atom` sites that are plain
(non-gather, non-split-padding) copies to
`fx.rocdl.cdna5.make_tiled_tdm_atom` + `tdm_partition`:

  gemm_a8w8_gfx1250.py:922          C store
  gemm_a4w4_256x256_gfx1250.py:848  C store
  gemm_a4w4_gfx1250.py:471          C store
  mla_pagesize1_fp8_fp8.py:1517     per-wave O store
  mla_pagesize1_bf16_bf16.py:1450   per-wave O store

All five are padded stores. A TDM store cannot drain a padded LDS tile, so
each spells the pad the way the old interface did: `tdm_tile` is the PADDED
width and the global view's inner extent is the REAL width, leaving the
derived padAmount at 0 and letting boundary_check drop the pad columns. The
old `tensor_extents` clamps move into the view's shape unchanged, including
the runtime ones (`mn_oob`, `store_rows`), so M tails, split-k offsets,
`batched` offsets and the zero-row invalid-wave store all behave as before.

Dropped `early_timeout=False` on the a8w8 C store (already false).

Verified against the FlyDSL wheel aiter pins (`flydsl==0.4.1`), not a local
FlyDSL checkout, with each variant in its own FLYDSL_RUNTIME_CACHE_DIR:

  test_gemm_a8w8_mxfp8_bpreshuffle.py   36 shapes, err 0, median -0.07%
  test_gemm_a4w4.py                    116 rows / 58 timed, err 0, median +0.03%
  test_mla_flydsl.py                    45 shapes, err 0, median -0.31%

Baselines came from a separate worktree at main. Outliers past +/-5% appear
in both directions on the a4w4 suite and match its known run-to-run spread.

Not converted, with reasons:
  - gemm_a8w8_gfx1250.py:318/332/348 -- the A load carries A_PAD_SPLIT split
    padding, which a flat LDS box cannot express; needs the K axis split into
    pad-interval chunks on box and view both, plus a K-extent audit at every
    caller. Its mx128 scale caller additionally needs FlyDSL ROCm#1309, which is
    NOT in the pinned 0.4.1.
  - mxfp4_preshuffle_gfx1250_tdm.py:680/801/2362 and
    mega_moe_gfx1250/combine.py:460 -- convertible, but no single-GPU op_test
    reaches them; they need an output-equivalence driver rather than a suite.
  - the gather/scatter family -- make_tiled_tdm_atom takes only
    TensorLoad()/TensorStore().

Co-Authored-By: Claude Opus 5 <[email protected]>

* [FlyDSL] Convert the a8w8 B load too, and drop the added comments

Continues the same refactor: gemm_a8w8_gfx1250.py:332's B load moves to the
layout-friendly interface. Its K advance becomes an i32 tile index on the
coordinate rest instead of a byte imm_offset, and the view spans the whole K,
which also retires the per-iteration "extent_1" write that handled the K
tail. B_LDS_ROW == tile_k * 16, so the box carries no padding, as before.

Verified per shape against main over the configurations the B path varies on
-- sk4, sk2 fused-splitk, sk1 and t256x256x128 -- err 0 on both sides, timing
within noise. The full-suite sequential run is currently unusable on this
machine: it takes a GPU memory access fault at a different shape each run on
main as well as on this branch, with other tenants on the same device.

Also removes the explanatory comments added by the previous commit.

Co-Authored-By: Claude Opus 5 <[email protected]>

* [FlyDSL] Convert the mxfp4 C stores and the combine scale load

Three more sites onto the layout-friendly interface:

  mxfp4_preshuffle_gfx1250_tdm.py  make_tdm_store helper + both C-store callers
  mega_moe_gfx1250/combine.py:460  scale-plane load

mxfp4's three store branches collapse into one tiled_store helper: with
STORE_PAD == 0 the padded width STORE_PITCH equals STORE_N, so the no-pad
branch is the same expression and no longer needs its own code path.

combine's scale plane was held back by the 16-byte tile_dim0 span floor, as
its own comment recorded. The pinned flydsl is now 0.4.1, which carries the
relaxed padAmount-gated rule, so the plane gets the SC_TILE the comment
described and its LDS view grows the size-1 rest that tdm_partition needs.

mxfp4: op_tests/test_flydsl_batched_gemm.py, 80 shapes passed before the run
hit a GPU memory access fault whose faulting kernel is a Tensile assembly
kernel (Cijk_Alik_Bljk_..._ISA1250_...), not a FlyDSL one -- the same
shared-device instability seen on main elsewhere in this branch.
combine: no single-GPU entry point; compile-checked only.

Not converted: mxfp4_preshuffle_gfx1250_tdm.py's segmented add_tdm_loads
folds each wave's inner offset into the base pointer. The tiled coordinate
rest counts tiles rather than rows, so that offset has to move into the
rest's starting index instead, across six callers with different geometries,
and it carries a per-iteration tail extent as well. That class of mistake
produces wrong addresses, not a compile error, so compile-only evidence
cannot cover it.

Co-Authored-By: Claude Opus 5 <[email protected]>

* [FlyDSL] black formatting

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants