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
Machine Learning
Machine Learning Engineer
Meta
November 29, 2026
Machine Learning Engineer
Onsite
Machine Learning
Hard

0

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
FSDP
mixed precision
memory estimation
activation checkpointing
distributed training
PyTorch
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. 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 Prep
Sample 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....


Submit Your Answer
Markdown supported