4.3.8 · D3Pretraining & Fine-Tuning LLMs

Worked examples — LoRA and QLoRA

2,033 words9 min readBack to topic

Everything here builds on LoRA and QLoRA (parent). If a term is new, check Matrix Rank and Low-Rank Approximation, Quantization of Neural Networks, Adam Optimizer memory cost, or Full Fine-Tuning vs PEFT.


The scenario matrix

Every LoRA/QLoRA numeric question falls into one of these cells. We will hit each one.

Cell What varies The question it answers
C1 Param count, square How many trainable params for one square projection?
C2 Param count, rectangular Does the formula still hold when shapes differ?
C3 Degenerate rank smallest useful rank What is the leanest LoRA possible?
C4 Limiting rank rank saturates When does LoRA stop saving anything?
C5 Scaling factor change , hold How does effective update strength move?
C6 Full-FT optimizer memory Adam on all params Why is full fine-tuning so heavy?
C7 QLoRA base storage 4-bit frozen weights How small does the base get?
C8 Real-world sizing (word problem) pick a GPU Does a whole run fit in this card?
C9 Exam twist mixed / trap Apply LoRA to a subset of layers, count everything
Recall The three formulas everything below uses

Trainable params per matrix ::: Effective update scale ::: Bytes/param at bits :::


C1 — Param count, square projection


C2 — Rectangular projection ()


C3 — Degenerate: the leanest possible rank ()


C4 — Limiting case: rank saturates ()


C5 — Scaling factor across changes


C6 — Full fine-tuning optimizer memory (the baseline pain)


C7 — QLoRA 4-bit base storage


C8 — Real-world word problem: does it fit this GPU?


C9 — Exam twist: LoRA on a subset, count everything


Recall Quick self-test

LoRA stops saving memory when exceeds what value (for )? ::: — beyond it, . In the C8 budget, which term dominates? ::: The 4-bit frozen base ( GB), not the adapters ( GB). Raising from 8 to 32 with fixed changes update strength by what factor? ::: (quartered).