productinterview.tools
MenuClose

AI Numbers: Model Memory and Compute, Estimated on the Back of an Envelope

Parameters, memory and FLOPs, estimated on the back of an envelope.

Core3 lessons5 questions

What this module covers

  • Estimating the memory a model's weights need, at different precisions
  • The two rules of thumb for compute: about 2 × parameters per token to run a model, about 6 × parameters × tokens to train one
  • A method for estimating out loud in an interview

Builds on

AI numbers: memory and compute

Why it matters, by role

  • AI Infrastructure PMProduct Manager. Decides what a product should do, for whom, and why. Read the full explanation: GPU counts, memory and cost estimates come up in almost every loop.
  • AI TPMTechnical Program Manager. Owns plans, dependencies, risks and delivery for large cross-team programmes. Read the full explanation: compute and capacity planning are core to the role.
  • Model PM: you'll reason about model size and training cost trade-offs.
  • AI Platform PM: pricing and capacity questions start here.

Lessons

  1. How much memory a model needs
  2. Compute for inference and training
  3. A back-of-envelope method

How much memory a model needs

A model's weights take parameters × bytes per parameter:

Precision Bytes per parameter 7B model 70B model
16-bit (FP16 / BF16) 2 14 GB 140 GB
8-bit 1 7 GB 70 GB
4-bit 0.5 3.5 GB 35 GB

So a 70B model at 16-bit doesn't fit on one 80 GB GPU; it needs at least two, in practice more. Lower precision (quantisation) shrinks memory, usually with some loss of quality.

Weights aren't the only memory. Serving also needs room for the KV cacheKey-value cache. Stored attention keys and values that let a model generate each new token without recomputing the whole context. Read the full explanation, which grows with context length and with the number of users served at once. Long contexts and many concurrent users can need as much memory as the weights themselves.

Compute for inference and training

Two rules of thumb cover most questions:

  • Running a model (inference): about 2 × parameters floating-point operations (FLOPs) per token. A 70B model needs about 140 billion FLOPs per token.
  • Training a model: about 6 × parameters × training tokens FLOPs.

Example: a 70B model trained on 15 trillion tokens needs about 6 × 70 × 10⁹ × 15 × 10¹² ≈ 6 × 10²⁴ FLOPs. A modern data-centre GPU does around 10¹⁵ FLOPs per second at peak; at a realistic 40% utilisation that's 4 × 10¹⁴. So training takes about 1.5 × 10¹⁰ GPU-seconds, or roughly 4 million GPU-hours. Spread across 10,000 GPUs, that's about 17 days.

These are estimates, good to within a factor of two or so, which is exactly what interviews want.

A back-of-envelope method

When asked to estimate, say your steps out loud:

  1. Restate what's being estimated and the unit (GPUs, dollars, GB).
  2. Write the formula first: memory = parameters × bytes; training compute = 6 × N × D.
  3. Plug in round numbers, and say they're assumptions.
  4. Compute in powers of ten, not long multiplication.
  5. Sanity-check against something you know ("about 4 million GPU-hours is in the range reported for models this size").
  6. Name what would change the answer: utilisation, precision, context length, traffic peaks.

The interviewer is grading your structure and your assumptions more than the final number.

Questions

Advanced

QuestionTypeRolesAsked atSource
A team wants to fine-tune a 7B model. How much GPU memory does full fine-tuning need, and what are the alternatives?estimationAI Infrastructure PM, Model PM, Forward Deployed Engineer–Representative

Rubric

Dimension Weak Passable Strong
Memory Doesn't know how to start Parameters × bytes Weights by precision, plus KV cache growth with context and users
Compute Guesses Knows one rule of thumb 2N per token and 6ND for training, applied correctly
Method Silent calculation Steps, some assumptions Formula first, stated assumptions, powers of ten, sanity check
Judgment False precision Rough answer Knows the error bars and which assumptions move the answer most

Next modules