AI Infra Interviews logo
Napkin Math, Cost & Capacity / 08
mediumNewDatabricksAnyscale

How much memory does it take to fine-tune a 70B model, full fine-tuning versus LoRA?

Sixteen bytes per parameter is 1.1 TB of static state before a single activation; LoRA keeps the 141 GB of frozen weights and shrinks the rest to a few gigabytes. The derivation, the GPU counts, and the activations that both still pay.

Updated Sep 2026 · Grounded in real AI infrastructure interview loops and written to a senior-engineer editorial bar, with every number worked and every diagram hand-built.

TL;DR: Full fine-tuning with mixed-precision Adam holds 16 bytes per parameter (bf16 weights 2, bf16 gradients 2, fp32 master 4, two fp32 Adam moments 8): 70.6e9 × 16 ≈ 1.13 TB of static state, at least 18 H100s sharded before activations. LoRA freezes the 141 GB of bf16 weights and trains adapters of tens of millions of parameters, so the trainable state drops to a few gigabytes and the job fits on one node, with activations now the largest term.

How to approach it

Ask which optimizer and precision (mixed-precision AdamW is the default), and whether the question is static state or the peak including activations. Start with the per-parameter byte count and decompose it out loud, because that decomposition is what the interviewer is scoring. Multiply, compare to a node, and then redo the sum for LoRA by separating frozen from trainable parameters. Close by saying what LoRA does not remove: the weights and the activations.

A strong answer

A typical situation: a team plans a fine-tune on the two cards that already hold the model for inference, and discovers that training state is eight times the weights. The optimizer, not the model, is what does not fit.

Training state per parameter for mixed-precision Adam:

bf16 weights            2 B   (the copy the forward and backward use)
bf16 gradients          2 B
fp32 master weights     4 B   (the precise copy the optimizer updates)
fp32 Adam first moment  4 B
fp32 Adam second moment 4 B
total                  16 B per trainable parameter

full fine-tune of Llama 3.1 70B:
  static state = 70.6e9 × 16 = 1.13e12 B ≈ 1.13 TB

GPUs to hold it when fully sharded (FSDP / ZeRO-3), 80% of 80 GB usable:
  1.13e12 ÷ (80e9 × 0.8) = 1.13e12 ÷ 64e9 ≈ 17.7 → 18 H100s minimum, so 3 nodes (24 cards)
  in practice 4 nodes (32 cards), because activations come on top

sanity: 1.13 TB is eight times the 141 GB serving footprint, and more than a full 8-card node
        holds (640 GB), so full fine-tuning a 70B is never a single-node job in bf16 Adam.

Now LoRA. The base weights are frozen, so they need no gradients, no master copy and no optimizer moments; they sit in memory at 2 bytes each and are read in the forward and backward passes. The trainable parameters are the low-rank adapters, A (d × r) and B (r × d) on each targeted matrix. For rank 16 on the attention and MLP projections of an 80-layer model the adapter count comes to tens of millions:

LoRA, rank r = 16, applied to q, k, v, o and the three MLP matrices in every layer
  per matrix: r × (d_in + d_out); for an 8192 × 8192 projection: 16 × 16,384 = 262k
  MLP matrices are 8192 × 28,672: 16 × 36,864 = 590k each
  k and v project to 1,024 (8 KV heads × 128): 16 × (8,192 + 1,024) = 147k each
  per layer ≈ 2 × 262k + 2 × 147k + 3 × 590k ≈ 2.6M
  80 layers ≈ 207M → call it 100M to 250M depending on targets and rank

trainable state = adapters × 16 B = 200e6 × 16 = 3.2 GB
frozen weights  = 70.6e9 × 2 B = 141 GB
static total    ≈ 145 GB

sanity: 145 GB is one eighth of the full fine-tune's 1.13 TB, and fits on a single 8-card node
        with 400 GB left for activations, or on 2 × H200 with fp8 base weights.

What LoRA does not change is the activation memory, which for both methods is proportional to batch × sequence × hidden × layers and, at 8k sequences on a 70B, is tens of gigabytes per sequence without checkpointing. With gradient checkpointing (recompute activations in the backward pass) that drops by roughly an order of magnitude, and it is standard for both full and LoRA fine-tunes. So a LoRA job on one node is usually activation-bound: the batch size is what the leftover 400 GB will hold, not the adapters.

methodstatic stateminimum cards (80 GB, 80% usable)what limits batch
full, bf16 Adam1.13 TB18 (plan 32)activations after sharding
full, 8-bit Adam (moments at 1 B each)70.6e9 × 10 = 706 GB12 (plan 16)same
LoRA r=16, bf16 base145 GB3 (plan 8)activations
QLoRA, int4 base35 + 3 GB1activations, dequant overhead
STATIC TRAINING STATE FOR A 70B, BEFORE ACTIVATIONS weights 141 GB grads 141 fp32 master + Adam moments 848 GB full fine-tune 1.13 TB frozen weights 141 GB LoRA ≈ 147 GB The optimizer is 12 of the 16 bytes. Freezing the base does not shrink the weights, it deletes the other 12. 18 H100s minimum against 2, which is the whole reason small teams fine-tune with adapters.

The reversal condition, and the decision: full fine-tuning when the task needs the whole model to move (a new language, a large domain shift, continued pretraining) and the budget has 32 H100s for the duration; LoRA when the data is thousands to hundreds of thousands of examples and the change is behavioral, which is the common case and runs on one node. The reversal is quality: if a LoRA run plateaus below the target and rank increases do not help, the remaining lever is full fine-tuning, and the memory jumps by 8x. Model Memory Footprint is the static half of this, and nvidia-smi --query-gpu=memory.used after the first step is the check that the estimate held. Activation Checkpointing is the lever that moves the activation half of the bill.

What interviewers probe next

  • "Why fp32 master weights?" bf16 has 8 bits of mantissa; a learning rate times a gradient is often smaller than the weight's bf16 resolution and would round to no update. The fp32 copy accumulates the small steps.
  • "Can you drop the master copy?" Pure bf16 Adam with stochastic rounding or Kahan summation exists and saves 4 B per parameter; it is a numerics risk to be validated, not a default.
  • "Where do activations go in the LoRA case?" Same place as full fine-tuning: through every frozen layer, because the backward pass still needs each layer's input to compute the gradient for the adapter and to propagate to the layer below.
  • "What about serving many LoRA adapters?" The frozen base is shared and each adapter is a few hundred megabytes, so one replica can hold hundreds; that is multi-LoRA serving.

Common mistakes

  • Forgetting the master weights or one Adam moment and reporting 12 bytes per parameter.
  • Claiming LoRA "reduces memory 8x" without saying that the 141 GB of weights stay; the 8x is on the trainable state, and the total drops from 1.13 TB to about 145 GB plus activations.
  • Sizing the job on static state alone and running out of memory on the first 8k-sequence batch.
  • Dividing 1.13 TB by 80 GB and reporting 15 cards, with no usable-memory headroom.

Key takeaways

  • Full fine-tuning: 16 B per parameter (2 + 2 + 4 + 4 + 4), 1.13 TB for a 70B, 18 H100s minimum sharded, plan 32.
  • LoRA: base weights stay at 141 GB in bf16; the adapters' 16 B per parameter is a few gigabytes; one node.
  • Activations are unchanged by LoRA and set the batch size; gradient checkpointing is standard for both.
  • 8-bit Adam trims full fine-tuning to 10 B per parameter; QLoRA puts a 70B on one card.
That one was free — and so are 10 answers per topic without an account. Signing in doubles that to 20, opens the Plus lessons in the courses, and remembers which topics you keep getting wrong.no card · Google sign-in · nothing to cancel
HOW DID IT GO?
0
READING SIGNED OUT

Signing in doubles your free answers, from 10 to 20 per topic, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free

The concepts behind this question

Ranked by how closely each one overlaps this question's topic, so the first card is the thing to read if the answer above moved too fast.

Advanced
🚀 Inference & Serving🔒 Premium
Multi-LoRA ServingA LoRA adapter is a few hundred megabytes of low-rank matrices that turn a base model into a fine-tuned variant, and multi-LoRA serving runs hundreds of them on one copy of the base weights by keeping the adapters in memory and applying the right one per request inside the batch. It is how a platform serves a thousand customers' fine-tunes without a thousand deployments. The costs are an extra small matmul per layer, adapter memory and loading, and a scheduler that has to batch across adapters without starving any of them.
Core
🕸️ Distributed TrainingSign in
ZeRO and FSDPZeRO and FSDP keep data parallelism's simple programming model but shard the optimizer state, gradients and parameters across ranks, cutting per-GPU memory from 16 bytes per parameter toward 16/N. The price is 1.5x DDP's communication and a dependence on tokens per GPU that decides when sharding stops paying and tensor parallelism takes over.
Advanced
📐 AI Systems Design🔒 Premium
Multi-Tenant Fine-Tuning ServiceA fine-tuning service takes a customer's dataset and a base model and returns a model, and the design problem is that many customers want this at once, cheaply, without seeing each other's data, on GPUs that must not sit idle between jobs. LoRA changes the shape: an adapter is a few hundred megabytes rather than a copy of the base, so many jobs can share a base in memory and many adapters can be served from one replica. This page designs the service end to end: the pipeline, the LoRA arithmetic that sets memory and cost, the isolation, the scheduler that packs jobs, and the serving path.
Core
🧮 Napkin Math & CapacitySign in
GPU-Hours and Time to TrainThe fleet equation turns a training run's FLOPs into a schedule: time = 6ND divided by (GPUs times peak FLOPS times MFU). Every term is a stated assumption, and the interviewer grades the assumptions rather than the digits: which peak, which MFU, and what happens to the answer when MFU falls from 40% to 30%. This page works three runs end to end (an 8B, a 70B and a 405B), inverts the equation for the GPU count a deadline needs, and shows the sensitivity that separates a considered estimate from a lucky one.
UP NEXT ON YOUR JOURNEY
FEDITOR'S NOTE

The interviewer wants the 16 bytes decomposed (2 + 2 + 4 + 4 + 4) and wants the candidate to notice that LoRA does not shrink the weights, only the trainable state.

DISCUSSION · 0

No comments yet — be the first to share your approach.