TL;DR
A matrix can look like a large table of numbers, but many of its rows or columns may repeat information the others already carry. The rank counts how much genuinely new information it holds: the largest number of columns that are linearly independent. Equivalently, it is the number of dimensions of output space the matrix can reach.
Where you'll see it: deciding whether a system of linear equations has a solution, and in LoRA, where a fine-tuning update is forced to have low rank so that it stores far fewer numbers.
Intuition
Repeated information
Take a price list with three columns: price in dollars, price in euros, and the number of items. Suppose the euro column is always the dollar column times 0.9. The table has three columns, but only two of them carry new information, because the euro column can be computed from the dollar column. Rank is the count of what is really there.
The tool for this is linear independence. A set of vectors is independent when none of them can be built from the others. The rank of a matrix is the largest number of its columns that form an independent set. In the price list, the euro column is a multiple of the dollar column, so the two are dependent and the rank is 2.
Rank as reach
Apply the matrix as a machine, , and ask which outputs are possible. If every column of is a multiple of one vector, every output lies on one line through the origin: the matrix reaches only one direction. If the columns span a plane, the outputs fill the plane. Rank is the dimension of the set of reachable outputs, which is the number of directions the linear transformation keeps alive.
flowchart LR A[Matrix A with n columns] --> B[Find the independent columns] B --> C[Count them: this is the rank] C --> D[Outputs fill a space of that dimension] C --> E[Inputs sent to zero: n minus rank]
Why it exists
Gaussian elimination is the classical way to solve a system . Running it tells you whether a solution exists at all. The number of pivots it finds, meaning rows that still have a nonzero leading entry after elimination, is the rank. Rank summarises the outcome of the whole procedure in one integer, which is why it matters in theory and in software.
The math
Definition
The rank of a matrix with rows and columns, written , is the maximum number of linearly independent columns of . Equivalently, it is the dimension of the column space of , the set of all vectors of the form .
Each column of is a vector in . The rank is how many of those columns you need as a building set: every column is a combination of the independent ones, and no fewer will do.
Key results
Rank is at most the smaller dimension.
A table with 1000 rows and 3 columns has rank at most 3. When the rank equals the matrix is called full rank.
Row rank equals column rank.
The number of independent rows is the same as the number of independent columns, so there is one well-defined rank.
Rank-nullity. The null space is the set of inputs sent to zero. Its dimension is the nullity.
Each column that depends on earlier columns produces one direction that sends to zero. The columns split into independent ones (counted by the rank) and dependent ones (each giving a null direction).
Products cannot increase rank.
Every column of is a combination of columns of , so its columns all lie in the column space of . Multiplying can only lose information. This is why multiplying matrices cannot make a rank-deficient matrix full rank.
Rank- factorisation. If , then can be written as a product of two thin matrices:
To see why, pick independent columns of and place them in . Every other column of lies in their span, so for some coefficient vector . Stack the as the rows of and the product reproduces every column of . Storing and takes numbers instead of . This is the fact that LoRA exploits.
- r(m + n) / (m n), with m = n = 1000
Worked examples
Let .
- Column 1 is and column 2 is , so column 2 equals times column 1.
- The columns are dependent, so the largest independent set has one column. The rank is 1.
- Row reduction agrees. Subtract 3 times row 1 from row 2 to get . One pivot remains.
- Factor it as with and . Then .
Interpretation: every output of lies on the line through . Only one direction is reachable, so the rank is 1.
Let .
- Subtract 2 times row 1 from row 2. The result is .
- Subtract 3 times row 1 from row 3. The result is .
- Subtract the new row 2 from the new row 3. The result is .
- Two pivots remain, in columns 1 and 3, so .
- Rank-nullity gives . The vector is sent to zero. Row 1 gives , row 2 gives , and row 3 gives .
Interpretation: outputs of fill only a plane in three-dimensional space, so some right-hand sides can never be reached. The matrix also flattens one direction completely.
A fine-tuning update to one weight matrix has entries. LoRA forces the update to have rank , so it is stored as (size ) times (size ).
- Entries in : .
- Entries in : .
- Total stored: .
- Fraction stored: , or 0.8 percent.
Interpretation: the update is restricted to a rank-4 family of changes and costs under one percent of the storage. Choosing is a trade between what the update can express and what it costs.
Tradeoffs and failure modes
Rank is an exact idea, but computers work with rounded floating-point numbers. Exact zeros almost never appear, so software decides rank with a tolerance: compute the singular values with the SVD and count the ones above a threshold.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Noisy measured data | Exact rank is almost always full, so noise hides the structure | Count singular values above a tolerance |
| You need the solutions of | Rank says whether a solution exists, not what it is | Row reduce and read off pivots and free variables |
| Compressing a dense weight matrix | A full-rank matrix cannot be stored in fewer numbers without loss | Truncated SVD. The Eckart-Young theorem says it gives the best rank- approximation |
| Choosing a LoRA rank | A rank that is too small limits what the update can learn | Try several values of and compare on validation data |
Rank applies to linear maps. A nonlinear function has no single rank, but its Jacobian matrix has a rank at each point, and that local rank is often the useful quantity.
History
Carl Friedrich Gauss used the method of elimination in the early 1800s for least-squares calculations in astronomy. The procedure existed long before anyone called the result a rank. In the late 1870s, Ferdinand Georg Frobenius gave the precise definition of the rank of a matrix while studying systems of equations and bilinear forms.
Rank caught on because it reduces many questions about linear systems to one integer. Computers made elimination and the SVD routine, so the number became cheap to compute. In 2021 the LoRA paper by Hu and colleagues made rank a design knob for large neural networks, which brought the idea into machine learning practice.
Check yourself
QuestionWhat is the rank of the 3 by 3 identity matrix?Show answer
The identity has three columns, and they are the standard basis vectors , and . None of them can be built from the others, so all three are independent. The rank is 3, which is full rank.
QuestionA 2 by 2 matrix has rows (2, 4) and (1, 2). What are its rank and nullity?Show answer
Column 2 is , which equals times column 1 . The columns are dependent, so the rank is 1. Rank-nullity gives nullity . The null vector is : the first row gives and the second gives .
QuestionWhy can the rank of a product AB never exceed the rank of A?Show answer
Each column of is applied to a column of , which is a linear combination of the columns of . So every column of lies in the column space of . That space has dimension , so cannot have more independent columns than that.
QuestionA 512 by 512 weight matrix gets a LoRA update of rank 8. What fraction of its entries does the update store?Show answer
The factored form stores numbers. The full matrix has entries. The fraction is , or 3.125 percent.