Improvements over upstream https://huggingface.co/kernels-community/sonic-moe :

  • Updated to latest sonicmoe
  • Updated vendored quack to 0.6.1
  • Fixed backward pass for EP sentinel
  • Breaking changes: requires "nvidia-cutlass-dsl==4.6.0" "apache-tvm-ffi>=0.1.10,<0.2"

SonicMoE

Accelerating Mixture-of-Experts with IO and Tile-aware Optimizations.

SonicMoE is a blazing-fast MoE implementation optimized for NVIDIA Hopper and Blackwell GPUs. It leverages CuTe-DSL and Triton to deliver state-of-the-art performance through IO-aware optimizations.

Requirements

  • NVIDIA Hopper GPUs (H100, H200) or Blackwell GPUs (GB200, B200, B300)
  • PyTorch >= 2.7
  • CUDA 12.9+ (13.0+ for B300)
  • Python 3.12+

Usage

import torch
from kernels import get_kernel

sonicmoe = get_kernel("axolotl-ai-co/sonic-moe")

from sonicmoe import MoE, KernelBackendMoE
from sonicmoe.enums import ActivationType

moe = MoE(
    num_experts=128,
    num_experts_per_tok=8,
    hidden_size=4096,
    intermediate_size=1536,
    activation_function=ActivationType.SWIGLU,
    add_bias=False,
    std=0.02,
).to(device="cuda", dtype=torch.bfloat16)

x = torch.randn(32768, 4096, device="cuda", dtype=torch.bfloat16)
output, aux_loss = moe(x, kernel_backend_moe=KernelBackendMoE.sonicmoe)

Router variants

Since sonic-moe#39 the functional API exposes both softmax(topk(logits)) (TC default) and topk(softmax(logits)) (Qwen3 style) routing, plus optional top-k probability renormalization:

from sonicmoe import moe_TC_softmax_topk_layer

# Qwen3-style: topk(softmax()) with renormalized probabilities
out, router_logits, expert_freq = moe_TC_softmax_topk_layer(
    x, moe.router.weight,
    moe.c_fc.weight.permute(1, 2, 0), moe.c_fc.bias,
    moe.c_proj.weight.permute(1, 2, 0), moe.c_proj.bias,
    K=8,
    stream_id=torch.cuda.current_stream().cuda_stream,
    is_softmax_over_topk=False,
    norm_topk_probs=True,
)

Weight layout

By default, w1 (gated up-projection) is expected in interleaved layout [gate_0, up_0, gate_1, up_1, ...]. HuggingFace checkpoints (Qwen3, Mixtral, DeepSeek, ...) store gate_up_proj in concatenated layout [gate_0, ..., gate_{I-1}, up_0, ..., up_{I-1}]. Pass concat_layout=True to moe_TC_softmax_topk_layer / moe_general_routing_inputs to consume the concatenated layout directly without a pre-pass permutation.

Vendored Dependencies

This kernel vendors QuACK v0.6.1 for CuTe-DSL grouped GEMM infrastructure (Hopper + Blackwell). The vendored copy is under torch-ext/sonic_moe/quack/. Torch operators are registered through add_op_namespace_prefix, which the build system prefixes with a kernel-unique namespace, so they cannot collide with a user-installed quack-kernels.

License

Apache-2.0 (SonicMoE and QuACK are both Apache-2.0 licensed)

Downloads last month
-
Mixture of Experts
cuda
arxiv: 2512.14080
Supported hardwares new
CUDA
all
GPU
B300
288GB
NVIDIA SXM
B200
192GB
NVIDIA SXM
H200
141GB
NVIDIA SXM
H100
80GB
GPU
H800
80GB
GPU
H20
96GB
GPU
L40s
48GB
GPU
L40
48GB
GPU
L20
48GB
GPU
L4
24GB
DGX Spark
GB10
128GB
GPU
RTX PRO 6000 WS
96GB
GPU
RTX PRO 6000 Max-Q
96GB
GPU
RTX PRO 5000
48GB
GPU
RTX PRO 4500 WS
32GB
GPU
RTX PRO 4000
24GB
GPU
RTX PRO 4000 SFF
24GB
GPU
RTX PRO 2000
16GB
GPU
RTX 6000 Ada
48GB
GPU
RTX 5880 Ada
48GB
RTX
RTX 5000 Ada
32GB
GPU
RTX 4500 Ada
24GB
RTX
RTX 4000 Ada
20GB
RTX
RTX 4000 SFF Ada
20GB
GPU
RTX 3500 Ada Mobile
12GB
GPU
RTX 2000 Ada
16GB
GPU
RTX A6000
48GB
GPU
RTX A5000
8GB
GPU
RTX A5000 Max-Q
16GB
GPU
RTX A5000 Mobile
16GB
GPU
RTX A4000
16GB
GPU
RTX A4000 Max-Q
8GB
GPU
RTX A4000 Mobile
8GB
GPU
RTX A3000 Mobile
6GB
GPU
RTX A2000
6GB
GPU
RTX A2000 Embedded
4GB
GPU
RTX A2000 Max-Q
4GB
GPU
RTX A2000 Mobile
4GB
GPU
A800
40GB
GPU
A100
80GB
GPU
A40
48GB
GPU
A30
24GB
GPU
A10
24GB
GPU
A2
16GB
RTX
RTX 5090
32GB
RTX
RTX 5090 D
32GB
RTX
RTX 5090 Mobile
24GB
RTX
RTX 5080
16GB
RTX
RTX 5080 Mobile
16GB
RTX
RTX 5070
12GB
RTX
RTX 5070 Mobile
8GB
RTX
RTX 5070 Ti
16GB
RTX
RTX 5070 Ti Mobile
12GB
RTX
RTX 5060 Ti
16GB
RTX
RTX 5060
8GB
RTX
RTX 5060 Mobile
8GB
RTX
RTX 5050
8GB
RTX
RTX 5050 Mobile
8GB
RTX
RTX 4090
24GB
RTX
RTX 4090D
24GB
RTX
RTX 4090 Mobile
16GB
RTX
RTX 4080 SUPER
16GB
RTX
RTX 4080
16GB
RTX
RTX 4080 Mobile
12GB
RTX
RTX 4070
12GB
RTX
RTX 4070 Mobile
8GB
RTX
RTX 4070 Ti
12GB
RTX
RTX 4070 Super
12GB
RTX
RTX 4070 Ti Super
16GB
RTX
RTX 4060
8GB
RTX
RTX 4060 Ti
8GB
RTX
RTX 4090 Laptop
16GB
RTX
RTX 4080 Laptop
12GB
RTX
RTX 4070 Laptop
8GB
RTX
RTX 4060 Laptop
8GB
RTX
RTX 4050 Laptop
6GB
RTX
RTX 3090
24GB
RTX
RTX 3090 Ti
24GB
RTX
RTX 3080
12GB
RTX
RTX 3080 Ti
12GB
RTX
RTX 3080 Mobile
16GB
RTX
RTX 3070
8GB
RTX
RTX 3070 Ti
8GB
RTX
RTX 3070 Ti Mobile
8GB
RTX
RTX 3060 Ti
8GB
RTX
RTX 3060
12GB
GPU
RTX 2080 Ti
11GB
GPU
RTX 2080
8GB
GPU
RTX 2070
8GB
GPU
RTX 2070 SUPER Mobile
8GB
GPU
RTX 2070 SUPER
8GB
RTX
RTX 3060 Mobile
6GB
RTX
RTX 3050 Mobile
4GB
GPU
RTX 2060
6GB
GPU
RTX 2060 12GB
12GB
GPU
RTX 2060 Mobile
6GB
GPU
RTX 2050 Mobile
4GB
GPU
GTX 1080 Ti
11GB
GPU
GTX 1080
8GB
GPU
GTX 1070 Ti
8GB
GPU
GTX 1070
8GB
GPU
GTX 1060
3GB
GPU
GTX 1050 Ti
4GB
GPU
RTX Titan
24GB
GPU
GTX 1660
6GB
GPU
GTX 1650 Mobile
4GB
NVIDIA T4
T4
16GB
GPU
T10
16GB
GPU
V100
32GB
GPU
Quadro P6000
24GB
GPU
P40
24GB
GPU
P100
16GB
Jetson
Jetson AGX Orin 64GB
64GB
Jetson
Jetson AGX Orin 32GB
32GB
Jetson
Jetson Orin NX 16GB
16GB
Jetson
Jetson Orin NX 8GB
8GB
Jetson
Jetson Orin Nano 8GB
8GB
Jetson
Jetson Orin Nano 4GB
4GB
Jetson
Jetson AGX Xavier
32GB
Jetson
Jetson Xavier NX
8GB
Jetson
Jetson TX2
4GB
Jetson
Jetson Nano
4GB
Kernel Builder
81580bb