Repository navigation
Add grouped_mm kernel wrapper - #707
Merged
Merged
Conversation
AkshitaB
force-pushed
the
akshitab/moe-grouped-mm
branch
from
June 5, 2026 19:00
f4fd5e6 to
2598fd9
Compare
Base automatically changed from
akshitab/moe-cuda-extension-loader
to
akshitab/moe-v2-core
June 5, 2026 19:09
AkshitaB
force-pushed
the
akshitab/moe-grouped-mm
branch
from
June 5, 2026 19:10
0aaf4cd to
05f0824
Compare
AkshitaB
marked this pull request as ready for review
June 5, 2026 19:10
AkshitaB
force-pushed
the
akshitab/moe-grouped-mm
branch
3 times, most recently
from
June 5, 2026 22:58
a60a182 to
3a44467
Compare
grouped_mm wraps torch.nn.functional.grouped_mm and adds two caller-provided buffers: `out=` writes the forward result in place, and `input_grad_out=` writes the gradient of the first input during backward. These let callers reuse preallocated buffers and avoid extra allocations in hot loops. Includes cuda/grouped_mm_out.cpp for the in-place output path; the CUDA extension builds lazily via load_cuda_extension, so the module is import-safe on CPU. Co-Authored-By: Akshita Bhagia <[email protected]> Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…fwd + bwd) Add a GPU test that runs grouped_mm with no out=/input_grad_out= buffers and asserts both the forward output and the gradients match torch.nn.functional.grouped_mm, i.e. the custom autograd wrapper is a faithful drop-in in its default configuration. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add a has_torch_grouped_mm capability flag and a requires_torch_grouped_mm test decorator (gpu + skipif on torch.nn.functional.grouped_mm availability), mirroring the existing requires_grouped_gemm pattern. This is distinct from has_grouped_gemm, which checks for the third-party grouped_gemm package. Gate the grouped_mm wrapper tests with it so they skip cleanly on torch < 2.10 instead of erroring. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
AkshitaB
force-pushed
the
akshitab/moe-grouped-mm
branch
from
June 5, 2026 23:23
00ed3ee to
2110d9b
Compare
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
olmo_core.kernels.grouped_mm— a thin wrapper overtorch.nn.functional.grouped_mm(ragged/grouped matmul indexed by anoffstensor) that adds two caller-provided buffers:out=— write the forward result in place into a preallocated tensor and return it.input_grad_out=— writegrad(mat_a)into a preallocated buffer during backward.These let callers reuse preallocated forward/backward buffers and avoid extra allocations in hot loops. Ships
cuda/grouped_mm_out.cppfor the in-place output path, loaded lazily viaload_cuda_extension, and exportsgrouped_mmfromolmo_core.kernels.Import-safety / testing
Pure-Python wrapper; the CUDA extension builds lazily on first use, so the module is import-safe on CPU (no GPU or compiler needed to import). Correctness is covered by GPU tests on hardware.