Skip to content

Add scaled_grouped_mm FP8 kernels and FP8 weight cache - #710

Merged
AkshitaB merged 5 commits into
akshitab/moe-v2-corefrom
akshitab/moe-scaled-grouped-mm
Jun 9, 2026
Merged

AkshitaB merged 5 commits into
akshitab/moe-v2-corefrom
akshitab/moe-scaled-grouped-mm

Conversation

@AkshitaB

@AkshitaB AkshitaB commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

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 on torch.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) and F.ScalingType/F.SwizzleType — torch 2.10 APIs. The module imports safely on older torch (the enum constants fall back via try/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.

@AkshitaB
AkshitaB force-pushed the akshitab/moe-mxfp8 branch from 1df30b8 to d31a2c2 Compare June 6, 2026 00:44
@AkshitaB
AkshitaB force-pushed the akshitab/moe-scaled-grouped-mm branch from 82a741c to a175224 Compare June 6, 2026 00:44
@AkshitaB
AkshitaB force-pushed the akshitab/moe-mxfp8 branch from d31a2c2 to 04edb37 Compare June 9, 2026 01:05
@AkshitaB
AkshitaB force-pushed the akshitab/moe-scaled-grouped-mm branch 4 times, most recently from a55fdcc to b241adc Compare June 9, 2026 05:29
Base automatically changed from akshitab/moe-mxfp8 to akshitab/moe-v2-core June 9, 2026 05:43
TianhuaTao and others added 4 commits June 8, 2026 22:44
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]>
… 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
AkshitaB force-pushed the akshitab/moe-scaled-grouped-mm branch from b241adc to 8a28d7f Compare June 9, 2026 05:45
@AkshitaB
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]>
@AkshitaB
AkshitaB merged commit 7622e40 into akshitab/moe-v2-core Jun 9, 2026
46 of 47 checks passed
@AkshitaB
AkshitaB deleted the akshitab/moe-scaled-grouped-mm branch June 9, 2026 06:37
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