Estimate GPU Memory and Choose Sharding to Train a 7B Model
Last updated: November 29, 2026
Quick Overview
Estimate the GPU memory needed to pretrain a 7B parameter transformer with Adam in mixed precision, and explain how data parallelism, FSDP, and activation checkpointing change where that memory lives.
Meta
November 29, 20260
0
0 solved
Estimate the GPU memory needed to pretrain a 7B parameter transformer with Adam in mixed precision, and explain how data parallelism, FSDP, and activation checkpointing change where that memory lives.
Meta develops PyTorch and FSDP, and training infrastructure interviews expect solid memory accounting. The interviewer checks bytes per parameter, activation memory scaling, and the communication cost of each strategy.
What the Interviewer Expects
- Break down bytes per parameter for weights, gradients, master weights, and optimizer states
- Estimate activation memory and how it scales with sequence length and batch size
- Explain plain data parallel, ZeRO stages, and FSDP full sharding
- Explain activation checkpointing and its compute cost
- Mention when tensor or pipeline parallelism is also needed
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- What does FSDP communicate in the forward and backward passes?
- How does the memory picture change with an 8-bit optimizer?
- When would you choose hybrid sharding within a node and replication across nodes?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Model: 7B parameters, 32 layers, hidden size 4096, sequence length 4096. Optimizer: AdamW. Precision: bf16 compute with fp32 master weights. Hardware: 80 GB GPUs....
Approach
Count model states (scale with parameters) and activations (scale with tokens per GPU) separately, then see which strategy fits each....