Zenaique

Fill in the full FT memory contributions for a 7B model

Fill in blank·Hard·4.0 · 0·~1 min·Asked atIroncladNVIDIAUnity·Relevant atDatabricksMetaMicrosoft
Attempt it
For full FT of a 7B model in bf16 with standard Adam: weights take GB, gradients take GB, and Adam optimizer states (m and v in fp32) take GB: for a baseline of roughly GB before activations.
TL;DR

Weights 14 GB, gradients 14 GB, Adam states 56 GB: about 84 GB baseline before activations, which is why full FT of a 7B model needs multiple data-center GPUs.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture each of the 7 billion knobs in the model. To train it with Adam, you keep four copies of every knob. One copy is the knob itself, one is the nudge you want to apply this step, and two are running averages Adam keeps to smooth the nudges. The knob and the nudge are stored compactly at 2 bytes each, but the two averages are stored at full 4-byte precision so the math stays stable. Add it up across all 7 billion knobs and you get roughly 84 gigabytes of memory, before you even feed in any data. That is why a model that sounds small still does not fit on one gaming GPU when you train it the full way.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Memory math is a staple of senior fine-tuning interviews because it separates people who have actually trained large models from people who have only read about it. The question looks like trivia, but it tests whether you can decompose training memory into its parts and reason about which part dominates. Interviewers like it because there is a single correct number and a clean derivation, so a candidate either knows the bytes per parameter accounting or does not.

The trap is that the model weights feel like the obvious answer, and they are also the smallest of the three big terms. A 7B model is only 14 GB of weights in half precision, which would fit comfortably on a single GPU. Yet you cannot full-fine-tune it on that same GPU, and the reason is everything you have to store alongside the weights. The gap between the 14 GB intuition and the 84 GB reality is exactly what the question is designed to expose.

The disciplined approach is to assign a fixed bytes per parameter cost to each class of tensor, then multiply by the parameter count exactly once. Doing the multiply once at the end keeps the arithmetic clean and lets you swap precisions or optimizers by changing a single coefficient. This deep dive walks that arithmetic for a 7B model in the standard bf16 Adam recipe, shows why the optimizer states are the dominant term, separates the static baseline from activation memory, and connects the result to the techniques that exist specifically to shrink it.

The four things you store per parameter

Full fine-tuning with Adam keeps four tensors for every trainable parameter. There are the weights themselves, the gradients computed during the backward pass, and the two optimizer state tensors Adam maintains. Every one of these four has exactly as many elements as the model has parameters, so the only thing that varies between them is the bytes per element cost.

The weights and gradients have the same shape as the model. In a bf16 mixed-precision recipe, both are stored at 2 bytes per element. So each of these two terms costs 2 bytes per parameter. The gradient tensor is allocated in full during the backward pass, so you cannot treat it as free or transient when sizing memory.

Adam's two state tensors are the first moment, an exponential moving average of the gradient, and the second moment, an exponential moving average of the squared gradient. Both are kept in fp32 at 4 bytes each. That is 8 bytes per parameter for the optimizer alone, which is the key number people forget. The reason fp32 is used here, even in a bf16 run, is numerical stability. The second moment accumulates squared gradients that are often tiny, and storing them in half precision would let them underflow to zero, which corrupts the per-parameter learning-rate scaling that makes Adam work.

Doing the arithmetic for 7B
Why the optimizer states dominate
The master-weights subtlety
How this baseline drives real engineering choices
Where activation memory sits
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
ComponentBytes/param7B footprint
Weights (bf16)214 GB
Gradients (bf16)214 GB
Adam moments (2 x fp32)856 GB
Baseline before activations12~84 GB

Real products, models, and research that use this idea.

  • Training a Llama 3.1 8B with full FT and standard Adam overflows a single 80 GB H100, which is why teams reach for ZeRO sharding or LoRA in practice.
  • DeepSpeed ZeRO-2 shards the 56 GB of Adam states across data-parallel ranks, the exact term this arithmetic shows dominates the budget.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy are Adam's moments kept in fp32 even when the weights are bf16?
A

Think about numerical stability of the running variance estimate. The second moment accumulates tiny squared gradients, which underflow in half precision, so fp32 protects the update.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Counting only the weights and forgetting that Adam keeps two extra fp32 moments per parameter. Those optimizer states are the largest single term, four times the weight footprint.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Bytes per parameter for bf16 weights and gradients

  • Why Adam stores two separate fp32 moments

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is RLHF, and why is it used after pretraining?
MCQ·Easy