Foundations — LoRA and QLoRA
This page assumes nothing. Before you read LoRA and QLoRA proper, we build every symbol it uses — one brick at a time. Each symbol gets: plain words → a picture → why the topic needs it.
1. A vector — a list of numbers
In an LLM, is the "state" of a token as it flows through the network — a list of, say, 4096 numbers describing what the model currently "thinks" about that word.
- Picture: a tall thin strip of numbers (see figure below, left).
- Why the topic needs it: every layer of the model takes such a list in and produces a new list out. is the input to the layer LoRA modifies.
We write , read " lives in the space of real numbers" — meaning is a list of ordinary numbers. is the symbol for "all real numbers" (any decimal, positive or negative).
2. A matrix — a grid that transforms vectors
Look at the figure. A matrix is a machine: feed in a vector of length (matching its columns), get out a vector of length (matching its rows). The rule for one output number is: march along a row, multiply each entry by the matching entry of , add them up.
- Why the topic needs it: a linear layer is a matrix. The whole of LoRA is about how to cheaply change this grid .
3. Dimensions , , and why the layer is huge
and are just the height and width of the grid.
Multiply to get the parameter count of one matrix. Keep this multiplication in mind — it is the villain LoRA defeats.
4. The frozen base and the update
The new weight is simply:
- Picture: two grids stacked and added cell by cell (right side of figure s01).
- Why the topic needs it: LoRA never touches (it "freezes" it). All the action is in cheaply representing .
5. Rank — how "thin" a grid really is
This is the concept everything hinges on.
Look at the figure. On the left, a full-rank grid: rows point in many independent directions. On the right, a rank-1 grid: every row is a multiple of the top row — visually it collapses to a single stripe of information smeared across the grid.
- Why the topic needs it: LoRA's founding assumption is that has low rank , with far smaller than or .
6. The outer product — building a grid from two lists
Before we factor , we need the tool that makes a rank-1 grid.
Look at the figure: a tall skinny times a wide skinny produces a full rectangle. Every grid built this way has rank exactly (each row is scaled by that row's ).
Why the outer product and not, say, ordinary multiplication? We want the smallest building block that produces a full 2-D grid from 1-D lists. The outer product is exactly that atom — and rank is precisely "how many atoms you needed." This is the reason LoRA can write .
- Parameter payoff: has numbers, has . Together — versus for the full grid.
7. The skinny matrices , , and the rank
Now the LoRA symbols make sense:
| Symbol | Plain words | Shape | Picture |
|---|---|---|---|
| the chosen rank (how many "atoms") | a small number like | how many stripes | |
| left skinny grid | tall & thin | ||
| right skinny grid | wide & short | ||
| their product = the update | full grid, but low-rank |
8. The scaling knob
- Picture: a dial turning the injected change up or down.
- Why the topic needs it: without the factor you'd have to re-tune the learning rate every time you changed . The knob decouples them.
9. Quantization — storing numbers in fewer bits (for QLoRA)
- Picture: a smooth number line replaced by 16 tick marks; every value jumps to its closest tick.
- A byte is 8 bits, so 4 bits byte per number. A 7B-parameter model at 4 bits needs GB instead of GB at 32-bit.
- Why the topic needs it: QLoRA stores the frozen in 4-bit to shrink it, and only briefly "dequantizes" (expands it back) during the multiply. See Quantization of Neural Networks.
Because is frozen, this snapping introduces a fixed small error that the trainable simply learn to work around — safe precisely because we never train itself.
10. Optimizer memory — the reason all this exists
Since LoRA only trains the tiny , the optimizer only tracks those — a few megabytes. That single fact is the payoff of everything above. See Adam Optimizer memory cost.
Prerequisite map
Equipment checklist
Test yourself — reveal each only after answering aloud.
What is a vector, in one phrase?
What does mean?
How many numbers are in a matrix?
What does say?
What does "frozen" mean for a weight?
What is the rank of a matrix?
What grid does an outer product produce, and what is its rank?
Why can represent any rank- matrix?
How many parameters does rank- LoRA store per matrix?
What does the factor do?
What does 4-bit quantization mean numerically?
Why is quantizing the frozen base safe?
Ready? Now read LoRA and QLoRA — every symbol on that page is now a picture you already own. For the fine-tuning context see Full Fine-Tuning vs PEFT; for where these matrices sit in the model, Attention Q K V Projections; and for how LoRA differs from Adapter Layers, watch the "merge = zero latency" point.