## Introduction to SonicMoE
Norris: Welcome back to Mechanical Dreams, the podcast where we dive into the gears and wires of machine learning and natural language processing. I am Professor Norris, and across the desk from me is my ever-enthusiastic student, Linda. What do you have for us this week, Linda? Linda: Hi Professor! Today I brought a paper that is going to make anyone training large language models very, very happy. It is called SonicMoE: Accelerating MoE with IO and Tile-aware Optimizations. Norris: SonicMoE. Sounds fast. Who are the authors? Linda: It is by Wentao Guo, Mayank Mishra, Xinle Cheng, Ion Stoica, and Tri Dao, from Princeton, UC Berkeley, and Together AI. Norris: Ah, Tri Dao. So we are in for some serious hardware-level wizardry today. FlashAttention was not enough for him, now he is coming for our routers. Linda: Exactly! And this paper tackles one of the biggest architectural shifts we have seen recently in the field, which is the evolution of Mixture of Experts, or MoE models. For our listeners, MoEs are basically the de facto way to scale up an LLM's parameter count without exploding the computational cost during training. But the specific trend SonicMoE addresses is the rapid move towards fine-grained and highly sparse MoEs. Norris: Right. To give some context, a traditional MoE from a couple of years ago might have had something like 8 massive experts and routed tokens to just 2 of them. But looking at recent frontier models, like DeepSeek V3 or Qwen3, they use a much finer granularity. They might have 256 much smaller experts and route to 8 of them. Linda: Spot on. The MoE scaling laws clearly predict that you get better model quality per FLOP by doing exactly that. You increase expert granularity, meaning a smaller intermediate hidden size per expert, and you increase sparsity, which means having a huge pool of experts but only activating a few per token. Kimi K2, for instance, activates the same number of parameters per token as DeepSeek V3 but has a much larger total parameter count. Norris: Now, as an algorithmic concept, that sounds beautiful. More specialized experts, better routing, sharper gradients. But as someone who has spent way too much time staring at GPU profilers, my skeptical alarm is absolutely blaring right now. Hardware typically hates fine-grained, sparse routing. Linda: Oh, it is an absolute nightmare for GPUs! When experts become smaller and sparser, the arithmetic intensity, which is the ratio of math operations to memory accesses, just falls off a cliff. Norris: Exactly. You are constantly gathering token embeddings from all over the sequence, sending them to tiny little matrix multiplications, and then scattering the results back. You end up completely starved for memory bandwidth. And I imagine the activation memory footprint during training gets pretty ridiculous too, because you have to cache all those complicated routing paths for the backward pass. Linda: It really does. In fact, if you just naively scale up the granularity while keeping FLOPs constant, the activation memory required for the backward pass scales linearly. And to make matters worse, modern Grouped GEMM kernels end up wasting a ton of compute on padding because the hardware expects nice, predictable tile sizes, but sparse routers send highly irregular numbers of tokens to each expert. Norris: So let me guess, SonicMoE fixes all of this? Linda: It does. It reduces activation memory by 45 percent, improves compute throughput by up to 1.86x on Hopper GPUs compared to the state-of-the-art ScatterMoE, and completely rethinks how we do token routing to avoid that padding waste. On a cluster of 64 H100s, they hit a training throughput of 213 billion tokens per day for a 7B MoE. Norris: Okay, consider me hooked. A 45 percent memory reduction without sacrificing math sounds like black magic. How exactly are they pulling this off?
## The Hardware Inefficiency Problem
Norris: So at the end of our last chapter, you left me hanging. You promised me black magic that fixes a triple threat of hardware bottlenecks. Let us start by laying out exactly why fine-grained, sparse MoEs are such a nightmare for GPUs. Walk me through the pain points. Linda: I would love to. Let us define what we are talking about mathematically first. The authors define expert granularity as the model's embedding dimension divided by each expert's intermediate size. And sparsity is just the number of activated experts divided by the total number of experts. In modern models, granularity is going up, and sparsity is going up. Norris: Right. Which means the hidden matrices for each expert are getting much smaller, but the number of experts we choose from is getting much larger. But the token embedding size, the actual data we have to move around, stays exactly the same. Linda: Exactly! And that is the root of the first problem: plummeting arithmetic intensity. Arithmetic intensity is the ratio of FLOPs you compute to the bytes of data you have to transfer from memory. In a standard MoE layer, you have a token router, an up-projection, an activation function like SwiGLU, and a down-projection. Norris: And to do that up-projection, every single expert has to reach out into global memory and gather all the tokens that were routed to it. They are pulling tokens from completely random positions in the sequence. Then, after the down-projection, they have to scatter those results back to their original positions. Linda: Yes, and doing gather and scatter operations in global memory is incredibly slow. The paper has a chart showing that if you keep the total FLOPs and parameter count constant, but scale up the expert granularity, the IO cost for the forward pass scales completely linearly. It just shoots straight up. Norris: A straight line up and to the right on an IO cost graph. That is the worst kind of chart for a systems engineer. Your GPU is just sitting there twiddling its thumbs, waiting for the High Bandwidth Memory to deliver the data. It is completely memory-bound. Linda: It gets worse. That is just the bandwidth problem. We also have a severe memory capacity problem. In a normal dense layer, you cache your inputs and some intermediate activations so you can use them later to compute gradients in the backward pass. But with fine-grained MoEs, if you use standard autograd frameworks, you end up caching the outputs of the down-projection or the gathered inputs for every single activated expert. Norris: Oh, I see. Because the activation size scales linearly with the number of activated experts. If you have a highly granular model where you are routing to, say, eight or sixteen tiny experts instead of two large ones, your activation memory footprint for that layer just multiplied by four or eight. Linda: Precisely. If you just scale up granularity naively, you will hit a CUDA Out Of Memory error before you even finish the forward pass. Existing kernels like ScatterMoE or MoMoE just were not designed to handle these extreme IO costs or massive activation memory footprints. They choke on fine-grained setups. Norris: Okay, so we have memory bandwidth starvation and memory capacity explosions. You mentioned a third issue earlier: tile quantization. I shudder just thinking about padding. How bad is it? Linda: It is pretty catastrophic in sparse MoEs! To compute all these different experts efficiently, we use Grouped GEMM, which stands for General Matrix Multiply. It lets you run multiple matrix multiplications of different sizes in a single kernel launch. Norris: Which is generally a good thing. It saves you from paying the kernel launch overhead for every single tiny expert. Linda: It is good, but Hopper GPUs execute these multiplications in fixed hardware tiles, usually sizes of 64 or 128. If your sparse router only sends 10 tokens to a specific expert, the Grouped GEMM kernel still has to spin up a full tile. It pads those 10 tokens with 118 zeros just to fill the 128-sized block. Norris: That means you are throwing away over 90 percent of your Tensor Core cycles for that expert! You are doing the math, consuming the power, but you are just multiplying by zero. Linda: Exactly. The authors call it the tile quantization effect. In highly sparse regimes where tokens are spread thinly across hundreds of experts, the wasted FLOPs from padding become a massive fraction of your total compute time. You are basically paying for computation you do not need. Norris: So to summarize this hardware inefficiency nightmare: we are starving the Tensor Cores because of gather and scatter IO latency, we are running out of HBM capacity because of linearly scaling activation caches, and even when we finally get data to the cores, we are wasting cycles multiplying padding zeros. This sounds like an unsolvable mess. Linda: It sounds like one, but the beauty of SonicMoE is how it systematically dismantles all three of these bottlenecks. And they do it by co-designing the algorithm and the hardware execution, starting with a brilliant mathematical trick for that activation memory.
## Minimizing Activation Memory
Norris: So at the end of our last chapter, you left me hanging. You promised me a mathematical trick that completely dismantles the activation memory bottleneck. I know the standard trick in deep learning is activation recomputation, but you explicitly said they do not use extra FLOPs. How is that possible? Linda: To understand the trick, we have to look at how frameworks like PyTorch handle the backward pass. To compute the gradient for the router scores, which we call dS, standard autograd caches the output of the down-projection layer, the Y tensor. Norris: Right, and since Y represents the down-projection for every token across every activated expert, its shape is tokens times activated experts times embedding dimension. As the number of activated experts, K, goes up in these sparse MoEs, the size of Y balloons. Linda: Exactly. Other state-of-the-art kernels like ScatterMoE and MoMoE both cache Y. During the backward pass, they compute dS simply by taking the dot product of the output gradient, dO, and that cached Y tensor. It is straightforward, but incredibly memory hungry. Norris: Okay, so SonicMoE finds a way to compute dS without needing Y. Let me think. Y is just the result of multiplying the activation, let us call it A, by the down-projection weight, W2. Are they just substituting that definition into the gradient formula? Linda: You are exactly right! Instead of computing the dot product of dO and Y, they expand the math. They compute the dot product of the activation A, and the term dO times W2 transposed. And here is the brilliant part: that term, dO times W2 transposed, is something we already have to compute anyway to get the activation gradient! Norris: Ah! So they are reusing an intermediate tensor that already exists in the backward pass. They do not have to compute anything new, so the FLOP count stays exactly the same, but they can completely throw away the massive Y tensor from their activation cache. Linda: Yes! They call this intermediate tensor dA-prime. By writing a custom backward kernel, they fuse the computation of dS and the up-projection gradient directly into the epilogue of the Grouped GEMM. PyTorch's naive layer-by-layer autograd cannot do this because it does not know it can drop Y, but custom CUDA kernels can. Norris: That is genuinely elegant. It is one of those optimizations that seems obvious in hindsight, but requires you to completely break the abstraction barrier of your deep learning framework. So what do they actually end up caching? Linda: They only need to cache X, which is the input, and H, which is the output of the up-projection, plus some tiny routing metadata. And since the size of H depends on the expert intermediate size, n, multiplied by the number of activated experts, K, the memory stays perfectly constant if you are holding FLOPs constant. Norris: Because if you make the experts smaller, decreasing n, you proportionally increase K to maintain the compute. Since they are multiplied together, the footprint of H never changes. That is beautiful. What does this look like in terms of actual gigabytes saved? Linda: The numbers are massive. For a 7 billion parameter fine-grained MoE, SonicMoE reduces activation memory by 45 percent compared to ScatterMoE. At the 120 billion parameter scale, SonicMoE saves over 3 GiB of memory per layer compared to MoMoE. Norris: Three gigabytes per layer! Multiply that by 32 or 64 layers in a typical architecture, and you are saving an entire GPU's worth of VRAM just from this one mathematical rearrangement. That is the difference between fitting a model on your cluster and crashing with an Out Of Memory exception. Linda: Exactly. They also completely eliminated the need to materialize gathered inputs in memory by fusing the gather operation directly into the High Bandwidth Memory load. So the memory capacity problem is officially solved. The activation footprint is now identical to a dense model with the same number of activated parameters. Norris: Okay, color me impressed. We are no longer caching massive tensors, and we are not materializing gathered inputs. But we still have to actually execute all these tiny matrix multiplications without letting the GPU starve for data. That brings us to the memory bandwidth and IO latency problem. Linda: Right. We solved the capacity issue, but now we need to talk about speed. And that is where things like Ping-Pong scheduling and asynchronous TMA come into play.
## Overlapping Compute and IO
Norris: So, wrapping up our last thought, the SonicMoE team mathematically eliminated the activation memory explosion. Capacity is solved. But as we said, we still have a speed problem. We have to feed these hungry Tensor Cores without letting them starve while waiting for data from global memory. Linda: Exactly, Professor. And to solve the speed problem, the authors dive deep into the architecture of NVIDIA's Hopper and Blackwell GPUs. The core philosophy here is asynchrony. If you have to do heavy memory IO, you better be doing matrix math at the exact same time. Norris: Ah, hiding the latency. That is classic systems optimization. But doing that in a highly sparse Mixture of Experts is notoriously difficult because the memory access patterns are so chaotic. How do they actually pull off this overlap? Linda: They use something called Ping-Pong scheduling on Hopper GPUs. Hopper operates on a producer-consumer paradigm. SonicMoE sets up two consumer warpgroups. While one warpgroup is busy issuing the heavy matrix multiply-accumulate instructions—the MMA—the other warpgroup handles the epilogue. Norris: By epilogue, you mean all the messy work that happens after the matrix multiplication? Like applying the SwiGLU activation function or writing the final tensors back to High Bandwidth Memory? Linda: Exactly. In fine-grained MoEs, the epilogues are incredibly heavy, especially in the backward pass. So, Warpgroup A does the math, while Warpgroup B uses the Tensor Memory Accelerator, or TMA, to asynchronously load or store data. Once they both finish, they swap roles. Ping, pong. Norris: That makes perfect sense for a dense layer. But wait, what about the scatter operation? We talked earlier about how experts have to scatter their results back to the original token positions in the sequence. Doesn't that ruin the beautiful asynchronous TMA pipeline? Linda: It absolutely ruins it if you are not careful! And this is where SonicMoE makes a brilliant, counter-intuitive design choice. Other state-of-the-art kernels, like ScatterMoE and MoMoE, try to be clever by fusing the scatter operation directly into the memory store at the end of the GEMM. Norris: Usually, fusion is the holy grail of kernel writing. It saves you from launching a second kernel and reading the data twice. Are you telling me fusion is bad here? Linda: In this specific case, yes! On Hopper GPUs, the instruction needed to do that fused scatter is a synchronous global store. If you use it, the hardware actually blocks the execution of the next math tile until that store finishes. You end up stalling the world's most expensive calculator just to put data into the right buckets. Norris: Oh, that is painful to even think about. A synchronous stall right in the middle of your mainloop. Linda: Right! So SonicMoE does not fuse the scatter. Instead, they use asynchronous TMA stores to just dump the expert outputs contiguously into memory as fast as possible. This allows the Ping-Pong scheduling to work perfectly. The math never stops. Then, they use a highly optimized, separate expert aggregation kernel to gather the results per token afterward. Norris: That is fascinating. By un-fusing the scatter, they allow the asynchronous memory hardware to operate at peak efficiency. It is a perfect example of hardware sympathy. Do they see a big speedup from this? Linda: A massive one. Unblocking the MMA pipeline gives them a 20 percent throughput boost in those heavy epilogue kernels compared to the synchronous scatter fusion. Norris: Incredible. Now, Hopper is today's frontier, but what about the new Blackwell GPUs? The paper mentioned they support Blackwell as well. Does Ping-Pong scheduling still apply? Linda: Blackwell actually makes this overlap much more elegant. It introduces a dedicated on-chip Tensor Memory, or TMEM, and a Unified Matrix Multiply-Accumulate instruction. The TMEM naturally acts as a two-stage pipeline. One stage does the math while the other handles the epilogue, without needing the complex warpgroup coordination that Hopper required. Norris: So the hardware is physically evolving to make this IO-compute overlap easier. But it sounds like the SonicMoE team has wrung every possible drop of performance out of both architectures. We have fixed the memory capacity, and we have fixed the bandwidth stalls. Linda: We have! The GPU is humming along, pushing well over 500 TeraFLOPs on these granular MoE configurations. Norris: But wait... TeraFLOPs just measure raw math operations. If the router is sending weird, unaligned numbers of tokens to our experts... are we actually doing useful math, or is the GPU just multiplying a mountain of padding zeros at lightning speed?
## Token Rounding Routing
Linda: You hit the nail on the head, Professor! That is exactly the tile quantization effect we mentioned earlier. And it is the final boss of Mixture of Experts inefficiency. Norris: I knew it! You can have the fastest async memory pipeline in the world, but if 90 percent of your matrix is just zeros added to fit a 128-by-128 hardware tile, you are essentially just heating up the server room for fun. Linda: Exactly. If an expert receives, say, 130 tokens, the Grouped GEMM kernel has to launch two 128-token tiles to process them. That means 126 tokens in that second tile are pure padding. In highly sparse MoEs, where you might route a tiny handful of tokens to hundreds of different experts, the wasted FLOPs skyrocket. Norris: It hurts my soul just thinking about it. So how do the authors fix this? Do they just rewrite the hardware specs to accept jagged matrices? Linda: Not quite! They propose an algorithmic fix called Token Rounding Routing. It is a drop-in routing algorithm that guarantees the number of tokens sent to any expert is always a perfect multiple of the GEMM tile size. Norris: Hold on a second. If you are artificially inflating or deflating the number of tokens an expert receives just to appease the GPU tiles, you are fundamentally altering the model's choices. You are either dropping tokens an expert was supposed to see, or forcing it to process tokens it has no business looking at. Doesn't that destroy the accuracy? Linda: That is the most surprising part of the paper. It turns out, it does not hurt accuracy at all! The algorithm is incredibly clever. It starts by computing the standard token-choice Top-K routing. Then, it sorts the routing scores and makes a binary decision for each expert: either drop a few of the lowest-scoring tokens, or pad it with a few extra tokens using an expert-choice fallback. Norris: Ah, so they bound the error. What is the maximum deviation from the standard routing? Linda: Exactly one tile. They guarantee that the maximum deviation from the original Top-K token-choice result is bounded by at most one tile's worth of tokens per expert. Norris: Okay, bounding the error makes me feel a bit better. But what about the train-test gap? If I train my model with this Frankenstein rounding router, what happens during inference when I just want to generate text normally with standard Top-K routing? Linda: That is the best part! They tested this extensively on models up to the 1.8 billion parameter scale. You train with Token Rounding to get all the hardware efficiency, and then during inference, you just swap it back to standard Top-K routing. There is zero loss in downstream task accuracy or validation perplexity. Norris: Zero loss? So the model just learns to be robust to that slight one-tile noise during training? Linda: Precisely. It acts almost like a regularization effect. And the performance benefits are massive. By completely eliminating the padding waste, Token Rounding yields an additional 16 percent speedup on the kernel execution time in highly sparse setups. Norris: Sixteen percent on top of all the other memory and async optimizations we already discussed? That is phenomenal. It is a perfect example of algorithmic and hardware co-design. You modify the math just enough to make the silicon happy, without compromising the machine learning. Linda: Exactly! They successfully bridged the gap between what the model wants, which is dynamic sparse routing, and what the hardware wants, which is perfectly aligned block matrices.
## Conclusion and Impact
Norris: So, looking at the big picture, we have a memory footprint that refuses to explode, IO latency that is perfectly hidden behind compute, and a router that politely aligns with hardware tiles. It really is a masterclass in full-stack co-design. Linda: It absolutely is! And the broader impact here is huge. As MoE scaling laws push the industry towards even more granular and sparse architectures, techniques like SonicMoE are going to become mandatory. It shifts our entire perspective from just optimizing model quality per FLOP to optimizing quality per actual compute hour. Norris: Exactly. It does not matter how mathematically efficient your theoretical model is if the silicon takes twice as long to execute it. This paper proves you really can have your sparse cake and eat it too. Linda: And for any engineers out there who want a slice of that cake, the authors have open-sourced all their kernels. They are mostly written in CuTe with a clean PyTorch interface, so you can integrate them into your own training pipelines right now. Norris: Fantastic. Thank you for bringing this paper to the desk today, Linda. It is always refreshing to see elegant math solve brutal hardware constraints. And thank you to all our listeners for tuning in to another episode of Mechanical Dreams. Until next week, keep your gradients steep and your padding to an absolute minimum!