Skip to content
Apixo
Blog
news· 3 min read· via Towards AI

Inside MoE and SwiGLU: How Modern LLMs Scale Capacity Without Compute Blowup

A look into Mixture of Experts and SwiGLU architectures, showing how models like Mixtral achieve massive capacity while keeping active per-token compute low.

Inside MoE and SwiGLU: How Modern LLMs Scale Capacity Without Compute Blowup

In standard dense Transformer models, every token passes through every parameter in the network. As model sizes scale up to increase capability, the computational cost per token scales directly alongside total parameter count. Mixture of Experts (MoE) architectures change this dynamic by splitting the feed-forward layer into multiple independent subnetworks, running only a small subset of parameters for any given token.

A prominent example of this design is Mixtral 8x7B. While its name implies 56 billion parameters, the architecture contains approximately 47 billion total parameters, with only 13 billion active during the processing of a single token. By relying on a lightweight router that selects two out of eight experts for each token, MoE models achieve the capacity of a much larger network while maintaining the runtime compute footprint of a smaller one.

The Feed-Forward Network and SwiGLU

To understand where parameters reside in a Transformer, it helps to examine the structure of an individual block. A standard block is split into attention and feed-forward network (FFN) sub-layers. While attention allows tokens to exchange contextual information, the FFN processes each token individually. In classic Transformer designs, the FFN accounts for roughly two-thirds of the total parameters in a block—scaling at 8d² weights compared to 4d² for standard multi-head attention projections.

Modern open-weight models have upgraded the classic two-matrix FFN with SwiGLU (Swish Gated Linear Unit). Instead of a single projection followed by an activation like ReLU or GELU, SwiGLU utilizes three projection matrices: W_gate, W_up, and W_down. The gating projection is multiplied element-wise with the content projection after applying a SiLU (Swish) activation function.

Because adding a second up-projection increases parameter density, model designers adjust the hidden dimension width. While a standard FFN uses a hidden width of 4d, a parameter-matched SwiGLU layer shrinks the hidden dimension to roughly 2.67d (or 8d/3). Models such as Llama, PaLM, DeepSeek, and Mixtral (which uses a slightly wider 3.5d expert width) rely on SwiGLU to improve overall output quality at identical computational budgets.

Routing Tokens to Specialized Experts

Inside an MoE layer, the monolithic FFN is replaced by N parallel expert networks, each structured as a standalone FFN. A gating mechanism, or router, evaluates the token's representation vector and determines which experts should process it.

The router functions via a learned matrix W_g of shape (d × N). By computing the dot product between the token vector and each column of W_g, the router produces score logits for every expert. The system selects the top-k scoring experts, normalizes their scores using softmax, and routes the token exclusively through those selected networks. Unselected experts remain completely idle for that token, avoiding unnecessary computation. Early research into sparsely gated MoE layers by Shazeer et al. (2017) demonstrated this form of conditional computation, which modern decoders now integrate at scale.

Routing decisions are learned end-to-end via next-token loss alongside auxiliary load-balancing losses, without explicit human-defined logic dictating expert domain assignments. Advanced architectures like DeepSeek-V2 combine these sparse MoE concepts with specialized Multi-Head Latent Attention (MLA) layers to manage both parameter capacity and memory efficiency.

What it means for developers

For engineering teams deploying artificial intelligence applications, MoE architectures present clear trade-offs between memory footprint and compute efficiency:

  • Reduced Compute per Token: MoE models drastically lower FLOPs per token compared to dense models of equivalent parameter counts, accelerating generation speed.
  • VRAM Requirements: Although active parameters per token are low, all expert weights must still reside in system or GPU memory for routing. Servicing an MoE model requires memory capacity sized for its full parameter count.
  • Routing Dynamics: Routing mechanisms require careful balance during training to prevent specific experts from becoming overloaded bottlenecks while others sit idle.

For teams building products on these architectures, developers can try top AI models cheaply through one API at https://apixoai.online to evaluate performance across dense and MoE models without managing underlying multi-GPU infrastructure.


Source: From Vanilla Transformers to Modern LLMs: The Evolution of Transformer Architecture — Part 4: Model… — Towards AI. Written by the Apixo team from that report.

#ai-news#ai#llm#transformers#mixtral#deepseek
Try it with your own tools

One key for Claude, GPT, GLM, DeepSeek and more. Pay per token with crypto.

Get your API key

Keep reading