Mixtral of Experts
TL;DR. Mixtral 8x7B takes the Mistral 7B architecture and replaces every FFN with 8 SwiGLU experts, of which a router picks 2 per token. The model stores about 47B parameters but uses about 13B per token. With open weights under Apache 2.0, it matches or beats Llama 2 70B on most of the reported benchmarks, especially maths and code.
Why it matters now. Mixtral was the open-weights model that made MoE routine outside big labs. Many fine-tuned readers, rerankers and agents of 2024 were built on it. It is also the simplest modern MoE to reason about: no shared experts, no fine-grained split, one gating equation. Its routing analysis matters if you serve MoE models on a small cluster: experts must stay resident, and routing locality decides whether offloading is viable.
Key idea
Section titled “Key idea”For token representation and router weights , Mixtral keeps the two largest logits and takes a softmax over only those:
Here sets every other logit to , so 6 of the 8 experts get weight zero and are never run. Attention is shared across experts and uses grouped-query attention with 8 KV heads. The experts are the only sparse part.
Key results
Section titled “Key results”- Against Llama 2 70B (Table 2). Mixtral uses 13B active parameters. It scores MMLU 70.6 versus 69.9, GSM8K 74.4 versus 69.6, MATH 28.4 versus 13.8, HumanEval 40.2 versus 29.3, MBPP 60.7 versus 49.8, and NQ 30.6 versus 25.4. It is lower on HellaSwag (84.4 versus 85.4), WinoGrande (77.2 versus 80.4) and TriviaQA (71.5 versus 73.0).
- Long context (§3.2). Passkey retrieval is 100% at every tested context length and passkey position (Figure 4).
- Instruct model (§4). Trained with supervised fine-tuning and DPO, it reaches MT-Bench 8.30.
- Routing (§5, Table 5). Expert choice is similar across arXiv, PubMed and PhilPapers, with DM Mathematics slightly different. At layer 15, the first-choice expert repeats for consecutive tokens about 28% of the time, against 12.5% at random.
Limitations & open questions
Section titled “Limitations & open questions”- The paper gives few training details. Pretraining data is described only as multilingual, and token count and compute are not reported. This makes the result hard to reproduce or compare with scaling laws.
- No load-balancing loss or capacity setting is described, so how balance was achieved during training is unknown from the paper.
- Passkey retrieval is a weak long-context test. Harder suites such as RULER are a better check.
- Eight large experts give only 28 expert pairs per layer. DeepSeekMoE argues this limits specialisation.
Connections
Section titled “Connections”- Before: Switch Transformers (top-1, capacity factor, balance loss). Attention side: GQA, whose 8 KV heads keep Mixtral’s KV cache small.
- After: DeepSeekMoE (fine-grained and shared experts) and MLA (compressing the KV cache further).
- Serving: vLLM / PagedAttention. Architecture surveys: Raschka’s architecture comparison.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
Using Mixtral's configuration (dim 4096, 32 layers, SwiGLU hidden size 14336, 32 query heads, 8 KV heads, head dim 128, vocabulary 32000, 8 experts, top-2), derive the total and active parameter counts. Assume untied input and output embeddings and ignore norms and router weights. Then compute the KV-cache size per token and for one 32K-token sequence in bfloat16.
What a strong answer covers
- One SwiGLU expert has three 4096 × 14336 matrices, about 176.2M parameters. Eight experts × 32 layers gives about 45.1B.
- Attention per layer: Wq and Wo are 4096 × 4096, Wk and Wv are 4096 × 1024 (8 KV heads × 128). That is about 41.9M per layer, or 1.34B in total. Embeddings and output head add 2 × 32000 × 4096 ≈ 0.26B.
- Total ≈ 45.1 + 1.34 + 0.26 ≈ 46.7B, the paper's 47B. Active: two experts per layer gives 11.3B, plus attention and embeddings, ≈ 12.9B, the paper's 13B.
- KV cache: 2 × 8 × 128 × 32 = 65,536 elements per token, which is 128 KiB in bfloat16. A 32K-token sequence needs 32768 × 128 KiB = 4 GiB.
- Lesson: compute scales with 13B, but memory for weights scales with 47B. That is why the name 8x7B overstates the total (attention is shared, so it is not 56B).
- Mechanism
Mixtral computes its gate as a softmax over only the top-2 router logits. Show that this equals taking a full softmax over 8 experts and renormalising the top two. Compute the weights for top logits 2.0 and 1.0, and explain how the router still gets a task gradient, comparing with Switch's top-1 rule.
What a strong answer covers
- Setting the other logits to −∞ removes them from the denominator. So the weights are exp(lᵢ) divided by the sum over the two kept logits, which is exactly the renormalised full softmax.
- For logits 2.0 and 1.0: weights are e²/(e² + e) ≈ 0.731 and 0.269. Only the difference between the two logits matters.
- The task gradient reaches the router through these two weights. It can shift mass between the chosen pair, but the choice of the pair itself is not differentiable.
- With top-1 the renormalised weight would always be 1 and carry no gradient. That is why Switch scales by the un-renormalised probability instead. With top-2, renormalising is safe.
- Critique
Mixtral's routing analysis finds no clear domain experts (arXiv, PubMed and PhilPapers route alike) but strong locality: at layer 15 the same expert is first choice for consecutive tokens about 28% of the time. Derive the random baselines for the first-choice and first-or-second-choice repeat rates, and critique what this analysis can and cannot tell us about specialisation.
What a strong answer covers
- First-choice repeat under uniform independent routing is 1/8 = 12.5%. For "the next token's top-2 shares an expert with this token's top-2", the chance of no overlap is (6/8)(5/7) = 30/56, so the baseline is about 46%. The paper reports about 62–67% at layer 15.
- Locality above chance plus examples (Python "self", indentation) suggest syntactic or positional specialisation rather than topical specialisation.
- Limits: the analysis is per layer and per expert-id share. It does not measure what the expert computes, and topic signals could be spread across combinations of experts.
- Better test: ablate or swap one expert and measure the per-domain loss change, or probe expert inputs and outputs for domain information.
- Practical effect: locality means fewer expert switches between nearby tokens, which matters for expert caching and expert-parallel load.
- Design
You want to serve Mixtral 8x7B as the reader in a RAG system with 16–32K-token retrieved contexts on an academic node with two 80 GB GPUs. Plan memory and throughput. Cover weight memory, KV cache per request, the batch size you can afford, and how routing locality could be used if you had to offload experts.
What a strong answer covers
- Weights: about 47B × 2 bytes ≈ 94 GB in bfloat16, which does not fit on one 80 GB GPU. Use tensor or expert parallelism over both GPUs, or quantise the weights.
- KV cache: 128 KiB per token, so a 32K context needs 4 GiB per request. With about 60 GB free after weights you can hold roughly 15 such requests. Shorter contexts allow more.
- Compute per token is about that of a 13B dense model, so prefill of long retrieved contexts is cheap in FLOPs relative to a 70B dense model.
- Offloading: consecutive tokens often reuse experts, so an LRU cache of experts on the GPU with prefetching can hide some PCIe transfer cost. Measure the hit rate on your own RAG traffic.
- Check quality: Mixtral's 100% passkey retrieval is a weak test. Evaluate on realistic multi-document QA with distractors before relying on long context.
- Connect
Write Mixtral as a diff against Switch Transformers and against DeepSeekMoE. Cover experts per token, which layers are sparse, expert size and count, and how load is balanced. Then predict which design gets more combinations of experts per token at equal active compute.
What a strong answer covers
- Switch: top-1 of many experts, MoE in every other FFN layer, capacity factor plus the f·P auxiliary loss.
- Mixtral: top-2 of 8 large SwiGLU experts in every layer. The paper describes no balance loss and relies on Megablocks kernels and expert parallelism for serving.
- DeepSeekMoE: many small experts (fine-grained), some always-on shared experts, and expert- and device-level balance losses.
- Combinations: Mixtral has C(8,2) = 28 per layer. DeepSeekMoE-style splitting at the same active compute gives orders of magnitude more (for example C(64,8) ≈ 4.4 billion), which the DeepSeekMoE paper argues allows sharper specialisation.
- Research idea
An IR idea: use a token's per-layer expert choices as a free sparse signature of a document, and retrieve by overlap of routing histograms. Given Mixtral's routing findings, predict how well this would work, and design the experiment that would test it.
What a strong answer covers
- Prediction: weak for topical retrieval, because routing looked similar across arXiv, PubMed and PhilPapers and tracked syntax more than topic.
- It might capture style, code versus prose, or language, which could help routing queries between collections rather than ranking documents.
- Experiment: build routing histograms per layer for BEIR documents and queries. Compare nDCG@10 with BM25 and with a mean-pooled hidden-state baseline. Test which layers carry the most signal.
- Control for frequency effects by normalising histograms (for example tf-idf over experts) and check whether learned fine-grained experts (DeepSeekMoE) do better than Mixtral's 8.