Skip to content

fix(fused-ops): make supports() and the tile check match construction; fix two doc errors - #979

Merged
yangyuhuiling merged 6 commits into
mainfrom
xiangch/fused-ops-small-fixes
Nov 17, 2026
Merged

yangyuhuiling merged 6 commits into
mainfrom
xiangch/fused-ops-small-fixes

Conversation

@yangyuhuiling

@yangyuhuiling yangyuhuiling commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Four small fixes in the fused GEMM + collective ops, found while writing the MORI-FUSED user guides (#973). Two make a validation path agree with the constructor; two correct documentation.

1. gemm_ar.supports() said yes where GemmAllReduceOp raises

supports() is documented to answer exactly what construction would, but it never ran the constructor's option checks. It answered True, while the constructor raises ValueError, for:

The constructor's option checks move, unchanged in order and message, into _option_constraint, which both now call. test_supports_accepts_the_legal_tile_multiples asserted that 256x512 is supported; it predates the permlane rule. It now uses 256x256, and 512 joins the block_n values supports() must refuse.

2. GemmAgOp let a bf16 BLOCK_M of 384 through to the first call

The docstring says an illegal pinned tile "is rejected here". For bf16 the layout check catches most bad tiles, but it only asks for a BLOCK_M that is a multiple of 128, and the bf16 GEMM takes 128 or 256. So tile=(384, 256) constructed, allocated its window, and failed when the first call compiled the GEMM.

_tile_constraint now checks a pinned tile against the fp8 rule as before and, for bf16, against tile_constants, the rule the compile path applies. Only a BLOCK_M that is a multiple of 128 above 256 is newly refused. The other bad bf16 tiles are refused as before, but with the GEMM's message (BLOCK_M must be 128 or 256, got 64) instead of the layout's (block_m=64 must be a positive multiple of 128). fp8 is unchanged.

3 and 4. Documentation

  • bench_ag_gemm.py: the usage example passed -n 6400; the flag is -N / --out-dim.
  • a2a_gemm/README.md: the op's fused times were said to be within 1.3% of the best fused cells, but at m_local 2048 the gap is 1.6%. The README now gives all three: +1.6%, +1.3%, -1.0%.

Testing

GPU, on an 8x MI355X node in the ci-cco image (FlyDSL 0.4.0, mori built from this branch with the CI flags). These are the fused job's steps, limited to the three test files that construct these ops or call supports():

Step (as in ci_cco.yml) Files Result
Single-GPU kernel tests (-n 8) test_gemm_ar_op.py, test_gemm_ar_schedule.py, test_gemm_ag_op.py 40 passed
2- and 4-rank tests (-n 2) test_gemm_ar_op.py, test_gemm_ar_schedule.py 3 passed
GEMM+AR numerics, up to 8 ranks test_gemm_ar_op.py, test_gemm_ar_schedule.py 76 passed, 1 skipped (ci_full; run separately with MORI_CI_FULL=1, it passes)
GEMM+AG op tests, up to 8 ranks test_gemm_ag_op.py 56 passed

The worker's operand_checks case now also constructs a bf16 op with tile=(384, 256) and expects ValueError; it passes.

CPU, run locally with flydsl and the compiled mori modules replaced by stubs:

  • The CPU cases of both test files pass (82). Against main's op.py, the two new supports() cases fail.
  • GemmAllReduceOp constructor, main vs this branch, 3,780 option combinations: the same accept-or-raise result, and the same message, for every one.
  • supports() vs the constructor, 11,340 combinations at 2, 4 and 8 ranks: 0 disagreements (main: 300, every one "supports() says yes, the constructor raises").
  • GemmAgOp pinned tiles, 210 combinations: fp8 outcomes unchanged. bf16: nothing newly accepted; 9 newly refused, all with BLOCK_M 384, 512 or 640.

🤖 Generated with Claude Code

Xiang.Chen and others added 3 commits November 10, 2026 14:01
supports() is meant to answer exactly what construction would ("a
predicate that says yes where construction raises ... is worse than no
predicate"), but it did not run the constructor's option checks. It
answered True, where GemmAllReduceOp raises ValueError, for:

- a block_n that is a multiple of 256 other than 256 (512, ...).
  _tile_constraints allows it, but the permlane epilogue pairs exactly two
  N tiles (permlane_tile_constraint). #690 applied that rule to the
  constructor and to supports_gemm, not to supports().
- quant="bf16" with an fp8 scatter wire.

Move the constructor's option checks into _option_constraint, unchanged in
order and message, and call it from both. Unknown wire dtypes and
transports were already refused by supports(), through the schedule it
builds; they are now refused one check earlier, with the same answer.

test_supports_accepts_the_legal_tile_multiples asserted that 256x512 is
supported. It predates the permlane rule; it now checks 256x256, and 512
joins the block_n values supports() must refuse.

Co-Authored-By: Claude <[email protected]>
…tion

GemmAgOp's docstring says an illegal pinned tile "is rejected here". The
layout check catches most bad bf16 tiles, but it asks only for a BLOCK_M
that is a multiple of 128, while the bf16 GEMM takes 128 or 256. A tile
such as (384, 256) constructed, allocated its window, and failed when the
first call compiled the GEMM (tile_constants, from compile_bf16_gemm_ag).

Check the pinned tile in _tile_constraint: the fp8 rule as before, and for
bf16 the rule the compile path applies, tile_constants. Only a BLOCK_M
that is a multiple of 128 above 256 is newly refused. A bad bf16 tile the
layout already refused is still refused, now with the GEMM's message
("BLOCK_M must be 128 or 256, got 64") rather than the layout's
("block_m=64 must be a positive multiple of 128"). fp8 is unchanged.

Co-Authored-By: Claude <[email protected]>
- bench_ag_gemm.py: its usage line passed `-n 6400`; the parser only takes
  `-N` / `--out-dim`, so the command failed as written.
- a2a_gemm README: the operator's fused times (136.6 / 262.0 / 430.9 us) were
  said to be within 1.3% of the best fused cells (134.4 / 258.6 / 435.2);
  they are +1.6%, +1.3% and -1.0%. Give the three numbers.

Co-Authored-By: Claude <[email protected]>
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

GPU CI for 49161f00 (run): changed areas: fused

lane runs jobs
mori no MI355X intranode, MI355X ROCm 7.14, MI355X JAX, MI355X internode
mi300x no MI300X intranode, MI300X internode
umbp no UMBP unit test
cco no CCO unit test, CCO EPv2 single-node test, CCO internode
fused yes CCO fused GEMM test
build no MoRI build (compile check)

Test groups (the steps that run in those jobs): fused.

Lanes follow the changed files. Adding ci:full re-runs CI with every lane, the full internode sweeps and every fused GEMM case; adding ci:mi300x re-runs it with the MI300X lanes added. /ci-rerun re-runs CI against the current main.

xiangch and others added 2 commits November 17, 2026 02:19
Only mxfp8 has exactly one legal BLOCK_M, and bf16 a short list
(BF16_BLOCK_MS). blockscale and ptpc take any legal tile. The comment
moved into _option_constraint said every quantisation has one, and
pointed at _quant_block_m, which does not exist. The constructor's
comment on the default said the same; it now points at
_default_block_m.

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

@jhchouuu jhchouuu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Checked each change against the code. All four are right:

  • gemm_ar:
    • _option_constraint is the constructor's checks moved over unchanged, in the same order and with the same messages.
    • supports() checks quant in QUANTS before calling it, and GemmReduceScatterOp gets it through super().__init__.
    • The old 256x512 test predates the permlane rule.
  • gemm_ag:
    • The fp8 rule is equivalent to the old condition.
    • bf16 now goes through tile_constants, the same pure check the compile path applies.
    • in_dtype/out_dtype are the same values as self.* there.
  • Docs:
    • bench_ag_gemm.py does take -N/--out-dim.
    • From the table, the README's percentages recompute to +1.64%, +1.31% and -0.99%.

gemm_a2a, ag_gemm and a2a_gemm take no pinned tile, so they don't have the same gap. Two nits inline, neither blocking.

Comment thread python/mori/ops/gemm_ar/op.py Outdated
Comment on lines +316 to +318
One copy for the constructor and ``supports``: the predicate used to skip
the permlane epilogue's block_n rule and the bf16 quantisation's wire
rule, and answered True where construction raised. ``quant`` must already

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: this explains how supports used to disagree with the constructor. That history belongs in the PR or commit. The docstring could just say what the function is, e.g. "The constructor's option checks, shared with supports so the two cannot disagree."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 49161f0. The docstring now says what the function is, in your wording; the history stays in the PR description.

f"gather_transport={gather_transport!r} is not one of "
f"{sorted(GATHER_TRANSPORTS)}"
)
why = permlane_tile_constraint(block_n)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: with this rule in place, the "multiple of TILE_N_GRANULE" that _tile_constraints allows for block_n only ever admits 256 here, so 512 and above are dead. Tightening it there, or noting it next to the permlane rule, would save the next reader from tripping on it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Went with the note, in 49161f0: a comment above the permlane check says it pins block_n to 256, so the wider multiples _tile_constraints admits never get past it. I left _tile_constraints alone because it describes the mainloop, which does build the wider tiles; tightening it would mix the store's limit into the mainloop's rule.

From review. The _option_constraint docstring now says what the function
is; how supports() used to disagree with the constructor belongs to the
PR, not the code.

The permlane check gets a comment: it pins block_n to 256, so the wider
multiples of TILE_N_GRANULE that _tile_constraints admits never get past
it here. They stay in _tile_constraints, which describes the mainloop,
and the mainloop does build them.

Co-Authored-By: Claude <[email protected]>
@yangyuhuiling
yangyuhuiling merged commit a45db69 into main Nov 17, 2026
20 checks passed
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.

2 participants