Repository navigation
fix(fused-ops): make supports() and the tile check match construction; fix two doc errors - #979
Conversation
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]>
|
GPU CI for
Test groups (the steps that run in those jobs): fused. Lanes follow the changed files. Adding |
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
left a comment
There was a problem hiding this comment.
Checked each change against the code. All four are right:
- gemm_ar:
_option_constraintis the constructor's checks moved over unchanged, in the same order and with the same messages.supports()checksquant in QUANTSbefore calling it, andGemmReduceScatterOpgets it throughsuper().__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_dtypeare the same values asself.*there.
- Docs:
bench_ag_gemm.pydoes 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.
| 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 |
There was a problem hiding this comment.
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."
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
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 whereGemmAllReduceOpraisessupports()is documented to answer exactly what construction would, but it never ran the constructor's option checks. It answeredTrue, while the constructor raisesValueError, for:block_nthat is a multiple of 256 other than 256 (512, ...)._tile_constraintsallows it, but the permlane epilogue pairs exactly two N tiles (permlane_tile_constraint). feat(cco): gemm_ar MXFP8 support, and the GEMM usable without a collective #690 added that rule to the constructor and tosupports_gemm, but not tosupports().quant="bf16"with an fp8 scatter wire.The constructor's option checks move, unchanged in order and message, into
_option_constraint, which both now call.test_supports_accepts_the_legal_tile_multiplesasserted that 256x512 is supported; it predates the permlane rule. It now uses 256x256, and 512 joins theblock_nvaluessupports()must refuse.2.
GemmAgOplet a bf16 BLOCK_M of 384 through to the first callThe 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. Sotile=(384, 256)constructed, allocated its window, and failed when the first call compiled the GEMM._tile_constraintnow checks a pinned tile against the fp8 rule as before and, for bf16, againsttile_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 atm_local2048 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-ccoimage (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 callsupports():ci_cco.yml)-n 8)test_gemm_ar_op.py,test_gemm_ar_schedule.py,test_gemm_ag_op.py-n 2)test_gemm_ar_op.py,test_gemm_ar_schedule.pytest_gemm_ar_op.py,test_gemm_ar_schedule.pyci_full; run separately withMORI_CI_FULL=1, it passes)test_gemm_ag_op.pyThe worker's
operand_checkscase now also constructs a bf16 op withtile=(384, 256)and expectsValueError; it passes.CPU, run locally with
flydsland the compiledmorimodules replaced by stubs:op.py, the two newsupports()cases fail.GemmAllReduceOpconstructor, 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").GemmAgOppinned 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