arXiv(opens in a new tab)cs.LGSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.35751

How to Loop MoE: Flatten the Experts, Untie the Attention

Shouren Wang, Chuang Ma, Mohsen Hariri, Debargha Ganguly, Wang Yang, Xiaoqing Tong, Qianying Liu, Xiaotian Han, Vipin Chaudhary

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Looped Transformers reuse one block of layers several times: by spending extra computation they push a model of fixed size further, and so use its parameters more fully; while sparse mixture-of-experts (MoE) models activate only a few of many experts for each token. Looped MoE bridges these two design philosophies and gives MoE models new potential for better expert usage, but it raises a question: how to loop a MoE? We answer it with Foil. With the expert parameters and the expert compute per token held fixed, Foil (1) flattens the experts, halving the expert layers, doubling the experts per layer and doubling the passes, so that every routing decision chooses from a larger pool, and (2) unties the attention, giving each pass its own attention parameters while the experts and routers stay shared. Experiments show that Foil clearly outperforms the unflattened looped baseline: at 20B tokens every Foil model has lower pretraining loss than the baseline; at 100B tokens the loss improves monotonically with the degree of flattening, the most flattened Foil ending 0.012 nat below the baseline at equal parameters and compute, with downstream accuracy on par or better; untying the attention also yields more balanced and more confident routing at equal shape. Our ablations analyse why Foil works and turn the findings into design guidance for looped MoE: the returns of looping and of widening the expert layers amplify each other, routing confidence tracks healthy expert use better than load balance, and a sparse looped MoE should therefore use more experts per layer and more passes. Code and configurations are available at https://github.com/SR-A-W/how-to-loop-moe.

Figure

Figure 1: Motivation of designing Foil. Left: why loop a sparse MoE. (1) At equal parameters, looping lowers the loss, and matches non-looped models with much less parameters; (2) Tokens reaches more distinct experts the more passes it makes. Right: Foil's design. (1) Flattens the experts, (2) Unties the attention. (3) Loops more times, (4) Keep parameters and compute unchanged.

1 INTRODUCTION

Looped models apply one block of Transformer layers repeatedly to an evolving hidden state, so that the depth of computation is set by the number of passes rather than by the number of stored layers (Dehghani et al., 2019). A model of fixed size can thus be made stronger by computing more, which uses its parameters more fully: both theory and experiments show that looped Transformers suit computations that need many iterative steps (Giannou et al., 2023; Saunshi et al., 2025), and looping has recently been scaled to large pretraining runs and to spending more computation at inference time (Geiping et al., 2025; Zhu et al., 2025). As hardware compute grows far faster than memory capacity and bandwidth (Gholami et al., 2024), trading computation for stored parameters is increasingly attractive, and how best to loop a model has become an active question (Prairie et al., 2026; Huang et al., 2026).

Sparse mixture-of-experts (MoE) models take a different route to efficiency: each layer holds many experts, but every token is routed to only a few of them, so that the parameter count far exceeds the computation per token; current large models hold hundreds of experts per layer and route each token to only a few (DeepSeek-AI, 2024; Kimi Team, 2025). The price is that a token sees only k experts in each layer, and the more experts there are, the less often each of them is used. Whether the experts are actually used, and whether they specialise, has been a central question since the first sparse MoE models (Fedus et al., 2022; Zoph et al., 2022), and a balanced load alone does not answer it (Li et al., 2026).

These two design philosophies are, however, naturally compatible. A routing decision exposes a token to only a few of the available experts; looping changes this: every pass gives the token a new routing decision in the same layer, so it can reach different experts, and different combinations of them, without storing any additional expert parameters. Our measurements make this potential concrete in three observations. (1) Looping brings better performance or fewer parameters. At equal parameters, looping twice lowers the loss by 0.064 nat, and a looped model with far fewer parameters nearly matches a non-looped model with twice the layers by spending more computation per token (Figure 1, top). (2) Looping lets a sparse MoE use more of its experts. The number of distinct experts a token reaches grows with the passes, from 16 without looping to 36 with eight passes (Figure 1, bottom). (3) Looping unlocks equivalent-parameter properties for MoE. Because experts are called repeatedly, the equivalent number of experts and the number of possible routing combinations grow multiplicatively as the looped block is flattened, while the real experts and the compute stay fixed.

Earlier work has combined looping with experts (Csordás et al., 2024; Chen et al., 2026b; Jaggi, 2026; Li et al., 2025), but none has studied how the experts should be distributed over the looped block—how many experts a layer holds, how many layers the block has and how many times it is looped—when the expert parameters and the compute are fixed. Nor has it been asked which parameters a pass should own: with attention shared across passes, flattening discards the attention parameters of the layers it removes, whereas giving each pass its own attention keeps the parameter budget and lets successive passes process the shared experts' inputs differently, at no extra compute. This raises our question: how to loop a MoE when its parameters and compute are fixed? We answer it with Foil. Foil (1) flattens the experts, scaling down the number of layers in the looped block while scaling up the experts per layer and the number of passes in proportion, so that every routing decision chooses from a larger pool, and (2) unties the attention, giving each pass its own attention parameters while the experts and routers stay shared across passes. Our contributions are:

• We propose Foil, which flattens the experts and unties the attention of a looped MoE while holding the parameters and the compute per token fixed (Section 2).

• We validate Foil in 20B-token pretraining and 100B-token continued training: it clearly lowers the pretraining loss of the unflattened baseline, matches or exceeds it downstream, and untying the attention yields healthier routing than tying it at the same shape (Section 3).

• Through systematic ablations we characterise several phenomena of looped MoE and distil a design suggestion: a sparse looped MoE should use appropriately more experts per layer and more passes (Section 4).

Figure

Figure 2: Vanilla looped MoE versus Foil. Both models share the same skeleton: a prelude (embedding and one regular MoE layer), a recurrent core applied for several passes, and a coda (one regular MoE layer and the LM head). The vanilla core ties both attention and experts across passes. Foil flattens the core—it keeps the total number of experts fixed while using fewer layers, more experts per layer and more passes—and unties the attention: the experts are shared across passes, but every pass has its own attention set, selected by the pass index. Both models call the same number of experts per token. When the core has several layers, every layer carries one attention set per pass; the ellipsis marks the remaining sets. Red: attention; blue: experts.

References (71)