Top-2 Mixture-of-Experts Routing With Expert Capacity Limits

Last updated: November 29, 2026

Quick Overview

Given router logits for a batch of tokens over E experts, pick each token's top-2 experts with softmax-normalized weights, enforce a per-expert capacity, and report assignments, dropped token-expert pairs, and per-expert load.

Mistral AI
Coding & Algorithms
Machine Learning Engineer
Mistral AI
November 29, 2026
Machine Learning Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given router logits for a batch of tokens over E experts, pick each token's top-2 experts with softmax-normalized weights, enforce a per-expert capacity, and report assignments, dropped token-expert pairs, and per-expert load.

Mixtral models use sparse mixture-of-experts layers with top-2 routing, so Mistral AI training and inference engineers need to reason about routing and load balance. The interviewer looks for correct top-k plus renormalization, a deliberate drop policy when an expert overflows, and awareness of why balance matters for GPU utilization.

What the Interviewer Expects
  • Select top-2 experts per token with deterministic tie-breaking
  • Normalize the two weights with a numerically stable softmax over the selected logits
  • Enforce capacity with a clear priority (first choices before second choices)
  • Return load per expert and list dropped assignments
  • Discuss what happens to a fully dropped token (residual passthrough)
  • Connect to auxiliary load-balancing loss and capacity factor
Key Topics to Cover
Mixture of experts
Top-k routing
Load balancing
Capacity factor
Softmax stability
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you vectorize this on GPU without a Python loop over tokens?
  • Should weights be renormalized after a second-choice drop?
  • How do you set capacity from a capacity factor and batch size?
  • Why can inference often run dropless while training uses capacity?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input logits[T][E] and integer capacity. Each token gets up to two experts; weights come from a softmax over its two chosen logits (Mixtral style). No expert may exceed capacity tokens. Output a...

High-Level Design

Phase 1: per token, sort experts by (-logit, index) and take two; compute weights with max-subtraction softmax. Phase 2: allocate slots in two passes, all first choices in token order, then all second...


Submit Your Answer
Markdown supported

Related Questions