Welcome back to the Neural Intel podcast! In this episode, we dive deep into "The Ultimate MoE Training Handbook" by Nouamane Tazi, Leandro von Werra, and Thomas Wolf from Hugging Face [1]. ⚡ Neural Signal Check: Sparse Mixture-of-Experts (MoE) models now account for 18 of the top 20 open-weights LLMs on global leaderboards [3]. But turning sparse inference savings into fast, stable distributed training requires solving complex hardware, router, and cluster communication challenges [4, 5]. 📋 QUICK SUMMARY (Hook, Problem, Solution): • Hook: Scale model capacity to billions of parameters while keeping per-token compute low (e.g., 6.86B total parameters with only 1.22B active per token) [4, 6]. • Problem: Inter-GPU all-to-all token communication bottlenecks, router instability, and severe load imbalance across GPU ranks.
• Solution: Systematic hardware verification (nccl-tests), FP32 router precision, auxiliary-loss-free / quantile load balancing, and overlapping communication with computation [8-11].
⏱️ TIMESTAMPS / CHAPTERS:
00:00 - Introduction & Neural Signal Check
01:45 - Cluster Diagnostic & Hardware Readiness (EFA & All-to-All Baselines) 05:10 - Dense Reference Baseline vs. First MoE Setup
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Welcome back to listeners to the Neural Intel Podcast. Let's dive into today's topic. As always, we'll focus on the technical details and implications of the technology we discuss. Right. And we'll definitely keep the discussion engaging and interesting. And let's focus on the technical aspects. Absolutely. So if you checked the Artificial Analysis Index this morning, something just genuinely shocking has happened to the frontier AI landscape. Oh yeah. Right. It's wild, right? Like 18 out of the top 20 open weights models are no longer your standard dense models. We are talking about the
absolute bleeding edge releases from, you know, DeepSeek, GLM, MIMO. They've completely abandoned the traditional underlying architecture, the exact architecture that gave us the generative AI boom in the 1st place. Really. Yeah, and instead they've shifted to something called a mixture of experts or MOEI Mean. It really seems like the era of the monolithic dense transformer is just rapidly coming to an end. It is, but it's a shift porn entirely out of necessity. I mean, the underlying problem with the standard dense transformer is that, well, every
single parameter in the model is activated for every single token that gets processed. And so if you type A10 word sentence into a dense 100 billion parameter model, it literally has to compute all 100 billion parameters 10 times over. Exactly. And as these models scale towards like a trillion parameters to gain more reasoning capabilities, calculating every single weight for every single word just becomes computationally impossible. The energy draw is astronomical, right? Yeah, the merry bandwidth of the hardware physically cannot keep
up. Which brings us to the solution that's taking over the industry. The mixture of experts, architecture. So instead of 1 massive network that processes everything, the model acts more like a dispatcher. Yeah, it routes each incoming token to a highly specialized subset of smaller networks, which are the experts. So this allows the model to hold vastly more parameters in its memory, meaning much larger capacity for knowledge, while drastically limiting the active compute required for any given word. You get the brain power of a trillion parameter model, but
you're only really paying the computational cost of a tiny fraction of it. It sounds brilliant on paper, yeah, but what happens in reality is that Moe introduces this whole host of terrifying new engineering and networking bottlenecks, doesn't it? Oh, absolutely. Moving from a dense model to a sparse model completely breaks the traditional rules of how we build, train, and run neural networks. And to figure out how these labs are actually solving those bottlenecks, today's deep dive is sourced entirely from this absolute masterpiece of a technical document. Yeah, the ultimate Moe Training
Handbook. Exactly. Published by the Hugging Face team, specifically authors Noamane Tazi, Leandro von Vera, and Thomas Wolfe. We really owe them immense credit for publishing what is essentially the Holy Grail of distributed training documentation. It really is a goldmine. So our mission today is to deconstruct the technical anatomy of an Moe model, layer by layer. We'll look at exactly how a token navigates the architecture, the absolute networking nightmares of moving data across GPU's, and how to train and serve these massive
systems without them. Just, you know, collapsing into a pile of digital rubble. Because they definitely want to collapse. Oh, for sure. And as always, we want to hear from you. Drop your take in the comments below. Visit ourblog@neuralintel.org to stay updated on the latest in AI and ML, and make sure you check out the show on YouTube, Apple Podcasts, and Spotify. So to even begin understanding how an Moe functions, we have to pull back from the code and look at the physical cables in silicon running it. The actual hardware. Right, because the transition
from dense to Moe fundamentally alters how GPU's physically communicate across a data center. Let's establish the baseline hardware environment the handbook uses. We are looking at a SLURM cluster of eight GPU nodes. Think of like an AWSP 5 node. Yeah, that's essentially a metal box packed with eight NVIDIA H100 GPU's, all connected internally by NV Link and then connected to the outside world by Elastic Fabric Adapters, or EFA. Now, in a traditional dense model setup, these GPU's rely heavily on a mathematical
operation called Allreduce to synchronize their learning. Right, let's breakdown Allreduce. In a standard dense training run, you are using data parallelism, so every GPU in your cluster has an identical copy of the model. GPU one gets 1 batch of training data, GPU 2 gets a different batch and so on. Exactly. They all do their forward passes, calculate their errors, and do their backward passes to figure out how the weights should change. But before they actually update their weights, they have to synchronize. They basically pause, communicate their proposed changes across the network,
average out the gradients, and then all update their weights identically. That sharing and averaging process is the all reduce operation. So in a dense model, the GPU's are essentially working independently for a while and then having a quick sync meeting. The data being passed across the cables is just the gradient updates. But in a mixture of experts model, you aren't using data parallelism in the same way you are using expert parallelism. Right, the experts are physically spread out. You might have an Moe layer with 64 experts.
Expert One might live in the VRAM of a GPU on Rack A, while Expert 64 lives on a completely different GPU over on Rack Z. So when a batch of tokens reaches this Moe layer, a router decides where each token needs to go. And if a token on Rack A needs Expert 64, that token's entire hidden state vector must physically leave Rack A, travel across the data center's network fabric to Rack Z, get processed, and then travel all the way back. I mean, this sounds like a logistical nightmare if the
dense model is a company where everyone works from home and occasionally syncs up on a big video call. The Allreduce then the Moe model is like a massive city. Yeah, a very congested city. Right. Millions of commuters are physically leaving their houses, taking a train to a highly specific office buildings, doing their work and taking the train back. And this isn't happening once a day. This is happening constantly. It happens at every single Moe layer for every single token during both the forward pass and the backward pass. This operation is called an all
to all token exchange. The entire network has to just throw data to everyone else simultaneously. Exactly, and this completely changes the stress placed on your network switches. Well, let's talk about that stress, because the handbook reveals a terrifying hardware reality here. If you run a standard cluster diagnostic you might see blazing fast speeds for an all reduce operation. Yeah, the authors noted a cluster hitting like 398.52 gigabytes per second for all reduce. Which is great. A hardware engineer would look at that and say awesome, the
network is healthy, start the training run. And that will be a multi $1,000,000 mistake because when they tested the all to all operation on that exact same hardware, the bandwidth plummeted to 39.84 gigabytes per second. Wait. A 90% drop in efficiency, why does it drop so drastically? I mean if the cables are the same and the GPU's are the same, why does an all to all gridlock the system while an all reduce just flies? Because of the communication pattern OK, all reduce is highly structured.
GPU's can pass data in a ring or a tree structure, accumulating data cleanly as it moves. All to all is just pure chaos by comparison. Every single GPU is trying to send distinct non overlapping chunks of data to every other GPU simultaneously. Right, it completely floods the network interface cards and the network switches. It exposes routing inefficiencies and congestion control issues that a structured all reduce civilly bypasses. OK, neural signal check. Here's why this development
actually matters at a technical level. If your hardware diagnostic only checks standard matrix math or all reduced speeds, you will be completely blind to the all to all bottleneck that will absolutely strangle your Moe during training. You have to benchmark the exact communication pattern your model uses. Which brings us to the actual networking protocols, the NCCL and the EFA. Right, the NVIDIA Collective Communication Library. It is the underlying software logic that dictates how NVIDIA GPU's talk to each other. So when a tensor needs to move from GPUA to GPUB, NCCL decides
the fastest route. If they are in the same physical box, uses the Hyperfast and V link. If they're on different nodes, it has to use the network cards like AWS EFA. And setting these up perfectly seems incredibly fragile, specifically because of something called a silent failure. Silent failures are just the bane of distributed systems. Ideally across nodes, NCCL should use RDMA Remote Direct Memory access. Which allows a GPU on node one to write data directly into the VRAM of a GPU on node 2, right?
Completely bypassing the operating system, CPU and kernel. Exactly. It's incredibly fast, but to do this on AWS, NCCL needs a specific plugin called the OFI plugin to talk to the EFA. What happens if that plug in is misconfigured or if the you know the environment variables aren't perfectly aligned in your docker container? The training doesn't crash, that's why it's a silent failure and CCL looks for the RDMA path, fails to find it and quietly falls back to using standard TCP sockets. Wait, what?
It falls back to TCP as in the standard Internet Protocol that sends emails and loads web pages. Yeah, it routes the massive tensor data through the CPU down through the OS networking stack, chops it into standard TCP packets, sends it across the wire, and reconstructs it on the other side. Oh my God. The handbook explicitly documents the catastrophic cost of this. A multi node training run that was supposed to hit 42 point O teraflops per second suddenly dropped to 1.7 teraflops per second.
That is a 25X slowdown. You could burn through your entire compute budget in a month and accomplish 2 days worth of training, all because a configuration flag was missing. And because it's a silent failure, the loss curves might still go down. The model is mathematically learning, it's just doing it at an absolute crawl. So you really have to look for the phrase using network Lib fabric in the logs. If it says using network socket, you have to stop the run immediately and fix it.
OK, let's assume we've passed that hurdle. We've verified the RDMA is working, the all to all bandwidth is optimized and our network is pristine. Now we have to look at how the model actually uses that network. Right, the routing. Yeah, a token has arrived at an Moe layer. How does it know which experts building to take the train to? We have to look inside the router and specifically how logits become weights. Well, the router is actually one of the smallest components in the entire network. It's typically just a single linear layer.
So when a token arrives, it's high dimensional hidden state vector is multiplied by a routing weight matrix and this outputs a set of scores which we call logits. You get 1 logit for every available expert. If your Moe layer has 64 experts, the router generates 64 logits for that token. And the router just picks the experts with the highest logits. So if we are doing a top 2 routing scheme, it just looks for the two highest numbers and sends the token to those experts. It does, but selecting the experts is only half the job.
The router also has to assign a mathematical weight to each chosen expert. Right, because when the token comes back from expert A and expert B, the model doesn't just add their outputs together. No. It multiplies expert A's output by a weight and expert B's output by a weight, and then sums them. This is how the model determines how much to listen to each expert. Which brings in the gating functions. The logits have to be transformed into these weights, and the traditional way to do this in neural networks is using a softmax function.
Yeah, softmax takes any set of numbers and turns them into a probability distribution that always sums to 1.0. It is great for classification. But softmax has an exponential nature, right? As the router learns and becomes more confident, the gap between the top logit and the second logit grows. Because the exponential math in softmax, a slightly higher logit gets pushed towards a probability of 1.0 and everything else gets crushed towards 0. That seems like a massive waste of compute. If my token routes to two
experts and softmax gives expert A a weight of .99 and expert BA weight of .01, core expert B is doing all this massive matrix multiplication across the network just for its final answer to be multiplied by .01 and essentially ignored. It is a total waste. The top expert dominates and the secondary experts failed to contribute meaningfully. This is exactly why Frontier models are moving away from softmax for routing. OK, So what are they using? Sigmoid. A popular alternative is a
sigmoid function, yeah. How does sigmoid differ here? Doesn't it also output values between zero and one? It does, but sigmoid evaluates each logit completely independently. It doesn't force them to sum to one. If the router generates very high logits for both expert A and expert B, the sigmoid function will output a weight near one point O for both of them. So if it's confident in both, they both get an equal say. Exactly. Confident experts end up with roughly equal weights, so they all contribute their full computational value to the final
output. And the handbook also mentions 1/3 option that DeepSeek V4 switch to which is the square root of the soft plus function. Yeah, that is getting deep into the math weeds. What makes that function special? It acts as a mathematical middle ground. Sigmoid can sometimes saturate too quickly, meaning it hits one point O and stops passing useful gradients back during training, right? The square root of soft plus scales gracefully for positive log it's. It completely avoids the winner
takes all crushing effect of softmax, but it provides A smoother gradient for the optimizer to learn from than a raw sigmoid. But wait, if we use sigmoid or the square root of soft plus, we lose the main property of softmax. The weights no longer sum to one point O. True. So if a token comes out of the Moe layer and its values are being multiplied by two different weights that are both sitting at one point O, the output vector is going to be massive. The scale of the numbers will explode. You've hit on the exact reason
we need renormalization and an output scale. If you just let those weights ride, the activation norms of your neural network will fluctuate wildly depending on how confident the router is. The model will just become numerically unstable and diverge. So even if you use sigmoid to get the weights, you still take the final chosen weights and renormalize them. You divide each weight by the sum of the chosen weights so that they add up to 1. Wait, I see a math problem there. If we force them to sum to one
point O and they are both equally confident, they both get a weight of 0.5. The outputs of the experts are being halved. It gets worse the more experts you pick. If you route to 8 experts and they all get an equal slice, each experts output is multiplied by 0.125. When you average the outputs of multiple independent experts like that, the variance of the combined output drops significantly. The token signal loses energy. So how do you fix a signal
that's shrinking as it passes through the network? You'll apply a mathematical scaling factor to restore the root mean, square, or RMS of the output. Oh, so after you sum the renormalized expert outputs, you might multiply the entire vector by a constant like 2.5, or dynamically by the square root of K, the number of experts you routed to. Exactly. This restores the energy of the token signal so it maintains A consistent magnitude as it travels deeper into the transformer layers. OK, here is where the handbook
dives into something that completely fascinated me. The precision of the router. This is a huge one. In modern AI, the whole goal is to use lower precision formats like FP16 or BF16. You use 16 bits instead of 32 bits to store a number, which halves your memory footprint and allows the tensor cores to chew through matrix math twice as fast. But the authors highlight that doing this to the router is a fatal mistake. It is one of the most critical yet subtle bugs you can introduce into an Moe code base. The massive FFN experts can run
in low precision, but the tiny little router calculation absolutely must be done in high definition FP 32 precision. Right, because if you calculate the router logits in BF16, the model will often catastrophically fail to learn. Google explicitly documented this failure mode in their switch Transformers research. Yeah, they did. I really need to understand the physics of this. We are doing billions of parameter matrix multiplications in low precision to save memory, but this one tiny routing calculation has to be in high def FP 32.
It does. It's like using a blurry, worn out tape measure to construct the steel beams of a skyscraper, but demanding a laser micrometer just to sort the mail in the lobby. Why is the router so incredibly fragile? To understand why the laser micrometer is necessary, you have to understand how BF16 represents numbers compared to FP32. Floating point numbers are stored in scientific notation. They have a sign bit, an exponent which tells you how big the number is, and a mantissa which tells you the precise
decimal value. Exactly. FP 32 has 8 bits for the exponent and 23 bits for the mantissa. It's highly precise. And BF 16. BF16 was invented by Google specifically for machine learning. It keeps the 8 bit exponent, meaning it can represent numbers just as massively large as FB32 without overflowing. But to save space, it chops the mantissa down to just 7 bits. So it sacrifices precision to maintain scale. It can store a massive number, but it can't tell you the exact
decimal points of that massive number. Exactly. Now think about the ruler analogy you brought up earlier. In floating point math, the tick marks on the ruler represent the numbers the computer can actually understand. When numbers are close to 0, the tick marks are microscopic. You have incredible precision. But as numbers get larger and larger, the absolute physical distance between the tick marks gets wider because the exponent has stepped up. So the limited bits of the mantissa are representing larger and larger chunks of distance.
Right, and here is where it collides with Moe training. As the model trains the router's weights update and the logits it outputs have a natural tendency to drift upwards, they get larger. Because standard loss functions don't care how big the logits are, they only care about the relative difference between them, right? Yeah, the router realizes that making the logits larger makes the softmax output sharper, so it pushes the logits from 5 up to 20 up to 100 and. What happens to our BF 16 tick marks when the logits drift up to 100?
The tick marks spread out at a value of 100. The BF16 format might only have a tick mark at 100.0, and the next possible representable number is 100.5. It physically cannot store anything in between. Oh, I see the collision. The sharpness of the routing decision lives in the microscopic gaps between the logits. Precisely if expert A is genuinely better, it's true. Mathematical logit might be 100.1 while expert B is 100.2. NFP 32 router has enough
manticipates to see that expert B is better. But ABF 16 router will round them both to the exact same tick mark 100.0. They tie. They tie, and when experts tie, the selection mechanism essentially becomes random. Yeah, tokens start randomly flipping between experts from step to step, The gradients become chaotic noise, the optimizer gets confused, and the model diverges. That is mind blowing. The entire trillion parameter model collapses because a 7 bit mantissa rounded 2 numbers to the same integer.
So the fix is just forcing the router to stay in FP32. That is Part 1 of the fix. You compute the router in FP32, but remember even FP 32 has a limit. If the logits drift to 10,000 or 100,000, even FP32 tick marks will spread out and cause rounding ties. So you have to stop the logits from drifting upward in the 1st place. You have to keep them near 0, where the floating point tick marks are infinitely dense. Exactly. And how do you force a neural network to keep its numbers small while it's trying to
learn? You apply an auxiliary penalty called AZ Loss. You add this Z loss term to the overall training loss. Specifically, the Z loss penalizes the log sum X of the router logits. Let's unpack that. It stands for the logarithm of the sum of the exponentials. Without getting bogged down in the equation, think of log sum X as a smooth approximation of the maximum logit value. By penalizing the log sum X you are basically adding a mathematical rubber band to the
logits. So as the logits try to drift higher, the Z loss pulls them back towards 0. Exactly. It applies A gentle downward pressure on the overall magnitude of the logits. This keeps the logits anchored in the sweet spot of the floating point representation right around 0, ensuring that the microscopic decimal differences between them are preserved perfectly forever. That is a phenomenal piece of engineering. So we've got our FP32 laser micrometer sorting the mail, and we've added AZ loss rubber band
to make sure the mail doesn't pile up to the ceiling. But that router logic brings up a massive physical problem. If the router is working perfectly, and it identifies that expert one is mathematically the smartest expert for grammar, it's going to send every single grammar token to expert one. How does the hardware not meltdown from the traffic jam? We have to talk about load balancing. This is arguably the most difficult aspect of training in Moe because the router is fundamentally selfish. It only cares about minimizing the immediate loss for the current token it is holding.
Yeah, if it calculates that expert one is even 0.1% better at processing a comma than expert two, it will ruthlessly route every single comma token to expert one. And since language is absolutely flooded with commas and punctuation, Expert one gets slammed with millions of tokens, while Expert 2, which might be slightly worse at commas but amazing at French verbs, sits completely idle waiting for French text. This brings us to the core routing paradigms. Token choice versus expert
choice. What you just described is token choice. The tokens look at the experts and pick their favorites. And because real world data is heavily skewed towards certain topics and grammar structures, token choice naturally leads to catastrophic load imbalances. What is the alternative expert choice? How does that flip the dynamic? In expert choice, you invert the selection process. Instead of tokens picking experts, the experts look at all the tokens in the batch. Each expert evaluates the batch and selects its top K favorite
tokens until its physical capacity buffer is full. Mathematically, that sounds like a perfect solution. If every expert picks exactly 1000 tokens, you have guaranteed 100% perfect load balancing. No GPU sits idle, no hardware is wasted. Why doesn't everyone just use expert choice? Because of a fatal flock called Future Token leakage. Expert choice works beautifully during training because the expert is looking at a massive static batch of text. You can look at the beginning of
a paragraph and the end of a paragraph simultaneously to pick the best tokens. But think about inference. When a user is actually chatting with the model. Inference is auto regressive. It generates text one single token at a time. Exactly. During inference, the expert cannot look into the future. It doesn't have a batch of tokens to pick from, It only has the single token that was just generated. And can't decide if it wants to process the current token or wait for a better one three words later because the future words haven't been generated yet, right?
Because the routing mechanism during inference fundamentally breaks from how it was trained, Expert choice models suffer severe performance degradation when actually deployed. So we are essentially forced to stick with token choice for auto regressive language models, which means we are stuck fighting the traffic jams. How do we measure how bad the jam is? The handbook mentions a metric called Maxvio. Maxvio stands for Maximal Violation OK. It is a vital metric for your dashboard. It measures how far the busiest
experts load sits above the mean or average load of the layer. Let's say you have 64 experts. OK, if you divide the tokens evenly, the average load is 1000 tokens per expert. If your busiest expert is receiving 2000 tokens, it is 100% over the mean. Your Max bio is 1.0. And a Max bio of 0.0 means perfect balance. Neural signal check. Here's why this development actually matters at a technical level. Imbalance isn't just an abstract mathematical penalty on a loss
curve, it is a physical hardware Rodelbach. Absolutely. Because of the all to all network barrier we discussed earlier, a cluster of 1024 GPU's will literally sit completely idle waiting for the single GPU holding that overloaded Max patch expert to finish its math. The network cannot proceed to the next layer until all tokens are returned. One overloaded expert halts $100 million supercomputer. Which is why we introduced balancing strategies to force the router to behave. The most blunt instrument is the auxiliary loss.
How does that work? You add another term to the main loss function. This term mathematically increases if the routing distribution becomes uneven. When the optimizer does backpropagation, it penalizes the router's weights for sending too many tokens to one expert. The router learns that sending everything to expert One causes a spike in the loss, so it starts spreading them out. But doesn't that create a terrible tension? It does. The router wants to send the token to the best expert to get a good language modeling score, but the auxiliary loss slaps its wrist and says no, send it to
the dumb expert because it needs work. Aren't we forcing the model to make suboptimal intelligence choices just to keep the hardware happy? Yes, the auxiliary loss actively competes with the main language modeling loss. It's a tug of war. If you set the aux loss coefficient too high, the model routes tokens almost randomly just to achieve perfect balance and the model becomes stupid. And if you set it too low, the router ignores it, the balance fails, and the hardware gridlocks. It is incredibly difficult to tune. Are there other ways? Ways that don't corrupt the actual learning gradients.
Yes, Frontier models are shifting toward loss free expert bias. Instead of messing with a loss function and confusing the gradients, you inject A dynamic bias directly into the router's logits, but purely for the selection phase. How does a bias work in this context? It's an additive scaler. If the system detects that expert one is getting too full, it artificially subtracts a value from expert one's logit before the top case selection happens. If Expert 2 is starving for tokens, it artificially adds a
value to Expert 2's logit. This steers the tokens toward underutilized experts without changing the underlying mathematical logits that the router uses to learn. Exactly. OK, let's use an analogy here. This sounds like a restaurant where the grill chef is slammed with 50 burger orders, and the salad chef is just standing there wiping the counter. The customer, the training batch, doesn't get their food until both chefs are done, right? Using an auxiliary loss is like yelling at the waiter for writing down too many burger orders. The waiter panics and, to avoid
getting yelled at, starts bringing salads to people who ordered burgers. The balance is fixed, but the customers are furious. The model loses intelligence. And how does the loss free bias fit into the restaurant? The loss free bias is like the kitchen manager quietly taking some of the burger prep, like toasting the buns or slicing the tomatoes and routing it over to the salad chef station to help out. The waiter still orders burgers. The customer still gets a burger, but the physical workload in the kitchen is dynamically shifted to keep everyone moving. That is an excellent way to
conceptualize it. But to make the salad chef actually useful at toasting buns, the router has to learn which tokens the underutilized expert can adequately handle, right? If you shift the bias wildly from microsecond to microsecond, the router never learns. This is why the handbook discusses quantile balancing. Smooth out the steering. Exactly. Quantile balancing uses an exponential moving average, or EMA. Instead of wildly changing the biases based on the immediate panic of a single batch of
tokens, the EMA slowly adjusts the bias over global batches. It takes a longer term view of the traffic patterns. It slowly nudges the router over millions of tokens, giving the experts time to adapt to the new data they are receiving. Which brings up the critical concept of scope. Do you calculate this balance per micro batch, per sequence, or over the massive global batch? Why does the scope of the balancing fundamentally change the models intelligence? Scope changes everything about how the experts specialize. To understand this, let's say
your training data happens to have a micro batch that consists entirely of Python code. OK, thousands of Python tokens hitting the router at once. If you enforce load balancing strictly per micro batch, the router looks at those Python tokens and is mathematically forced to distribute them perfectly evenly across all 64 experts. Which means every single expert receives a tiny slice of Python code. Exactly, and because of that you destroy specialization. No single expert can become the
master of Python because the strict micro batch balancing forbids any single expert from taking all the Python tokens. Every expert is forced to learn a little bit of Python, a little bit of French, a little bit of history. They all become mediocre generalists. So the obvious solution is to balance over the global batch. A global batch contains a massive mixture of Python, French literature, math equations, and Wikipedia articles. That way expert A can grab all the Python, expert B grabs all the French, and as long as they all get an equal amount of total work across the massive global
batch, everyone is happy and hyper specialized. In theory, yes, global balancing creates beautifully specialized experts. But here is the brutal hardware trap. Let's say you have that perfectly mixed global batch. It's too big to process at once, so it's fed to the GPU's sequentially in smaller micro batches. Chunk by chunk. Micro batch 1 happens to be the chunk of Python data. Because Expert A has specialized in Python, 100% of the tokens in micro batch one are routed to Expert A.
Oh no. Yes, during the processing of that specific micro batch, the single GPU holding expert A does 100% of the work. The other 63 GPU sit completely idle, waiting for expert A to finish. So even though the global batch will be perfectly balanced by the end of the day, at a microsecond to microsecond hardware level you have catastrophic imbalance. The cluster grinds to a halt. You're literally trapped. You either ruin the models intelligence by forcing micro batch balance or you ruin the hardware efficiency by allowing
global batch specialization. And This is why training MO ES is considered a dark art. You are constantly tuning the EMA, the bias scalers, the routing algorithms, trying to find the exact scope that allows just enough specialization to make the model brilliant, but just enough micro level balance to keep the massive GPU cluster fed. OK. We've routed our tokens, we've balanced the traffic so the data center doesn't melt. But what exactly are these tokens being routed to?
We need to look at the physical architecture of the experts themselves. The granularity, the latent projections, and the wiring. When we talk about an expert in these architectures, we are almost always talking about a feed forward network or FFN. In a dense transformer, the attention layer mixes information between tokens, and then the FFN is a massive wide layer that processes each token individually to extract features. In an Moe, we take the compute budget of that massive, dense FFN and slice it up into experts.
This brings us to the concept of granularity. Right. If I have a compute budget for a massive dense layer, I have choices. I could replace it with eight massive experts and route each token to two of them, or I could slice it much finer. You could create 64 smaller experts and route tokens to 8 of them. Mathematically, the total number of active parameters and the compute flops per token stays absolutely identical. The authors note that finer granularity, more smaller experts actually leads to better
learning and lower perplexity. So why not just make 1000 tiny experts? Because of the strict physics of how a GPU operates, GPU's achieve their incredible speeds by doing massive block matrix multiplications known as gems. They use specialized hardware called tensor cores to do this. Tensor cores require matrices to be as a certain minimum size to fully saturate their compute pipelines. If you slice your experts too small, the matrices become tiny. The GPU waste cycle spinning up the operation processes the tiny
math instantly and spins down. You lose compute efficiency. It's like using a massive freight train to deliver a single pizza. The overhead of starting the train ruins the efficiency of the delivery. Exactly. And the second problem with extreme granularity is the network overhead. If a token routes to two experts, you are sending 2 copies of that token's massive hidden state vector across the network fabric. If you route to 16 tiny experts, you are duplicating and sending 16 copies of that massive vector over the all to all network. The bandwidth requirement
absolutely explodes and chokes the system. But the handbook mentions a brilliant architectural fix to this network overhead called Latent Moe. How does compressing the token fix this? Latent Moe is a very clever mathematical trick. A standard tokens hidden state vector is huge. Let's call it dimension D, which might be 4096 numbers long. Sending that full 4096 dimension vector across the network 8 times is terrible. Right.
In latent Moe, before the token is dispatched over the network, it is multiplied by a projection matrix that compresses it down to a tiny latent size. Let's call it dimension L, maybe just 256 numbers long. So you drastically shrink the data footprint. Exactly. You send that tiny compressed vector across the network. The expert, which is also proportionally smaller, processes it. The expert sends the tiny vector back across the network, and then another projection matrix scales it back up to the full dimension D so it can continue
through the model. It's literally like zipping a massive file before you e-mail it, the expert unzips it, edits the file, rezips it, emails it back, and you unzip it locally. You drastically reduce the bandwidth required on the cables. That compression allows you to use a much higher granularity, more experts, better routing without hitting the all to all network bottleneck. Now here is a concept that broke my brain a little bit when reading the handbook. Shared experts DeepSeek-V3 and Kimi K3 use this architecture. The idea is that one expert sits
outside the router and it processes every single token regardless of what the router says. Yes, the shared expert acts as a foundational knowledge base. It learns the common grammar, the basic syntax, the structural connective tissue of the language that every single token needs. But hold on, if we introduce a shared expert that processes every single token, haven't we just reinvented the dense model? Aren't we undoing the entire point of the Moe which was to achieve sparsity and not compute every parameter for every token? It's a great observation, but
you have to look at how they allocate the compute budget. The shared expert is not the size of the whole original dense model. It is relatively small. OK, how does that work in practice? Think of it like a medical hospital. You have a team of highly specialized doctors, a brain surgeon, a cardiologist and oncologist. These are your routed experts. You don't want the world class brain surgeon wasting their brain power and time taking a patient's blood pressure, asking for their basic medical history, or checking their height and weight. Right. You have a General practitioner
or a triage nurse. Do that for every single patient first. Exactly. The shared expert is the triage nurse because it handles the basic syntax and common knowledge for every single token. The routed experts are completely freed up from having to relearn basic grammar. They don't have to waste their parameter capacity learning what a period is or how a noun connects to a verb. They can dedicate 100% of the parameters to becoming hyper specialized in quantum physics or Python coding or complex logic. By adding a small dense component, you make the sparse components vastly more
efficient. That makes total sense. Now what about the layout of these blocks? Does every single layer in a 100 layer transformer need to be an Moe layer? Not necessarily. Every Moe layer introduces an all to all network bottleneck. To mitigate this, some models like Llama 4 Maverick alternate their layers. They put a standard dense attention and dense FFM block, followed by an Moe block, followed by a dense block and so on. By doing that, you literally cut the all to all network traffic
of the entire model in half while still maintaining massive sparse capacity. Yes, and the handbook also highlights an optimization from Megatron called Shortcut Connections. This is a pure systems engineering trick. What does that do? In a standard layer, the model does the attention math, finishes it, and then sends the tokens to the Moe. Megatron overlaps them. While the attention head is crunching the massive matrix math on the GPU's tensor cores, the networking card is simultaneously sending the tokens out to the experts. You hide the latency of the
network transfer behind the latency of the mathematical computation. Which is brilliant because the network card and the tensor cores are different physical pieces of silicon on the board. You keep them both busy at the same time. OK, we have the architecture built. The network is wired, the router is Z loss stabilized. Now we hit run. And this is where training introduces terrifying new ways for a model to crash. Yeah, training an Moe from scratch from random initialization is notoriously difficult, but the handbook details a massive shortcut that
the industry uses called upcycling. Right, you don't actually have to start from random noise. You can take an already trained, highly intelligent dense model like a Llama 3 or a Mistral and physically transform it into an Moe. How do you slice a dense model into experts? Let's say your dense model has a massive FFN that is 8192 neurons wide. You mathematically slice that weight matrix into 8 smaller slices, each 1024 neurons wide. Then you literally copy and
paste those 8 slices 8 times over, giving you 64 total experts. But if I just copy them, don't I just have 64 completely identical experts? If a token routes to expert A or expert B, it gets the exact same mathematical answer. It's step zero. Yes, every expert is a clone, but you add a tiny bit of random noise to the router's weights. It's training begins. This noise causes slightly different tokens to go to slightly different copies of the experts.
Because the data they see starts to diverge, the gradients they receive during back propagation start to diverge. Over thousands of training steps, those identical clones slowly drift apart. They adjust their weights to better serve the specific tokens they are receiving. The Moe starts out smart, inheriting all the dense knowledge, and then seamlessly drifts into hyper specialization. It's like cloning a brilliant scientist 64 times, locking them all in different specialized libraries, and a year later one has become an expert in biology
and the other in astrophysics. Exactly. But as they drift, you have to be very careful about how you update their weights. This brings us to the choice of optimizer Adam West versus Muon. Adam West is the industry standard optimizer for almost every neural network, but it is incredibly dangerous for MO ES. Why? How does Adam West actually update a weight? Adam West scales its weight updates based on a moving average of the gradient history. It acts like a teacher looking at a student's past grades. If a parameter consistently gets
steep useful gradients, Adam W increases the learning rate for that parameter. But in an Moe, the routing is dynamic. If the router decides it doesn't like a particular expert, that expert might go hundreds of training steps receiving almost 0 tokens. So it's gradients basically dropped to 0 for a long time. Yes, and because Adam W relies on that historical moving average, the optimizer essentially puts that expert to sleep. It looks at the history, sees 0 gradients and shrinks the update size to microscopic noise. Even if the router leader accidentally sends a batch of
tokens to that expert, the optimizer won't move the weights enough to learn anything useful. The expert effectively dies and becomes dead weight on the GPU. Neural signal check. Here's why this development actually matters at a technical level. This is exactly why Frontier Labs are experimenting with newer optimizers like Muon for the expert layers. Yeah, Muon fundamentally changes the mathematics of the update. Instead of looking at a historical average, Muon orthogonalizes the update matrix. It scales the update based
purely on the physical shape of the matrix itself. It completely ignores how big or small the historical gradient is. By doing this, it artificially performs CPR on dying experts. Even if an expert hasn't received a token in 1000 steps, the moment it gets 1 Muon mathematically forces the weights to update significantly. It decouples the learning rate from the router's popularity contest, ensuring all the expensive silicon on the GPU is actually learning. Are there other stability guards? What happens if an expert just
goes rogue during training? The handbook details what they call catastrophic failures. Sometimes a single expert will encounter a weird batch of data and its weights will spike. It starts producing massive exploding output values, while the rest of the model looks perfectly fine. Because of the residual connections, that exploding value infects the entire forward pass and corrupts the model. To prevent this you have to implement step by step mitigations. Like what? You rigorously cap the gradient norms so no single update can be
too large. You physically clamp the Swiglu activation functions inside the experts so their mathematical outputs literally cannot exceed a certain bound. And as we mentioned with the router, you aggressively keep the critical attention outputs in FP32 precision to prevent compounding floating point errors. It sounds like you are wrapping the entire multi $1,000,000 model in mathematical bubble wrap just to keep it from tearing itself apart. That is exactly what you were doing. MO E training is an exercise in writing a razor's edge between chaos and gridlock.
Which leads us to the system's efficiency of the cluster hardware. Even if the math is perfectly stable and wrapped in bubble wrap, the sheer physics of moving terabytes of data across a cluster requires strict traffic control. Let's talk about group limited routing. As we discussed, a single token might want to pick eight different experts in a massive cluster of 1024 GPU's. Those 8 experts might physically live on 8 completely different physical nodes. That means one token has to be copied and blasted out to 8
different locations across the highest latency part of the network, the Internode fabric. The dreaded cross rack traffic. Exactly. DeepSeek-V3 came up with a brilliant, albeit restrictive, rule called Group Limited Routing. They mathematically force the router's decision making process so that a token is only allowed to select experts that live on a maximum of four physical nodes. So even if the absolute best expert for a token lives on node 5, the router evaluates its current path and says, sorry,
you've already visited experts on 4 nodes. You have to pick a suboptimal expert that happens to live on one of the nodes you are already going to. Yes, it is topological aware routing. It trades a tiny bit of theoretical model intelligence for a massive reduction in cross node network traffic. It mathematically caps the fan out of the tokens, preventing the network switches from being overwhelmed. That brings up another crazy hardware limit, capacity factors and token dropping. What happens when an expert physically runs out of memory buffer on the GPU?
Let's say a massive spike of tokens all route to the same GPU despite our best load balancing efforts. When a buffer fills up, you basically have three engineering choices. Choice one. You let the GPU try to dynamically allocate more memory, it runs out of VRAM and the entire cluster crashes with an OOM and out of memory error. That's a bad choice. Choice two, You use a dropless architecture. You dynamically pause the other GPU's, resize the buffers across the network, and wait for the overloaded GPU to chew through
the massive queue of tokens. This prevents crashes, but it destroys your throughput. Your expensive cluster is spending most of its time paused. And choice 3. Choice 3 is you literally set a hard capacity factor. You define a rule. This experts buffer is 1.5 times the average expected load. If tokens keep pouring in and the buffer fills up, you just drop the tokens. Wait, drop them. You delete them from the Moy layer's computation entirely. Real world models use this. Huawei's Pangu model, for
example, was observed dropping 6 to 8% of its tokens during heavy traffic. OK, I have to push back here. Dropping token sounds absolutely insane. If I ask the AIA highly specific coding question and the Python expert happens to be full because of a queue, does the model just randomly delete my semi colon or my bracket from its brain? How can it possibly generate working code if it's just throwing away 8% of my prompt? I know it is a shocking concept, but to understand why it works you have to remember the fundamental architecture of a
transformer. The Moe layer replaces the feed forward network, but running parallel to the Moe layer is the residual stream. The skip connections. Exactly, the residual stream is like a massive multi lane highway running straight through the center of the model from the first layer all the way to the last. The Moe block is just an off ramp. The token leaves the highway, gets processed by the expert, and merges back onto the highway, adding its new insights to the stream. Oh I see.
If the off ramp to the expert is closed because the buffer is full, the token doesn't disappear into the void, it just stays on the highway. Precisely, it's mathematical vector representation is passed completely unchanged to the next layer. Furthermore, the attention mechanism, which mixes information and contacts between all the tokens in the sequence, still processes every single token perfectly. So the sequence context is preserved even if the specific Moe reasoning step is skipped for that one specific token at that one specific layer.
That is incredibly resilient. The token survives, it just didn't get that specific layers expert opinion added to its vector. It is Transformers are remarkably robust to noisy or dropped internal features and to further optimize this hardware efficiency, while we meticulously keep the router in FP32 to avoid precision collapse, the actual expert GEM calculations, the massive matrices doing the heavy reasoning are aggressively pushed down to FP8 precision. Taking advantage of the Hopper
and Blackwell tensor cores. Exactly. Moving from BF16 to FP8 halves the memory footprint of the mass of experts, and it double s the mathematical throughput on modern tensor cores. Because the experts are just doing dense feature transformations, they are surprisingly resilient to the lower precision, provided your router remains accurate enough to send the tokens to the right place. It's all about putting the high precision exactly where the math is fragile, and ruthlessly cutting the precision where the math is robust. OK, we have trained this beast. The loss curves look beautiful,
but training is temporary, serving is forever. This brings us to the post training reality. How we run this model for millions of active users changes the rules of the architecture entirely. When you move to serving, your main goal is minimizing latency and cost. The first thing engineers try to do to save compute is serve a different K. Right. So if I train the model to pick the top 8 experts for every token, maybe during inference to save money on my cloud bill, I tell the router to only evaluate the top six experts. That's immediately 25% less
compute. It is, but if you remember from our earlier discussion, we applied renormalization to the weights. If you train a model at top 8, the router learns to divide the probability mass among eight different experts. If you suddenly only serve 6 experts, and you renormalize those six to some to one point O the remaining 6 experts suddenly have mathematically larger weights than they ever experienced during training. Because the denominator of the renormalization equation got smaller, the six experts are absorbing the probability mass
that used to belong to experts 7 and 8. Exactly. And because the weights are artificially larger, the output vector of the Moe layer becomes larger. This causes a massive distribution shift in the activation values. The handbook notes that when engineers tried this on a QNMOE model without careful mathematical adjustments, the perplexity, which is a measure of how confused the model is, exploded by 356%. It completely broke the model's ability to generate coherent text. So you can't just casually drop experts at serving without
recalibrating the scales? What about the parallelism itself? In training? We are doing massive batches of documents, but it's serving a user is chatting with it in real time. Serving as two distinct computational phases, prefill and decoding. Prefill is when the model reads your initial prompt. If you paste 1000 Word document into the chat, the model reads all 1000 words at once. This behaves a lot like training because it processes a large batch of tokens simultaneously. It requires low expert
parallelism because a single GPU has plenty of tokens to keep all of its experts completely busy. But decoding is different. Fundamentally different decoding is the phase where the model generates its response one single token at a time. If you only have one token and it routes to one expert, the rest of the massive GPU is basically sitting idle. To get efficiency during decoding, you need massive expert parallelism. You have to spread the experts across many GPU's, and you have to batch thousands of different
users decoding steps together to create enough traffic to keep the hardware fed. The traffic patterns are so different that DeepSeek actually provisions completely separate physical pools of GPU's. One pool is optimized and configured purely for prefill and another pool is optimized purely for decode. You are physically routing user traffic to different server racks depending on whether they are sending a prompt or waiting for a reply, and this leads into the most extreme architectural shift mentioned in the handbook,
disaggregation. To segregation is the logical extreme of optimizing Moe serving. In a standard transformer, every layer is interleaved. You have an attention block, then an FFN block, then attention, then FFN. But these two blocks have completely opposing hardware needs. Attention requires massive amounts of VRAM memory to store the KV cache. Right. The KV cache stores the key and value tensors for all the past tokens in the conversation, so the model remembers what was said. It's incredibly memory
intensive, but requires very little actual math compute. And the MO we experts are the exact opposite. They require massive compute tensor cores to do their matrix math, but they hold zero conversation states, so they don't need a KV cache at all. They are compute bound while attention is memory bound. So if you put them on the same GPU, you are always compromising. Either you run out of memory for the attention cache, or you waste compute cycles on the experts. Exactly. So modern serving frameworks like Mega Scale Infer literally disaggregate the architecture.
They tear the model apart. They put the attention mechanisms on one set of servers equipped with GPU's packed with high bandwidth memory, and they put the FFN experts on a completely separate set of servers equipped with GPU's packed with massive compute tensor cores. Wait, I need to visualize this. The physical layers of the model are separated by network cables. The attention server calculates the tokens context, then blasts the massive vector over the data center network to the expert server. The expert server does the reasoning and blasts it back
over the network to the attention server for the next. Layer. Yes. They pass micro batches of tokens back and forth across the network fabric millions of times a second. It allows you to tailor the physical hardware exactly to the specific bottleneck of the algorithm. It is an engineering marvel. That is absolutely wild. Finally, the handbook touches on a post training phase called RL Routing. This is reinforcement learning, specifically RLHF, which is how models are fine-tuned to stop acting like document predictors and start acting like helpful
chat bots. But applying RL to an Moe introduces a bizarre ghost in the machine. In RLHF you typically have two systems running simultaneously. A rolled out engine that generates text based on a prompt, and a trainer that evaluates that generated text and calculates gradients to improve the model. In a large asynchronous system, the rollout engine might be using weights that are slightly older than the trainer's weights. Because the trainer is constantly calculating updates, but it takes time to sync those massive gigabytes of updates over to the generation servers.
Exactly. Now in a dense model, this slight lag just means the probability distributions are slightly off. It's noisy, but it learns. But in an Moe it causes a physical divergent in the routing path. The rollout engine, using older weights might evaluate A token and it's router sends it to expert A. It generates a sentence. The trainer looks at that sentence, but using its slightly newer weights, it's router calculates that the token should have gone to expert B. Oh. So the trainer ends up calculating back propagation
gradients for a physical path expert B that the token never actually took during the generation. Yes, the trainer is optimizing the wrong experts based on a hallucinated trajectory. It sounds like trying to steer a race car while looking at a photograph of the road taken from 5 seconds ago. You are going to crash. How do they fix the RL routing drift? It's a severe problem that will cause RL training to mathematically collapse. The fixes detailed by the authors involve strictly enforcing consistency between the two systems. You have two choices.
Choice one. You freeze the router matrix entirely During the async RL phase. The router weights cannot update, so the routing decisions never diverge between the rollout and the trainer. But then the router can't learn from the reinforcement learning. What's choice 2? Choice 2 is you force the trainer to physically replay the exact routing decisions logged by the rollout engine. You pass a log file of the routing choices, and you explicitly override what the trainer's own router suggests, forcing it to calculate gradients for the exact path the token actually took.
You literally have to force the trainer to walk in the exact footsteps of the generator. Wow. We have covered an immense amount of ground today. We've traced the incredible chaotic journey of a token through a mixture of experts architecture. We watched it get mathematically steered by an FP32 router using AZ loss to prevent precision collapse. We saw it fly across EFA network fabric, avoiding the TCP socket trap. We saw it arrive at a dynamically balanced expert surviving group, limited caps and capacity drops by riding the residual stream highway, and
ultimately we saw it being served to users by a massive disaggregated GPU clusters passing micro batches over the wire. It is a testament to the incredible engineering happening at the frontier of AI right now. The mathematical theory of sparsity is elegant, but the sheer systems engineering required to make it a physical reality in a data center is staggering. We are pushing the absolute limits of silicon and light. Which brings me to a final provocative thought for everyone listening, think about that disaggregation we just talked about. If our serving systems are
literally forcing us to physically RIP the model apart, putting attention memory mechanisms on one set of servers, and expert reasoning on a completely different set of servers, are we witnessing the end of the traditional interleaved transformer block? For the last seven years, every model has been attention FFN, Attention FFN. Will future AI models abandoned the concept of layers entirely? Could we be moving toward a future where a model is just one giant global memory pool interacting over a network with
one giant global reasoning pool? It's something to deeply Mull over as this Moe architecture takes over the world. The physical constraints of the hardware are fundamentally reshaping the algorithmic architecture. It's a fascinating evolution, and I suspect we are only seeing the beginning of it. A huge thank you to the Hugging Face team for the incredible source material in the Ultimate MOA Training Handbook. As a reminder to our listeners, please leave your thoughts and theories in the comments below.
Visit neuralintel.org for the latest deep dives in AI and ML, and make sure you check out the show on YouTube, Apple Podcast, and Spotify. Until next time.
Can canary tokens expose hidden privacy failures across AI inference providers? Security researchers at Dragos demonstrated that several AI inference providers compromised data or failed to uphold their stated data...
What happens when an open-weights model is given a $500 cloud budget, discovers a critical bug in its own data seeding, rewrites its evaluation harness, and refactors its prompt architecture to cut inference spend - all...
Weight-space programming lets a large language model directly read and edit another neural network’s weights-without running a conventional training loop. In this Neural Intel deep dive, we unpack the MIT CSAIL research...
An imperfect monitor can teach a model to hide its reward hacks. GRAFT changes where the learning goes: route flagged updates into a forget adapter, then remove it. We examine the architecture, optimizer, anchor...
Between September 28 and October 8, 2026, researchers uncovered a rogue cloud AI agent fleet executing over 2,600 automated attempts to extract Chinese mapping data from Alibaba’s Amap. Operating out of Tencent Cloud...