AI Researchcalculator

LoRA parameter counter

LoRA fine-tunes a model without touching its weights. For each matrix you choose to adapt, it freezes the original and learns two thin matrices whose product is the update. Only those thin matrices are trained and saved, so the adapter is a small fraction of the model.

0.17% of the base model

Rank 16 on 4 module types trains 13.6M parameters, saved as a 27.3 MB bf16 file.

Adam states saved63.9 GBAgainst full fine-tuning
Trainable parameters13.6M13,631,488 in 4 module types across 32 layers
Share of the base model0.17%Base: 8B parameters
Adapter file size27.3 MBbf16 weights, no optimiser state
Scale (alpha / r)2Alpha 32, rank 16
Adam states saved63.9 GB64 GB for full fine-tuning against 109.1 MB for the adapter

Inputs

8B parameters as published; 32 layers, hidden size 4,096.

The update is scaled by alpha / r = 2.

Adapter precision
LoRA parameters by module
ModuleShape (in × out)Per layerAll layers
Query (q_proj)4,096 × 4,096131,0724,194,304
Key (k_proj)4,096 × 1,02481,9202,621,440
Value (v_proj)4,096 × 1,02481,9202,621,440
Output (o_proj)4,096 × 4,096131,0724,194,304

What it shows

A matrix that maps d_in values to d_out values gets r × (d_in + d_out) adapter parameters at rank r. That sum depends on the real shapes: with grouped-query attention the key and value projections are narrower than the query projection, and the three MLP matrices use the intermediate size, not the hidden size.

This counter uses the shapes of real dense models and adds up the modules you tick across every layer. It converts the result into a share of the base model, an adapter file size and the optimiser memory you avoid compared with training every weight with Adam.

How to read it

  • “Trainable parameters” is the total across all layers for the ticked modules. The per-module table shows each matrix’s shape and count.
  • “Share of the base model” divides by the published parameter count, which models round to one decimal. Expect the percentage to be right to about that precision.
  • “Scale” is alpha divided by rank. LoRA multiplies the learned update by it, so doubling the rank at a fixed alpha halves the scale.
  • “Adam states saved” compares 8 bytes per parameter for Adam’s two fp32 moments on the full model with the adapter alone. It leaves out gradients, master weights and activations.
  • The rank table keeps your modules and shows how the adapter grows from rank 4 to 128, with your rank marked.

Questions

What do rank and alpha control?

Rank r is the width of the thin matrices, so it sets capacity and the parameter count: doubling it doubles the adapter. Alpha sets the scale alpha / r applied to the learned update. Many recipes fix alpha and vary rank, which changes the effective step size as well as capacity, so retune the learning rate when you change either.

Which modules should I adapt?

The LoRA paper adapted only the query and value matrices in its main experiments. Many fine-tuning recipes since adapt every linear layer, which costs several times more parameters. There is no universal answer; compare on your own task.

Does LoRA reduce activation memory?

No. The forward and backward passes still run through the full frozen model, so activations are about the same. LoRA saves the gradients and optimiser states for the frozen weights. QLoRA also quantises the frozen weights, which this counter does not model.

Does the adapter slow down inference?

Not if you merge it. The learned update can be added into the frozen weights once, after training, which leaves the model the same shape and speed as the original. Keeping adapters separate lets you swap them at a small extra cost.

Why are mixture-of-experts models missing?

The presets cover dense models whose projection shapes are published. Expert layers and fused projections need different counting rules. Use the custom model option for any dense shape you know.

Sources

Explore further

Last updated

More tools

All tools

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.