Fine-Tuning, and When Not ToLesson 16 of 84

Module 2 · How training actually works

Where the memory actually goes

In this lesson

  • 10 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 7 of 9 in this chapter

This chapter’s goalTrace one optimisation step from a batch of tokens to a changed weight, and predict which way loss, memory and stability move when you change the learning rate, the batch size, the precision or the number of epochs.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
An 11 GB QLoRA run, by consumerActivations kept for thebackward pass6 GBFrozen base weights in4-bit NF43.9 GBLogits, 128k vocabulary1 GBAdapter gradients andoptimiser state0.20 GBA 7B base at sequence 2,048, batch 2. Lowering the batch size touches one row of this chart, and it isoften not the largest one.
A 7B base at sequence 2,048, batch 2. Lowering the batch size touches one row of this chart, and it is often not the largest one.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

Five consumers, in order of surprise

When a run reports CUDA out of memory, people reach for a smaller batch size. Sometimes that is right. Often the batch was not the problem, and knowing which of five consumers is eating the card saves an afternoon.

1. Weights. Parameters times bytes per parameter. A 7B model is 14 GB in bf16, 28 GB in fp32, about 3.9 GB in 4-bit NF4. Fixed for the whole run, easy to compute, rarely the surprise.

2. Gradients. Same size as the trainable weights, in the gradient dtype. Full fine-tuning a 7B in bf16: another 14 GB. LoRA with 20M trainable parameters: 80 MB. This single line is why parameter-efficient methods exist.

3. Optimiser state. 8 bytes per trainable parameter for AdamW. 56 GB for a full 7B; 160 MB for the LoRA.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Running Models Yourself exam.

Stuck on something?Ask Rafael, your AI tutor

How to cite: Addaly (2026) ‘Where the memory actually goes’, in Fine-Tuning, and When Not To. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/fine-tuning/where-the-memory-goes (Accessed: 29 November 2026).