Design a large-scale MoE pretraining pipeline
I was asked this
No reports yet. Sign in to say where you were asked it.
An AI/ML design interview question asked in Meta's AI/ML design round, last asked Sep 2025. It tests mixture of experts, distributed training and llm.
Design a large-scale pretraining pipeline for a bilingual mixture-of-experts (MoE) language model, trained on about 1 trillion tokens across 256 A100-80GB GPUs. Cover the model, the parallelism plan, routing and load balancing, data, fault tolerance and monitoring, and then explain how you would scale the same system to 1,024 GPUs while keeping cost under control.
Requirements
- Functional: the model architecture: number of experts, the gating and routing strategy, top-k selection.
- Functional: the parallelism plan across data, tensor, pipeline and expert parallelism, and the communication patterns (all-to-all for expert dispatch).
- Functional: capacity factor and token dropping policy, and load-balancing or auxiliary losses.
- Functional: memory and optimizer sharding (FSDP or ZeRO), checkpointing and recovery from failures.
- Functional: dataset curation and deduplication for two languages, tokenization, the training schedule and hyperparameters.
- Non-functional: high model FLOPs utilization, stable training, and a predictable cost and schedule.
Clarifying questions
- What is the target size: total parameters and active parameters per token?
- What is the language mix, and how much data per language is available?
- What is the interconnect inside and between nodes (NVLink, InfiniBand bandwidth)?
- What is the deadline and budget, and what evaluations define success?
What a strong answer covers
- Sizing that matches the hardware: active parameters and tokens against the FLOPs budget of 256 A100s, and memory per GPU for parameters, optimizer state and activations.
- Expert parallelism placed inside a node where possible so all-to-all uses NVLink, combined with data parallelism (and tensor or pipeline parallelism only if the dense layers need it).
- Routing: top-1 or top-2 gating, capacity factor around 1.0 to 1.25, what happens to dropped tokens, and an auxiliary balancing loss or a bias-based balancing method.
- Failure modes and fixes: router collapse (balancing loss, router z-loss, noise), expert overload and stragglers, loss spikes (gradient clipping, lower learning rate, restarting from a checkpoint).
- Data: language mix and sampling, deduplication (exact and near-duplicate), quality filtering, a tokenizer trained on both languages.
- Asynchronous sharded checkpoints, automatic restart on node failure, and spare nodes.
- Monitoring: tokens per second, step time, MFU, expert load per layer, loss per language, and periodic evaluations.
- Scaling to 1,024 GPUs: more data parallelism or more experts, the batch size and learning-rate changes that come with it, communication overlap, and where the cost goes.
Follow-ups
- One expert gets 40% of the tokens in layer 12. What do you do mid-run?
- The loss in one language plateaus while the other improves. What do you change?
- Going from 256 to 1,024 GPUs, step time improves only 2.5 times. Where do you look?
Where it's asked
- Meta · AI/ML design · Last asked Sep 2025ML system design
What it tests
mixture of experts · distributed training · llm
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
