LoRA Rank Calculator

Calculate LoRA parameters and memory savings.

LoRA Configuration

B

LoRA Parameters

8.39M

0.120% of original model

💾LoRA Memory
16.0 MB
📉Memory Saved
74.9%

LoRA Details

Scaling Factor (alpha/r)2.00
Target ModulesQuery + Value
Params per Layer262.1K
Params per Module131.1K

Memory Comparison

Full Fine-tuning52.2 GB
LoRA Fine-tuning13.1 GB
Training Speedup~9.9x

Common settings: r=8-16 for simple tasks, r=32-64 for complex tasks. Alpha is typically 2x the rank.

What the LoRA Rank Calculator Does

The LoRA Rank Calculator estimates how many trainable parameters a Low-Rank Adaptation (LoRA) adapter adds to a large language model, how much GPU memory those adapters consume, and how that compares to full fine-tuning. LoRA is the most widely used parameter-efficient fine-tuning (PEFT) method because it freezes the original weights of a pretrained model and injects small trainable rank-decomposition matrices into selected linear layers. Instead of updating billions of weights, you train a few million, which is exactly what this calculator quantifies for your chosen configuration.

To use the calculator you provide the base model size in billions of parameters, the hidden size (the model dimension, often written d_model), the number of transformer layers, the LoRA rank (r), the LoRA alpha scaling parameter, the set of target modules you want to adapt, and the numeric precision (FP32, FP16, or BF16). From those seven inputs it derives the total LoRA parameter count, the adapter memory footprint in megabytes, the percentage of the original model that is being trained, the alpha-over-rank scaling factor, an estimated memory saving versus full fine-tuning, and a rough training speedup.

This is a planning tool for anyone deciding how to fine-tune an LLM on limited hardware. Choosing a rank that is too small can starve the adapter of capacity and hurt downstream accuracy, while a rank that is too large wastes memory and edges toward the cost of full fine-tuning without the matching benefit. By turning your settings into concrete numbers, the LoRA rank calculator helps you pick a rank, alpha, and target-module combination that fits inside your GPU budget. The default example of a 7B model with rank 16 trains roughly 8.39 million parameters, which is only about 0.12% of the original 7 billion weights.

How LoRA Parameters Are Counted

LoRA replaces a full weight update with the product of two small matrices. For a frozen weight matrix of shape d x d, LoRA learns an A matrix of shape d x r and a B matrix of shape r x d, where r (the rank) is much smaller than d. Each adapted module therefore adds 2 x d x r trainable parameters: one factor of d x r for A and another d x r for B. The calculator multiplies this per-module count by the number of target modules per layer, then by the number of transformer layers.

The target modules selector maps directly to a count: Query only adds 1 module, Query + Value adds 2, Query + Key + Value adds 3, Q + K + V + Output adds 4, and All linear layers adds 6 (Q, K, V, O, the up projection, and the down projection). More modules mean more trainable parameters and more memory, but also more representational flexibility. The adapter memory in bytes is simply the total parameter count multiplied by the bytes per parameter for your precision: 4 bytes for FP32 and 2 bytes for FP16 or BF16.

The reported percentage of the original model divides total LoRA parameters by the base parameter count, which is the model size in billions multiplied by one billion. Because LoRA parameters scale with d, r, the module count, and the layer count, but the base model scales with the full quadratic and feed-forward weight matrices, this percentage is typically a fraction of one percent for sensible ranks.

Total LoRA Trainable Parameters

totalLoraParams = 2 × d × r × modules × L

Where:

  • d= Hidden size (model dimension, d_model)
  • r= LoRA rank — the size of the low-rank decomposition
  • modules= Adapted modules per layer (1=Q, 2=Q+V, 3=Q+K+V, 4=Q+K+V+O, 6=all linear)
  • L= Number of transformer layers in the base model

Alpha, Rank, and the Scaling Factor

LoRA does not apply the learned update at full strength. Instead it multiplies the low-rank product B x A by a scaling factor equal to alpha divided by rank. The calculator reports this ratio directly. The scaling factor controls how aggressively the adapter influences the frozen model: a larger alpha relative to r pushes the adaptation harder, while a smaller alpha keeps it gentle. A very common convention is to set alpha equal to twice the rank, which yields a scaling factor of 2.

The calculator includes guardrails that flag potentially poor configurations. If the rank is below 4 it warns that the adapter may lack capacity for complex tasks and suggests r=8 or higher. If the rank exceeds 64 it notes that you are approaching the cost of full fine-tuning and could reduce r for efficiency. If the alpha-over-rank ratio is below 1 it warns that adaptation may be too weak, and if that ratio exceeds 4 it warns about possible training instability. In both ratio cases the suggested fix is alpha = 2 x r.

Because the scaling factor only multiplies the output of the adapter and does not change the parameter count, adjusting alpha changes how strongly LoRA adapts without altering memory usage. This decoupling is one reason LoRA is so practical: you can tune learning dynamics through alpha and capacity through rank independently, and the LoRA rank calculator lets you see both effects side by side before you launch a training run.

Memory Savings Versus Full Fine-Tuning

The headline benefit of LoRA is dramatically lower memory pressure during training. Full fine-tuning of a model in mixed precision must hold the weights, the gradients, and the optimizer state. For the Adam optimizer the calculator models this as four copies of the model in memory: one for weights, one for gradients, and two for the first and second moment estimates. With bytes per parameter from your precision, the full fine-tuning footprint is base parameters multiplied by bytes multiplied by four.

LoRA instead keeps the base model frozen (one copy, no gradients or optimizer state for those weights) and applies the full gradient and optimizer overhead only to the tiny adapter. The calculator models the LoRA footprint as the frozen base model plus four times the adapter memory. Dividing the difference by the full fine-tuning footprint gives the reported memory savings percentage. For a 7B model in FP16 with rank 16 on Query and Value modules, full fine-tuning needs about 52.2 GB while LoRA needs about 13.1 GB, a saving near 75%.

The calculator also estimates a training speedup as the base parameter count divided by ten percent of the base plus the LoRA parameters. This is a heuristic that reflects how much less work the backward pass and optimizer step perform when only the adapter is trainable. It is not a literal wall-clock guarantee, since real throughput depends on the GPU, batch size, sequence length, and kernel efficiency, but it gives a useful relative sense of why LoRA runs faster and fits on smaller hardware than full fine-tuning.

LoRA Memory Saving Percentage

savings = ((P×b×4) − (P×b + loraMem×4)) / (P×b×4) × 100

Where:

  • P= Base model parameters (model size in billions × 1e9)
  • b= Bytes per parameter (4 for FP32, 2 for FP16/BF16)
  • loraMem= LoRA adapter memory in bytes = totalLoraParams × b

Choosing the Right Rank and Target Modules

There is no single best rank for every task, but the LoRA rank calculator makes the trade-offs visible. A small rank such as 8 trains very few parameters and is ideal for simple instruction tuning, style adaptation, or domain vocabulary where the base model already knows most of what it needs. Larger ranks such as 32 or 64 give the adapter more room to learn complex behaviors, multi-step reasoning patterns, or substantial domain shifts, at the cost of more memory and a smaller speedup.

Target-module selection matters just as much as rank. The original LoRA work showed that adapting only the attention Query and Value projections often captures most of the benefit at low cost, which is why Query + Value is a popular default. Adding Key and Output projections, or extending to all linear layers including the feed-forward up and down projections, increases capacity for harder tasks but multiplies the parameter count by the module factor shown in the calculator.

A practical workflow is to start with the default Query + Value at rank 16 with alpha 32, read off the parameter count and memory, and confirm the configuration fits your GPU. If accuracy plateaus, raise the rank or add modules and re-check the numbers. If you are memory constrained, lower the rank or precision and watch the savings percentage climb. Because the calculator updates instantly, you can sweep through dozens of LoRA fine-tuning configurations in seconds and settle on the one that balances quality against your hardware budget.

Worked Examples

7B Model, Rank 16, Query + Value (Default)

Problem:

A 7B model with hidden size 4096, 32 layers, rank 16, alpha 32, Query + Value modules, FP16. How many LoRA parameters and how much memory?

Solution Steps:

  1. 1Per module: 2 x d x r = 2 x 4096 x 16 = 131,072 parameters.
  2. 2Per layer: 131,072 x 2 modules = 262,144 parameters.
  3. 3Total: 262,144 x 32 layers = 8,388,608 parameters (about 8.39M).
  4. 4Memory: 8,388,608 x 2 bytes = 16,777,216 bytes = 16 MB. Percentage of model: 8,388,608 / 7,000,000,000 x 100 = 0.12%.

Result:

About 8.39M trainable LoRA parameters using 16 MB, roughly 0.12% of the 7B base model.

13B Model, Rank 32, All Linear Layers

Problem:

A 13B model with hidden size 5120, 40 layers, rank 32, all linear layers (6 modules), BF16. Find total parameters and adapter memory.

Solution Steps:

  1. 1Per module: 2 x 5120 x 32 = 327,680 parameters.
  2. 2Per layer: 327,680 x 6 modules = 1,966,080 parameters.
  3. 3Total: 1,966,080 x 40 layers = 78,643,200 parameters (about 78.6M).
  4. 4Memory: 78,643,200 x 2 bytes = 157,286,400 bytes = 150 MB.

Result:

About 78.6M LoRA parameters using 150 MB, around 0.605% of the 13B base model.

Memory Savings for a 7B FP16 Run

Problem:

Compare full fine-tuning versus LoRA memory for the default 7B FP16 case (16 MB adapter, 8.39M LoRA params).

Solution Steps:

  1. 1Full fine-tuning: 7e9 x 2 bytes x 4 = 56,000,000,000 bytes = about 52.2 GB.
  2. 2LoRA: frozen model 7e9 x 2 = 14e9 bytes, plus adapter 16,777,216 x 4 = 67,108,864 bytes, total 14,067,108,864 bytes = about 13.1 GB.
  3. 3Difference: 56e9 - 14,067,108,864 = 41,932,891,136 bytes.
  4. 4Savings: 41,932,891,136 / 56,000,000,000 x 100 = 74.9%.

Result:

LoRA cuts training memory from about 52.2 GB to 13.1 GB, a saving of roughly 74.9%.

Tips & Best Practices

  • Start with the default Query + Value modules at rank 16 and alpha 32, then scale up only if accuracy stalls.
  • Set alpha to roughly twice the rank to keep the scaling factor near 2 and avoid weak or unstable adaptation.
  • Use FP16 or BF16 instead of FP32 to halve adapter memory with no change to the parameter count.
  • Check the percentage-of-original metric — a healthy LoRA run usually trains well under 1% of the base model.
  • If you are GPU constrained, lower the rank or precision and watch the memory-saved percentage climb.
  • Add Key, Output, or feed-forward modules only when extra task complexity justifies the larger parameter count.
  • Keep rank at or below 64; beyond that you approach full fine-tuning cost without proportional gains.
  • Re-run the calculator after any input change so your configuration still fits inside your GPU memory budget.

Frequently Asked Questions

The rank r is the inner dimension of the two low-rank matrices LoRA inserts into each adapted layer, and it directly controls how many parameters the adapter can learn. Smaller ranks like 8 are efficient and work well for simple instruction tuning, while ranks of 32 to 64 add capacity for complex tasks. A good practice is to start at 16, check accuracy, and increase only if results plateau.
Each adapted module adds 2 x d x r parameters, where d is the hidden size and r is the rank. The calculator multiplies that by the number of target modules per layer and then by the number of transformer layers. For a 7B model with d=4096, r=16, two modules, and 32 layers, the total is about 8.39 million trainable parameters.
Alpha sets the scaling factor applied to the adapter output, which equals alpha divided by rank. A higher alpha relative to rank makes the adaptation stronger, while a lower value keeps it subtle. A widely used convention is alpha = 2 x rank, giving a scaling factor of 2, and the calculator warns if your ratio falls below 1 or above 4.
Full fine-tuning must store weights, gradients, and optimizer state for every parameter, which the calculator models as four copies of the model for Adam. LoRA keeps the base model frozen with no gradients or optimizer state and applies that overhead only to the small adapter. For a 7B FP16 model this drops the footprint from about 52.2 GB to 13.1 GB, near a 75% reduction.
Adapting just the Query and Value attention projections often captures most of the benefit at low cost and is a common default. Adding Key, Output, or the feed-forward projections increases capacity for harder tasks but multiplies the parameter count by the module factor. Use the calculator to see exactly how each choice changes parameters and memory before committing.
Not necessarily. Beyond a task-dependent point, extra rank adds memory and training cost without improving downstream quality, and very high ranks approach the expense of full fine-tuning. The calculator flags ranks above 64 as inefficient, so it is usually better to find the smallest rank that reaches your accuracy target.

Sources & References

Last updated: 2026-06-05

💡

Help us improve!

How would you rate the LoRA Rank Calculator?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Standard Mathematical References

by Various

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.