MoE: Add fused additive EXL3 kernels - #284
Open
malaiwah wants to merge 1 commit into
Open
Conversation
malaiwah
force-pushed
the
feat/exl3-additive-msrt
branch
from
August 13, 2026 12:55
5a3d325 to
639ef53
Compare
Add graph-capturable stable route packing and additive MCG residual stages for expert gate, up, and down projections. Tile oversized route spans within the fixed workspace, validate raw tensor contracts before device work, and skip zero-scale sparse stages. Add focused CUDA regressions for route packing, overflow tiling, sparse stages, and legacy fallback behavior. The route histogram, scan, and stable-pack pipeline is adapted from draft PR turboderp-org#246 (704aefd). Co-authored-by: Brandon M. Music <brandon.m.music@gmail.com>
malaiwah
force-pushed
the
feat/exl3-additive-msrt
branch
from
August 13, 2026 13:59
639ef53 to
619c1b1
Compare
|
Thank you for the attribution |
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.
Summary
Add a graph-capturable additive EXL3 MoE path for compressed residual ("cartridge") stages.
exl3_gemm_innerwith FP32 accumulation and output scalingexl3_moe_additivefor callers that already have route metadataexl3_moe_additive_fusedfor stable route packing plus base/residual execution in one extension callEXL3_MOE_ADDITIVE_ABI_VERSION = 1for exact consumer compatibility checksexl3_moeABI and legacy overflow fallback behaviorAPI contract
Consumers must require an exact supported
EXL3_MOE_ADDITIVE_ABI_VERSION; symbol presence or callable arity is not a compatibility contract. The version is bumped for incompatible signature, pointer-layout, routing-workspace, residual-encoding, or overflow-semantics changes.Additive residual trellises use the MCG codebook and reuse each base projection's
suh/svhrotations. Their K metadata must be validated by the caller before graph capture. A zero scale skips that projection's GEMM.The
int64pointer tables do not retain their pointees. Callers must keep all referenced trellis and rotation allocations alive, unmoved, and on the same device through asynchronous completion and for the lifetime of a captured graph.For additive calls,
num_activeis only a launch-size hint and counts every nonempty expert. Oversized experts are processed in workspace-sized tiles, sorows * topkscratch is not required.Relationship to #246
The fused route histogram, scan, and stable-packing pipeline is adapted from @brandonmmusic-max's draft #246 (commit
704aefd) and rebased onto the current ticket-scheduled MoE kernel. This PR does not include #246's SM120 retile; it adds additive residual stages. Brandon is credited in the squashed commit.Companion work
This PR is intentionally limited to the extension compute/API layer; it does not define the on-disk cartridge manifest. Consumers remain responsible for validating artifact version, extension ABI, codebook, K values, coverage, and pointer lifetime before invoking the extension.
Validation
Direct extension validation on NVIDIA L4 (SM89), CUDA 12.6, and PyTorch 2.6:
setup.py build_ext --inplacecompleted successfullypython -m pytest -q tests/test_exl3_moe_additive.py: 14 passedcapacity + 1and multi-tile overflow; the downstreamtopk=2,capacity=rowscase; zero-scale/null sparse stages; and preserved legacy overflow behaviorThe ABI-version follow-up is a header/binding/test-only change.
git diff --checkand Python syntax validation pass; the CUDA behavior is unchanged from the L4-tested commit.Earlier downstream prototype validation on RTX 5090 (SM120), CUDA 12.8, and PyTorch 2.8 reported successful CUDA-graph capture and base -> cartridge -> base transitions. Restored base logprobs matched exactly (
max_abs=0.0); packed-vs-dense cartridge output had mean KL1.30506e-4, max absolute logit delta0.11122, mean absolute logit delta0.00910, and identical argmax on sampled prompts.AI assistance was used. I reviewed the source changes and validation results.