Skip to content

fix(mxfp8_moe): zero empty-expert weight gradients, accept non-contiguous gradients, smoke-test the kernel - #21

Draft
garrett361 wants to merge 4 commits into
mainfrom
feat/mxfp8-moe-sm103
Draft

garrett361 wants to merge 4 commits into
mainfrom
feat/mxfp8-moe-sm103

Conversation

@garrett361

Copy link
Copy Markdown

No description provided.

garrett361 and others added 4 commits October 19, 2026 15:36
`torch._scaled_grouped_mm` leaves an empty group's output unwritten, so with
the default MXFP8 weight-gradient recipe an expert that received no tokens
got uninitialized memory (NaN or ~1e38) as its gradient. The high-precision
path through `torch._grouped_mm` already zero-fills. prime-rl's dispatchers
pad empty experts to one alignment block, so it never hit this, but the
public `grouped_gemm` did.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
torchao's MXFP8 casts require contiguous input, so a reduction's expanded,
stride-0 gradient (for example from `out.sum().backward()`) failed with
"`x` must be contiguous".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A release wheel without a usable mxfp8_moe now fails CI instead of
shipping; prime-rl's MXFP8 expert compute loads it. The check covers a
non-power-of-two group count and an empty expert.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nment

The weight gradient's 32-row scale blocks assume aligned group boundaries;
an unaligned group would straddle two groups' blocks and silently get wrong
scales. Not checked at runtime, since a check would add a host sync to every
call.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@garrett361
garrett361 force-pushed the feat/mxfp8-moe-sm103 branch from ec73ec1 to 2018c76 Compare October 19, 2026 19:09
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