Repository navigation
Add scaled_grouped_mm FP8 kernels and FP8 weight cache - #710
Merged
Merged
Conversation
AkshitaB
force-pushed
the
akshitab/moe-mxfp8
branch
from
June 6, 2026 00:44
1df30b8 to
d31a2c2
Compare
AkshitaB
force-pushed
the
akshitab/moe-scaled-grouped-mm
branch
from
June 6, 2026 00:44
82a741c to
a175224
Compare
AkshitaB
force-pushed
the
akshitab/moe-mxfp8
branch
from
June 9, 2026 01:05
d31a2c2 to
04edb37
Compare
AkshitaB
force-pushed
the
akshitab/moe-scaled-grouped-mm
branch
4 times, most recently
from
June 9, 2026 05:29
a55fdcc to
b241adc
Compare
scaled_grouped_mm_q / scaled_grouped_mm_q_fp8_weight: MXFP8-quantized grouped matmul
built on torch.nn.functional.scaled_grouped_mm, with prequantized-weight caching
(prequantize_scaled_grouped_mm_rhs, ScaledGroupedMMPrequantized{LHS,RHS}) to reuse a
quantized operand across calls. Includes cuda/scaled_grouped_mm_out.cpp; the CUDA
extension builds lazily and the nvtx import is guarded, so the module imports on CPU.
Exported from olmo_core.kernels.
Co-Authored-By: Akshita Bhagia <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
FP8WeightStore / FP8WeightCacheSpec: a small store that prequantizes a weight to its MXFP8 RHS form (and the transpose used by the dgrad) and caches it, so the quantized operand is computed once and reused across forward/backward calls into scaled_grouped_mm. Pure Python on top of olmo_core.kernels; import-safe on CPU. Co-Authored-By: Akshita Bhagia <[email protected]> Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…tures Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… 2.10) MXFP8 row quant/dequant, the scaled_grouped_mm_q / *_fp8_weight autograd paths (parity vs grouped_mm, wgrad-sink accumulation, prequantized LHS/RHS reuse, input_grad_out aliasing, empty-input grads, column-major layout), and the OlmoMXFP8Tensor -> ScaledGroupedMMPrequantizedLHS bridge. The autograd-plumbing cases stub the CUDA forward so they run on CPU; quant/layout cases are CUDA-gated. The file is skipped wholesale on torch < 2.10 (has_torch_grouped_mm). Co-Authored-By: Akshita Bhagia <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
AkshitaB
force-pushed
the
akshitab/moe-scaled-grouped-mm
branch
from
June 9, 2026 05:45
b241adc to
8a28d7f
Compare
AkshitaB
marked this pull request as ready for review
June 9, 2026 06:00
- Use builtin tuple generics for the prequantized dataclass fields and drop the now-unused typing.Tuple import. - Add docstrings to the public ScaledGroupedMMPrequantizedLHS/RHS dataclasses. - Replace the broad `except Exception` in _tensor_version with a getattr default so only a missing `_version` is handled, not unrelated errors. - Replace the `if not torch.cuda.is_available(): return` guards (which silently reported pass and lacked the gpu marker) with @requires_gpu. The three tests that exercise the real e4m3 quantize also get @requires_compute_capability(min_cc=9) (needs sm89+); the two that fake the FP8 ops only need a GPU. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
The FP8 grouped-matmul compute path, built on MXFP8:
scaled_grouped_mm_q/scaled_grouped_mm_q_fp8_weight(olmo_core.kernels.scaled_grouped_mm) — MXFP8-quantized grouped matmul ontorch.nn.functional.scaled_grouped_mm, with prequantized-weight caching (prequantize_scaled_grouped_mm_rhs,ScaledGroupedMMPrequantized{LHS,RHS}).FP8WeightStore/FP8WeightCacheSpec(olmo_core.nn.fp8_weight) — prequantizes a weight to its MXFP8 RHS form (and the dgrad transpose) and caches it.All public entry points are marked
@beta_feature.torch version
This path uses
torch.nn.functional.grouped_mm(backward) andF.ScalingType/F.SwizzleType— torch 2.10 APIs. The module imports safely on older torch (the enum constants fall back viatry/except), and the tests are version-gated (has_torch_grouped_mm) so they skip on torch < 2.10 rather than erroring; CI exercises them on a torch 2.10 GPU image. The autograd-plumbing tests stub the CUDA forward and run on CPU.