Skip to content

gemm: every MXFP8 GEMM shape's rows in its own folder, no common table - #9

Merged
benenzhu merged 1 commit into
Inferact:mainfrom
benenzhu:gemm-rows-per-shape
Nov 20, 2026
Merged

benenzhu merged 1 commit into
Inferact:mainfrom
benenzhu:gemm-rows-per-shape

Conversation

@benenzhu

@benenzhu benenzhu commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Every MXFP8 GEMM shape's rows move out of the common table gemm/mxfp8_common/mxfp8_gemm_tuned.py into the shape's own folder gemm/mxfp8_n<N>_k<K>/host.py (ROWS via gemm.parse_rows, select via gemm.select_from_rows), registered in gemm._SHAPE_HOSTS. A shape is then tuned, or gets kernels of its own, in its folder, and a row change cannot reach another shape through a shared file. Two layers with the same (N, K) run the same GEMM and share the folder's rows (as gemm/mxfp8_n6144_k6144 from #5 already does).

  • New folders, rows only: n1280_k6144, n1536_k6144, n2304_k6144, n3072_k6144, n4608_k6144, n6144_k768, n6144_k1536, n6144_k3072, n12288_k6144.
  • The folders with kernels of their own (n2560_k6144, n4992_k6144, n6144_k2048, n6144_k4096, n6144_k8192) try their windows first (_select_own, unchanged), then their ROWS: the order _select_config used with the table.
  • _load_tuned_configs gathers the folders' rows, tuned_shapes reads them, and the table file is gone. The column notes moved to parse_rows' docstring, the measurement notes to the folders.
  • tests/gemm/mxfp8_common/test_shape_folders.py: dispatch goes through every folder, tuned_shapes is the folders' keys, no common table.

No behavior change. I dumped every config choice on main (79dc256) and on this branch: _select_config (both allow_decode), the prequant and deferred configs, and prequant_code_tile_rows, for every shape, bf16 and fp16, at every row count 1-65536, plus tuned_shapes. 0 differences.

Tests (8 x MI355X, ROCm 7.2 image, FlyDSL 0.5.0, tools/ci full suite at ba03308): 259 / 262 targets.

  • gemm/mxfp8_n4992_k6144/test_warmup and moe/mxfp4_h6144_i768_e128_top4/test_gemm2_adaptive never started (two targets hit a container-start race in the CI job); alone they pass, 28 passed.
  • test_handoffs.py::test_side_stream_pool_recorded_grows[True] fails on that node without this branch too (3 of 3 runs at amd-kernels: tensor parallel 2 for MiniMax-M3.1-Flash on MI355X #5's head): its pool check depends on the allocator's state. It will be fixed in a test PR.
  • test_shape_folders, test_tuned_shapes, test_decode_splitk, test_dispatch and every shape folder's tests pass.

🤖 Generated with Claude Code

Each (N, K)'s rows move out of gemm/mxfp8_common/mxfp8_gemm_tuned.py into its folder
gemm/mxfp8_n<N>_k<K>/host.py (ROWS via gemm.parse_rows, select via gemm.select_from_rows), so a shape is tuned and
optimized in its own folder and a change to one shape cannot reach another through a shared file.

- New folders (rows only): n1280_k6144, n1536_k6144, n2304_k6144, n3072_k6144, n4608_k6144, n6144_k768,
  n6144_k1536, n6144_k3072, n12288_k6144.
- Folders with kernels of their own (n2560_k6144, n4992_k6144, n6144_k2048, n6144_k4096, n6144_k8192): their
  windows first (_select_own, unchanged), else their ROWS, the order _select_config used with the table.
- gemm: _SHAPE_HOSTS lists every folder; _load_tuned_configs gathers the folders' ROWS; tuned_shapes reads them;
  mxfp8_gemm_tuned.py is gone (its column notes are parse_rows' docstring, the measurement notes the folders').
- No config choice changes: _select_config (both allow_decode), the prequant and deferred configs and
  prequant_code_tile_rows at every row count 1-65536, bf16 and fp16, of every shape, and tuned_shapes, equal main's.
- tests: test_shape_folders (dispatch through every folder, tuned_shapes, no common table) replaces the 6144 x 6144
  folder test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Taoyu Zhu <[email protected]>
@benenzhu
benenzhu marked this pull request as ready for review November 20, 2026 09:06
@benenzhu
benenzhu merged commit 207814b into Inferact:main Nov 20, 2026
1 of 3 checks passed
benenzhu added a commit to shen-shanshan/amd-kernels that referenced this pull request Nov 20, 2026
Conflict in amd_kernels/README.md only: main's index (Inferact#5's TP2 packages, Inferact#9's shape folders) with this PR's
gemm/mxfp8_bmm_mxfp8_out_n1024_k4096 line after the dense MLP gate_up lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Taoyu Zhu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant