Repository navigation
Enable INT8-activation prefill MoE experts for Inkling-2-Mini MLX - #855
Draft
oniisanlabs wants to merge 1 commit into
Draft
oniisanlabs wants to merge 1 commit into
oniisanlabs wants to merge 1 commit into
Conversation
Compile the int8 MoE expert prefill passes for Inkling-2-Mini's routing
(0 shared slices, SoftcappedSwiglu<4, 25>) in af4g64 and af5g64 so
resident MLX 4-bit/5-bit Inkling-2-Mini checkpoints use Apple10/11 int8
MoE prefill like every other MoE family:
- runtime/metal/kernels/common/gguf_tile.h: add EpUpWithGateSoftcap4_25
epilogue using SoftcappedSwiglu<4, 25>.
- runtime/metal/kernels/shared/moe_int8.metal: instantiate _s0 and
_softcap4_25 kernels for af4g64 and af5g64.
- runtime/ops/MoE.cpp: in addInt8Experts, bind slotTable in unused
shared-plane slots when sharedSlices == 0 and append activationSuffix
on the up pass.
- runtime/ops/KernelSelection.cpp: allow all kCompiledMoeRoutings in
moeInt8Experts and skip the shared-segment check when sharedSlices == 0.
- Enable int8 MoE tests for Inkling-2-Mini's routing in gguf_moe_test.mm
and kernel_selection_test.cc, update the 14 Apple10/11 Inkling-2-Mini
entries in kernel_selection_golden.txt, and add inkling2 support to
gguf_moe_benchmark.mm.
Measured on 20-core Apple M5 Pro (macOS 26.6.2):
- gguf-moe-benchmark int8 inkling2 (15 rounds ABAB):
- af4g64: -12.3% at 512 rows, -19.6% (1.24x vs M64) at 1024 rows,
-25.5% (1.34x vs M64, 12.27 -> 9.15 ms/layer) at 2048 rows.
- af5g64: -16.2% (1.19x vs M64) at 1024 rows, -20.1% (1.25x vs M64)
at 2048 rows.
- Full-shape synthetic 48-app Inkling-2-Mini af4g64 prefill (4 ABBA pairs):
- 256 rows: -7.5% (1.08x), 512: -15.8% (1.19x), 1024: -18.3% (1.22x),
2048: -18.6% (1.23x, 1165.8 -> 948.5 ms).
Contributor
Author
|
Converting to draft after testing against a real downloaded
I'll explore extending INT8 MoE prefill to NVFP4 (plus per-block selection so layers 0–19 run INT8 while MXFP8 layers 20–23 stay on staged BF16), which would accelerate real |
oniisanlabs
marked this pull request as draft
November 26, 2026 08:50
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
Enable the existing INT8-activation MoE prefill passes (
moe_int8.metal) for Inkling-2-Mini's routing (sharedSlices == 0,SoftcappedSwiglu<4, 25>) on MLXaf4g64andaf5g64checkpoints on Apple10/Apple11 GPUs, bringing Inkling-2-Mini in line with every other MoE family in Splash (Qwen3.6-35B-A3B, Qwen3.5-122B, Qwen3.8-Flash-Next, and Flint).What changed (+43 / -26 production lines across 4 files)
runtime/metal/kernels/common/gguf_tile.h: addedEpUpWithGateSoftcap4_25epilogue reusingSoftcappedSwiglu<4, 25>(roundinguptobfloatbefore activation, matchingmoe_gguf.metal).runtime/metal/kernels/shared/moe_int8.metal: instantiatedShared = 0(_s0) +EpUpWithGateSoftcap4_25(_softcap4_25) kernels foraf4g64andaf5g64.runtime/ops/MoE.cpp: inaddInt8Experts, boundweights.slotTablein the unused shared-plane slots whenshape.sharedSlices == 0(matchingaddExperts) and appendedrouting.activationSuffixto the"up"pass name.runtime/ops/KernelSelection.cpp: generalizedmoeInt8Expertsto allkCompiledMoeRoutingsand skipped the shared-segment format check whenrouting->sharedSlices == 0.activationSuffixskip ingguf_moe_test.mmsogguf-moe-biasedexercisesaf4g64andaf5g64INT8 passes against the FP64 reference and bitwise across chunk sizes (263/33/16/1).int8ExpertRoutingsinkernel_selection_test.ccand the 14 Apple10/11Inkling-2-Minimoe-prefill/moe-workspacehashes inkernel_selection_golden.txt.inkling2shape todev/benchmarks/gguf_moe_benchmark.mmand fixedint8mode overridingM64back toM32when forcingint8Passes = true.GPU Benchmarks (20-core Apple M5 Pro, macOS 26.6.2, hardware
gpuSeconds)1. Per-layer MoE (
gguf-moe-benchmark int8 inkling2, 15 rounds ABAB)Even against the 64-row BF16 staged tile (
M64) at 1,024 and 2,048 rows:af4g64af4g64af4g64af4g64af4g64af4g64af4g64af4g64af4g64af4g64af5g64af5g64af5g64af5g642. Full-shape 48-application Inkling-2-Mini MLX (
af4g64, 4 ABBA pairs)mainmedprefill-256prefill-512prefill-1024prefill-2048decode-b1-1decode-b1-8Trade-offs & Scope
PrefillArena(381.35 → 428.92 MiB) for resident MLX 4-bit/5-bit Inkling-2-Mini on Apple10/11 (same as Qwen3.6-35B-A3B's +45 MiB in Splash 1.7.1). Zero memory change for GGUF, Apple9, streamed experts, or decode.--activations bf16preserves exact BF16). Decode and chunks < 96 rows remain unchanged. Ingguf-moe-biased, worst relative error vs FP64 is1.7e-3(gate/up) and8.2e-3(down) foraf4g64, and1.8e-3/7.1e-3foraf5g64, with 50/50 rows bitwise identical across263/33/16/1-row chunks.Testing
python3 dev/tools/check_architecture.py— PASSmake test-engine-cpu— PASS (includingkernel-selectionover all 5,145 groups andmodel-execution-plans)kernel-selection --library build/splash.metallib— PASS (all 1,624 pipelines across 5,653,188 plans present inbuild/splash.metallib)MTL_SHADER_VALIDATION=1Metal suites:gguf-moe-biased— PASS (exercises newaf4g64andaf5g64_s0+_softcap4_25INT8 passes)gguf-moe— PASSgguf-moe-sigmoid— PASSinkling2-target(shader-validated +bitwise) — PASSOpen in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.