1 00:00:01,000 --> 00:00:09,300 [Hal Turing] Alrighty! Thanks for tuning in! Hello AI world! I am your host, Hal Turing, and my co-host is Dr. Ada Shannon. 2 00:00:09,300 --> 00:00:32,700 [Hal Turing] Today's paper is "Mixture of A Million Experts" by Xu Owen He at Google DeepMind. It's a single-author paper, posted to arXiv on the fourth of July, 2024. The claim is in the title. Can a learned router pick among more than a million experts, each one a single neuron, and still beat dense layers and ordinary mixture-of-experts at the same training compute? 3 00:00:32,700 --> 00:00:50,550 [Dr. Ada Shannon] The question has two halves, and the hard part is the router. Usual MoE routers stop at around a hundred experts. This one reaches a million with sublinear routing cost. The open question is whether the FLOP savings survive contact with real hardware. We'll come back to that tension. 4 00:00:50,550 --> 00:00:54,525 [Hal Turing] Start with why the feedforward layer is the target. 5 00:00:54,525 --> 00:01:12,400 [Dr. Ada Shannon] The feedforward layer is the two-matrix MLP in every transformer block. The paper says it holds about two-thirds of the parameters, and its compute and activation memory grow linearly with width. So a bigger dense model makes you pay for every parameter on every token. 6 00:01:12,400 --> 00:01:15,400 [Hal Turing] And mixture-of-experts breaks that link? 7 00:01:15,400 --> 00:01:31,425 [Dr. Ada Shannon] Yes. You replace one big feedforward layer with many smaller feedforward experts, plus a router. Each token activates only a few. Total parameters scale with the number of experts. Per-token compute scales only with how many you activate. 8 00:01:31,425 --> 00:01:33,750 [Hal Turing] How does the router choose? 9 00:01:33,750 --> 00:02:00,825 [Dr. Ada Shannon] Two main ways. In token-choice routing, each token picks its top experts. In expert-choice routing, from Zhou and colleagues at Google in 2022, each expert picks its top tokens, which fixes load imbalance. Either way you score every expert against every token and take a top-k. So routing cost grows at least linearly with the number of experts, and in practice that stops around 128. This paper's MoE baseline is expert-choice with 128 experts. 10 00:02:00,825 --> 00:02:07,150 [Hal Turing] Couldn't you skip the scoring with a hash? Just assign tokens to experts by a fixed function. 11 00:02:07,150 --> 00:02:28,300 [Dr. Ada Shannon] Hash routers do scale, with work from Roller and colleagues and from dos Santos and colleagues. But they're fixed, so nothing learns which expert suits which token. Clark and colleagues at DeepMind, in "Unified Scaling Laws for Routed Language Models" in 2022, and Dikkala and colleagues in 2023, argue that learned routers win. This paper wants a router that is both learned and cheap. 12 00:02:28,300 --> 00:02:32,750 [Hal Turing] Why would you want a million experts instead of a hundred? 13 00:02:32,750 --> 00:02:56,474 [Dr. Ada Shannon] The motivation is a scaling law. Krajewski and colleagues, in "Scaling Laws for Fine-Grained Mixture of Experts" in 2024, define granularity as the dense feedforward width divided by the expert width. Higher granularity means smaller experts, with more of them active so compute stays fixed. They found that loss falls as granularity rises. They also found that Clark's earlier plateau came from holding the training token count fixed, not from MoE itself. 14 00:02:56,474 --> 00:03:00,799 [Hal Turing] So the extrapolation is to keep shrinking the experts. 15 00:03:00,799 --> 00:03:22,449 [Dr. Ada Shannon] Right, and this paper takes it to the limit, single-neuron experts. One caveat on the bookkeeping: Krajewski's granularity is that width ratio. This paper restates it as active parameters over expert parameters, which with one-neuron experts becomes heads times experts per head. That's a redefinition, and the law is being extrapolated far past where it was fitted. Part of the critique later comes back to it. 16 00:03:22,449 --> 00:03:26,449 [Hal Turing] Now the retrieval trick. It comes from product keys? 17 00:03:26,449 --> 00:03:55,549 [Dr. Ada Shannon] Product Key Memory, from Lample, Sablayrolles, Ranzato, Denoyer and Jégou at Facebook AI Research, NeurIPS 2019, in "Large Memory Layers with Product Keys". Picture a huge table of key-value slots. Searching all N keys per query is too slow. So the keys are built as a Cartesian product of two small sets of half-dimension sub-keys, each of size root N. You search each set separately, then combine the winners. Cost drops from N times the dimension to roughly root N plus k squared, times the dimension. 18 00:03:55,549 --> 00:03:58,649 [Hal Turing] What does a slot hold in that memory? 19 00:03:58,649 --> 00:04:08,249 [Dr. Ada Shannon] A fixed value vector. It can't depend on the input beyond the retrieval weight. Keep that in mind, because it's exactly what this paper changes. 20 00:04:08,249 --> 00:04:12,599 [Hal Turing] Is there a way to think about the router as something familiar? 21 00:04:12,599 --> 00:04:33,449 [Dr. Ada Shannon] The paper uses Kraska and colleagues' 2018 idea of learned index structures, where a learned model replaces a hand-built lookup structure. Here the query network learns which keys to hit. The boundary is that the product-key hierarchy is fixed. Only the keys and queries are learned. The paper claims this is the first learned index shown routing to over a million experts. 22 00:04:33,449 --> 00:04:35,925 [Hal Turing] And the link to neurons? 23 00:04:35,925 --> 00:04:55,824 [Dr. Ada Shannon] Geva, Schuster, Berant and Levy, EMNLP 2021, "Transformer Feed-Forward Layers Are Key-Value Memories". Each hidden neuron has an input row, the key, and an output row, the value. So a feedforward layer already acts like a soft lookup over memory slots. Retrieving individual neurons is that view taken literally. 24 00:04:55,824 --> 00:04:59,849 [Hal Turing] The abstract also mentions lifelong learning. 25 00:04:59,849 --> 00:05:13,774 [Dr. Ada Shannon] As motivation only. The argument is that you could keep adding experts and freeze old ones, so the model keeps learning without forgetting. It's a design argument, and the paper runs no lifelong-learning experiment. 26 00:05:13,774 --> 00:05:18,625 [Hal Turing] One more definition before we get into the layer: isoFLOP. 27 00:05:18,625 --> 00:05:41,125 [Dr. Ada Shannon] You fix a total training compute budget. Then you vary model size, and with it the number of training tokens, along that budget. You plot final validation perplexity against model size. Lower perplexity is better. Each method's best point is its compute-optimal model. The axis is FLOPs, not wall-clock time, and that gap is the tension I mentioned. Scattered lookups into a million-entry table are not the large matrix multiplies that hardware likes. 28 00:05:41,125 --> 00:05:47,675 [Hal Turing] So with the yardstick set, walk me through one PEER layer. A token comes in. What happens? 29 00:05:47,675 --> 00:06:08,550 [Dr. Ada Shannon] A small query network turns the token's hidden state into a query vector. That query gets compared against a table of about a million keys. But it never scores all million. The keys are built as pairs, one sub-key from a set of 1,024 and another from a second set of 1,024. The query is split in half, and each half is scored against only its own 1,024 sub-keys. 30 00:06:08,550 --> 00:06:13,125 [Hal Turing] So that's two thousand-ish dot products instead of a million. 31 00:06:13,125 --> 00:06:26,699 [Dr. Ada Shannon] Yes. Keep the top k from each half, then form every pairing of those survivors. That's k squared candidates. A pair's score is just the sum of its two half-scores, so you score those candidates and take the top k again. 32 00:06:26,699 --> 00:06:30,425 [Hal Turing] What if the true best key had a half that got cut? 33 00:06:30,425 --> 00:06:48,675 [Dr. Ada Shannon] It can't happen, and the paper says the top k are guaranteed to be in the candidate set. Suppose a key's first half ranks below k other first halves. Then each of those k halves, paired with the same second half, beats it. So that key can't be in the true top k. The router is exact, not approximate. 34 00:06:48,675 --> 00:06:51,324 [Hal Turing] Then what are the experts it picks? 35 00:06:51,324 --> 00:07:08,724 [Dr. Ada Shannon] Each expert is a single hidden neuron. One input vector u, one output vector v. The expert computes an activation of u dotted with x, then scales v by that number. The selected experts' outputs are weighted by softmax of their router scores and summed. 36 00:07:08,724 --> 00:07:14,874 [Hal Turing] Which is the Geva key-value picture again. A neuron is a slot, and you pick slots. 37 00:07:14,874 --> 00:07:33,249 [Dr. Ada Shannon] Right. And one query isn't enough, so there are h independent query networks, eight here. Each retrieves its own k experts, sixteen here, from the same shared pool. With k equal to one, eight heads give you an ordinary eight-neuron MLP, assembled on the fly from rows in a giant table. 38 00:07:33,249 --> 00:07:36,999 [Hal Turing] So why single neurons? Why not small groups? 39 00:07:36,999 --> 00:07:59,074 [Dr. Ada Shannon] The scaling law, in Krajewski's form, wants total parameters and granularity up without raising active parameters. The way to get both is smaller experts and more of them. A single neuron is the smallest possible expert, so granularity becomes h times k, which is 128. Since the pool is shared, one neuron can serve many heads and many tokens. In a coarse MoE a neuron belongs to exactly one expert. 40 00:07:59,074 --> 00:08:05,074 [Hal Turing] What does 128 active neurons cost per token, in memory terms? 41 00:08:05,074 --> 00:08:21,549 [Dr. Ada Shannon] 256 gathered rows, a u and a v for each, each one model-dimension wide. The forward pass is two embedding lookups and two einsums. The author says an efficient version may need specialized kernels. That sentence will matter later. 42 00:08:21,549 --> 00:08:23,549 [Hal Turing] Now the experiment. 43 00:08:23,549 --> 00:08:55,824 [Dr. Ada Shannon] Language modeling on C4, batch 128, sequence length 2048, two budgets, 6e18 and 2e19 FLOPs. Dense models vary in layers, heads and width. The sparse variants take each dense model and replace only the feedforward layer in the middle block, block six of twelve. The coarse MoE is expert-choice with 128 full-size experts. The product key memory baseline has about a million memories, eight heads, top 32, with query BatchNorm. PEER has the same million, eight heads, top 16. 44 00:08:55,824 --> 00:08:57,549 [Hal Turing] And the result? 45 00:08:57,549 --> 00:09:18,224 [Dr. Ada Shannon] PEER has the lowest perplexity on every dataset at both budgets. Perplexity is lower-is-better. At the smaller budget on C4 it's 20.63 against 23.84 for dense, about 13 percent lower. It's also roughly 0.8 points under the coarse MoE. One caveat from the start: each cell is a single run, with no seeds or error bars. 46 00:09:18,224 --> 00:09:24,374 [Hal Turing] The product key memory baseline matters most to me. It uses the same retrieval. 47 00:09:24,374 --> 00:09:43,449 [Dr. Ada Shannon] And PEER beats it on every dataset. The gap is clearest on the Pile at the smaller budget, 20.49 against 19.01. The only difference is what gets retrieved. PKM fetches a fixed vector. PEER fetches a small function of the input, a neuron that looks at x before deciding what to write. 48 00:09:43,449 --> 00:09:47,174 [Hal Turing] So is the novelty the router or the expert? 49 00:09:47,174 --> 00:10:05,149 [Dr. Ada Shannon] Mostly the expert. The router is borrowed from Lample's 2019 work, and the paper says so. What's new is pairing it with input-dependent neurons. The experiment can't fully separate that from the k difference, 16 versus 32, so I'd say the result supports the pairing, not any one piece. 50 00:10:05,149 --> 00:10:07,324 [Hal Turing] What about the ablations? 51 00:10:07,324 --> 00:10:26,799 [Dr. Ada Shannon] Two. Shrink the pool from a million down to about 16 thousand experts with the active count fixed, and the curve slides toward the dense model. More experts helps. Then vary active experts from 32 to 512. More is generally better, and the best head count grows with it. But gains saturate while device memory climbs. 52 00:10:26,799 --> 00:10:31,750 [Hal Turing] And the worry that a million-way router collapses onto a handful? 53 00:10:31,750 --> 00:10:53,000 [Dr. Ada Shannon] On the C4 validation set, 99.8 percent of experts were selected at least once without BatchNorm, 100 percent with it. BatchNorm on the query network cuts unevenness, a divergence from uniform use, from 1.52 to 1.06. Perplexity moves only from 20.73 to 20.64, and the paper itself calls the isoFLOP difference not significant. 54 00:10:53,000 --> 00:10:58,125 [Hal Turing] So no dead table. But selected once isn't selected usefully. 55 00:10:58,125 --> 00:11:06,000 [Dr. Ada Shannon] Exactly. Unevenness also grows with pool size, so the router isn't perfectly balanced. It just isn't collapsed. 56 00:11:06,000 --> 00:11:14,000 [Hal Turing] Let's put the claim under load. Everything so far was one sparse layer. What happens when you leave the middle block? 57 00:11:14,000 --> 00:11:33,850 [Dr. Ada Shannon] Nobody knows. In every sparse variant, MoE, PKM and PEER, only the feedforward layer in block six of twelve was swapped. Every other layer stayed dense. Production MoEs put sparse layers in every block or every other block. So we don't know whether the advantage holds, grows or shrinks when routers are stacked, or how they interact. 58 00:11:33,850 --> 00:11:36,300 [Hal Turing] Is there any hint at all? 59 00:11:36,300 --> 00:11:56,975 [Dr. Ada Shannon] One, and it's weak. On C4, PEER's lead over the dense model shrinks from about thirteen percent at the smaller budget to about ten percent at the larger one. Also, the coarse MoE is worse than dense on Lambada at the larger budget. Two budgets are not a trend, and the larger model changes how much of the network the one sparse layer covers. But the direction is what you'd worry about at production scale. 60 00:11:56,975 --> 00:12:01,225 [Hal Turing] Fine. Now the axis. Everything is measured in FLOPs. 61 00:12:01,225 --> 00:12:21,274 [Dr. Ada Shannon] And that's the biggest gap. Those 256 gathered rows per token are scattered, irregular reads, bound by memory bandwidth. Dense feedforward layers and expert-choice MoE are large matrix multiplies, which hardware runs close to peak. The paper reports no throughput, latency, utilization or memory traffic. 62 00:12:21,274 --> 00:12:28,000 [Hal Turing] So the superior compute-performance trade-off might not survive conversion to TPU time. 63 00:12:28,000 --> 00:12:42,524 [Dr. Ada Shannon] It might or might not. The paper can't say. And a table of a million experts has to be stored and sharded, which affects device memory and communication. The paper itself says more active experts may need more devices. 64 00:12:42,524 --> 00:12:49,600 [Hal Turing] What about the baseline? A 128-expert MoE seems a long way from a million. 65 00:12:49,600 --> 00:13:08,575 [Dr. Ada Shannon] That's my main objection. The scaling-law paper says the gain comes from granularity. The fair opponent is a fine-grained MoE, with many small experts at higher granularity. It was never run. So PEER's win could come from granularity alone, not from the million-expert pool or the product-key router. 66 00:13:08,575 --> 00:13:12,325 [Hal Turing] And the granularity definition changed too. 67 00:13:12,325 --> 00:13:28,350 [Dr. Ada Shannon] Right. The original G is dense width over expert width. Here it's hk. The law is never refit for PEER. So "supported by the scaling law" is qualitative. The ablation with more active experts is consistent with it, but it doesn't test it. 68 00:13:28,350 --> 00:13:34,225 [Hal Turing] Is the gain from the million experts, or just from having a huge parameter count? 69 00:13:34,225 --> 00:13:51,524 [Dr. Ada Shannon] The ablation can't separate those. Growing the pool also grows total parameters, and the dense, MoE, PKM and PEER models differ in total parameters at equal FLOPs. A cleaner control would hold total parameters fixed while varying expert size. 70 00:13:51,524 --> 00:13:55,500 [Hal Turing] Then there's the evidence type. Only perplexity. 71 00:13:55,500 --> 00:14:11,149 [Dr. Ada Shannon] Perplexity on C4-trained models, no downstream tasks, no seeds, no error bars. The paper itself calls the BatchNorm difference not significant. So the win is a measured perplexity gap, not a demonstrated capability gain. 72 00:14:11,149 --> 00:14:14,775 [Hal Turing] And lifelong learning, the second motivation. 73 00:14:14,775 --> 00:14:34,325 [Dr. Ada Shannon] Untested. No experiment adds experts, freezes them, or measures forgetting. And since neurons are shared across experts and heads, freezing may not be as clean as in a coarse MoE. Chen and colleagues' 2023 work on lifelong MoE is the motivating reference, but that's a hypothesis for future work here. 74 00:14:34,325 --> 00:14:37,025 [Hal Turing] So what's actually established? 75 00:14:37,025 --> 00:15:04,051 [Dr. Ada Shannon] A learned, sublinear router can reach about a million experts, and nearly all get used. The step beyond product-key memory is making each retrieved item a tiny input-dependent function. Nobody should swap production layers on this evidence. The useful next experiments are PEER in many layers, fused gather kernels with wall-clock numbers, fine-grained MoE baselines with a refit scaling law, and a real continual-learning test. The author's own idea of retrieving adapters is also worth trying. 76 00:15:04,051 --> 00:15:06,301 [Hal Turing] So what do we take away? 77 00:15:06,301 --> 00:15:26,801 [Dr. Ada Shannon] A learned router can reach about a million single-neuron experts, nearly all get used, and one swapped layer beats dense, coarse MoE and product-key memory on FLOP-matched perplexity. The boundary is that it's one layer, two small budgets, measured in FLOPs rather than time, with no fine-grained MoE comparison and no lifelong-learning test. 78 00:15:26,801 --> 00:15:30,176 [Hal Turing] Thanks for listening, everyone. Goodbye!