LoRA Parameters Calculator
Inputs
| Layers | 32 |
|---|---|
| Adapted modules per layer | 4 |
| Hidden size | 4,096 |
| LoRA rank | 8 |
LoRA Parameters Calculator
Estimate the number of trainable parameters a LoRA fine-tune adds, and the optimizer memory it requires, from the layer count, adapted modules per layer, hidden size, and LoRA rank.
Inputs
Model architecture
LoRA adapter
Results
Enter a value to see results.
Details
LoRA Parameters
Low-Rank Adaptation, or LoRA, is the most common way to fine-tune a large language model on a budget. Instead of updating every weight, it freezes the base model and trains a small pair of low-rank matrices alongside each adapted weight matrix. The result behaves almost like a full fine-tune while touching a tiny fraction of the parameters. This calculator estimates how many parameters that fraction amounts to, and how much optimizer memory it needs, from the model's shape and the adapter's rank.
How LoRA shrinks the trainable set
A transformer weight matrix maps one hidden vector to another, so for a square layer it holds about values. Fine-tuning all of them is expensive: the optimizer must store gradients and running statistics for every one. LoRA replaces that dense update with a product of two thin matrices — one of shape and one of shape , where the rank is far smaller than . The base weights never move; only these two factors are trained, and at inference their product is added back into the original matrix.
Because each adapted matrix contributes trainable values — and when input and output widths are equal — the trainable set is usually well under one percent of the full model. That is what makes LoRA practical on a single accelerator.
The formula
With layers, adapted modules per layer, rank , and hidden size , the trainable parameter count is
P=L⋅m⋅2⋅r⋅dMixed-precision Adam keeps roughly sixteen bytes of optimizer and master-weight state per trainable parameter — the 32-bit master copy, plus the first and second moment estimates — so the optimizer memory in megabytes is
M=10616PThis counts only the adapter state. The frozen base model still occupies memory for its weights, but it needs no gradients or optimizer state, which is where the saving comes from.
Worked example
Take a model with 32 layers, adapting the four attention projections in each layer, at rank 8 with a hidden size of 4096:
P=32×4×2×8×4096=8388608That is about 8.39 million trainable parameters. The optimizer state is
M=10616×8388608≈134.2 MBFor a seven-billion-parameter base model, those 8.39 million adapters are roughly a tenth of a percent of the whole — yet they are enough to specialize the model for many downstream tasks.
Choosing the rank and modules
The rank is the main capacity dial. Ranks of 4 to 8 are common for light task adaptation; 16 to 64 give more room when the target task is far from the base model's training. Doubling the rank doubles both the trainable parameters and the optimizer memory, so it is worth raising only when a lower rank underfits. The modules-per-layer input reflects which matrices receive an adapter: two for query and value only, four for the full attention block, or more if the feed-forward matrices are included.
To compare the adapter against the size of the full model, see the Transformer Parameter Count Calculator. To size the total memory of a training run including the frozen weights and activations, see the LLM Training VRAM Calculator.
Frequently Asked Questions (FAQ)
What does the LoRA rank control?
The rank sets the dimension of the low-rank update added to each adapted weight matrix. A higher rank gives the adapter more capacity to capture changes from the base model, at the cost of more trainable parameters and optimizer memory, both of which grow linearly with rank. A lower rank is smaller and faster but may underfit harder tasks.
Most fine-tunes use a rank between 4 and 64, with 8 or 16 a common starting point; the best value depends on how far the target task differs from the base model.
How much smaller is a LoRA fine-tune than full fine-tuning?
LoRA trains only the low-rank adapters and freezes the base weights, so the trainable set is usually well under one percent of the full model. A seven-billion-parameter model adapted at a modest rank often has only a few million trainable parameters.
Because optimizer state scales with trainable parameters rather than total parameters, the memory saving is large. The full model size for comparison can be estimated with the parameter-count-from-architecture calculator.
Which modules are usually adapted?
The most common choice is the attention projection matrices — query, key, value, and output — which corresponds to four modules per layer. Some recipes adapt only the query and value projections (two modules), while others add the feed-forward matrices for broader coverage at a higher parameter cost. Set the modules-per-layer input to match the matrices your configuration targets.
Disclaimer
This estimate assumes square adapted matrices and counts only the LoRA factors and their mixed-precision Adam optimizer state at roughly 16 bytes per parameter. It excludes the frozen base model, activations, gradients of non-adapter parameters, and any bias or embedding tuning. Treat it as a planning figure, not an exact memory accounting.