Skip to content

Fix all_gather_matmul_hbm_buffer: partial M groups, small K, int64 offsets - #632

Open
dsidler wants to merge 1 commit into
mainfrom
dev/dasidler/ag-matmul-fixes
Open

dsidler wants to merge 1 commit into
mainfrom
dev/dasidler/ag-matmul-fixes

Conversation

@dsidler

@dsidler dsidler commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes to existing ops, split out of #496 so they land independently of the SDMA work (#629 and the copy-engine ops).

Partial M groups hang (all_gather_matmul_hbm_buffer)

When the M-tiles of a fetch stage (or of the whole problem) are not a multiple of group_size_m, the fetch decode never set some K flags, so the GEMM workgroups waited forever (a hang). The GEMM decode also let a group run past the end of its stage. The group size is now clamped to the stage's remaining M-tiles in both decodes. Full groups decode exactly as before, and any group_size_m works. This replaces the TODO (there is a bug if #M-Tiles is not multiple of GROUP_SIZE_M) and the host-side check suggested in the #496 review: a check would also reject the shipped champion config (8 tiles per stage, group_size_m=24) and some _auto_config defaults, so the kernel is fixed instead.

Small / single-rank problems

The default k_per_flag is halved until it divides the K-blocks, instead of hitting an assert when there are fewer than 8.

int64 offsets

C and staged_a offsets in all_gather_matmul and all_gather_matmul_hbm_buffer are computed in int64 to avoid int32 overflow on large problems.

Tests

  • test_all_gather_matmul_hbm_buffer_partial_m_groups: 5 group/stage combinations (partial group in one stage, group larger than the problem, 2 stages with partial groups).
  • test_all_gather_matmul_hbm_buffer_default_k_per_flag_small_problem.
  • No test for the int64 offsets: overflow needs a very large heap/shape.

Verified in iris-dev (8 GPUs): on origin/main the new partial-group tests hang and the small-K test fails the k_per_flag assertion; with this change they pass. tests/ops/test_all_gather_matmul.py passes 36/36 at 4 ranks, the new tests pass at 1 and 2 ranks; ruff clean.

Independent of #629.

🤖 Generated with Claude Code

…nt64 offsets

- Partial M groups: when the M-tiles of a fetch stage (or of the problem) are
  not a multiple of group_size_m, the fetch decode left some K flags unset
  (the GEMM workgroups then spin forever) and the GEMM group extended into the
  next stage. Clamp the group size to the stage in both the fetch and the GEMM
  decode, so any group_size_m works. Previously this hung.
- Halve the default k_per_flag until it divides the K-blocks, so small and
  single-rank problems work instead of hitting an assert.
- Use int64 offsets for C and staged_a (all_gather_matmul and hbm_buffer) to
  avoid int32 overflow on large problems.

Adds tests for partial M groups (several group/stage combinations) and for the
default k_per_flag on a small problem.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added in-progress We are working on it iris Iris project issue labels Nov 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in-progress We are working on it iris Iris project issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant