01 · Kernel language to kernel language
Port complete · tuning ongoing
A mixture-of-experts kernel, from CuTe DSL to Pallas Mosaic GPU
FlashInfer MegaMoE·CuTe DSL→Pallas Mosaic GPU·Blackwell B200
- Reference
- The masked mixture-of-experts path in FlashInfer, written in NVIDIA's CuTe DSL.
- Target
- Pallas Mosaic GPU, JAX's own kernel layer for NVIDIA GPUs, so the kernel can live inside a JAX stack.
- Number format
- NVFP4 kept end to end: 4-bit values with shared block scales, consumed natively by Blackwell's tensor cores.
- Correctness
- The grouped matrix multiply is bit-exact against a float64 oracle. The full path agrees with the reference to bfloat16 precision.
- Speed
- Faster than the dense bfloat16 baseline the same computation would otherwise use.
- Figures
- to be published with reproductions
What was done
- Four kernels rebuilt, plus a model of the numerics that every test is checked against.
- Three of the reference's four stages fused into one kernel, removing a large intermediate tensor. This was one of the biggest end-to-end gains.
- Six structural variants taken from the reference's own design were each implemented, verified bit-exact and measured.
- The reference's launch configuration was reconstructed from its capture and executed, not inferred from its source.
What we found
- Fusion pays end to end. The intermediate tensor between stages never shows up when kernels are timed one at a time.
- The launch record matters. How the reference is scheduled across the processor is not visible in its instruction listing; capturing a real launch revealed it.
- Producing the scales is half the work. A block-scaled format needs its scale factors computed and laid out the way the hardware expects, and that shapes the whole kernel.
- The manual search and the automated loop agreed. Both arrived at the same operating point, the loop in a handful of steps.
Why it matters. A kernel that exists in one kernel language is out of reach for a stack built on another. This one now runs inside JAX with its number format and its numerics intact.