An Efficient Tile-agnostic GEMM for Mixture-of-Experts Training
The two B200 kernels are in src/gemm.py.
Mgemm(x, w, cnt, max_M_per_E, transpose_B)computes the grouped forward or input-gradient GEMM.xhas shape[M, K],whas shape[E, N, K], andcntis the cumulative row-offset tensor with a leading zero.Kgemm(grad, X, cnt, descriptor)computes the grouped FP32 weight gradient.gradandXcontain expert-grouped rows,cntstores cumulative expert row ends, anddescriptorisgw13orgw2.
The experiment uses the 30B-A3B MoE layout. The full model contains 20 Transformer layers; because the experiment runs on four GPUs, we execute the same model geometry with one and two layers and use their per-token time difference to estimate the incremental cost of model depth.
| Parameter | Value |
|---|---|
Model width (d_model) |
3,072 |
Dense FFN width (d_ffn) |
9,216 |
| Attention heads / KV heads | 24 / 4 |
| Head dimension | 128 |
| MoE experts | 128 |
Experts selected per token (top_k) |
8 |
Expert FFN width (moe_ffn_dim) |
1,280 |
| Shared-expert width | 1,280 |
| Full-model depth | 20 layers |
| Measured depths | 1 and 2 layers |
The runs use four NVIDIA B200 GPUs with the following model partition and training settings:
| Setting | Value |
|---|---|
| Expert parallelism | EP = 4; 128 experts are split evenly across four GPUs (32 per GPU) |
| Tensor parallelism | TP = 1; attention projections are not tensor-parallelized |
| Data parallelism | DP = 4 with ZeRO-1 for replicated attention and dense parameters over the same four ranks; expert-DP = 1 |
| Sequence length | 4,096 |
| Micro-batch size / update frequency | 1 / 4 |
| Effective steady-state tokens per update | 65,279 on average |
| Training steps | 100 |
| Learning rate | constant 2e-4, no warmup |
| Trainer precision | --precision fp32; MoE grouped GEMMs use BF16 (quant_mode=bfloat16) |
| Backends | RapidGEMM and DeepGEMM |
Each backend is run at one and two layers for 100 updates. We discard the first 20 warmup updates and summarize the steady-state near-peak envelope as the mean of the fastest eight updates (the top decile) from steps 21–100. All four runs have identical per-step token counts.
RapidGEMM is faster at both measured depths under the steady-state top-decile envelope, and its advantage increases with depth:
| Backend | 1-layer throughput | 2-layer throughput |
|---|---|---|
| RapidGEMM | 449.17k tokens/s | 345.69k tokens/s |
| DeepGEMM | 442.69k tokens/s | 336.71k tokens/s |
| RapidGEMM improvement | +1.46% | +2.67% |
To isolate the cost that scales with model depth, we convert throughput to per-token time before taking the layer difference:
Here,
| Backend | Incremental layer cost | Model-size rate | Estimated 20-layer throughput |
|---|---|---|---|
| RapidGEMM | 0.666 µs/token | 1.500M token-layers/s | 67.2k tokens/s |
| DeepGEMM | 0.711 µs/token | 1.406M token-layers/s | 63.4k tokens/s |
| RapidGEMM improvement | 6.27% lower | +6.68% | +5.90% |
The 20-layer estimate is
Across top-fraction choices from 5% through 25%, RapidGEMM's incremental model-size rate remains 4.6%–7.8% higher than DeepGEMM.