induwara.lk
induwara.lkAI · Fine-tuning

LoRA Parameter Calculator — Trainable Params & Adapter Size

Work out exactly how many trainable parameters a LoRA or QLoRA fine-tune adds to Llama 3, Mistral, Qwen2.5, Gemma 2, or a custom LLM — plus the percentage of the base model, the adapter file size, and the training memory. Matches PEFT, no signup, sources cited below.

By Induwara AshinsanaUpdated Jul 2, 2026
LoRA adapter sizingtrainable params & disk size
Matches PEFT
Base model
Target modules
·

1–512. Drives the parameter count.

Reference only — no effect on count.

Adapter precision
Trainable params
13,631,488
≈ 13.63 M
% of base model
0.170%
Base ≈ 8.03 B
Adapter file size
26.0 MB
params × bytes/param
Training memory
156.0 MB
adapter + Adam states

Per-module breakdown

ModuleInOutPer layerAll layers
q_proj4,0964,096131,0724,194,304
k_proj4,0961,02481,9202,621,440
v_proj4,0961,02481,9202,621,440
o_proj4,0964,096131,0724,194,304
Total trainable425,98413,631,488

Parameter counts follow the LoRA paper (arXiv:2106.09685): each adapter adds r·(in + out) trainable parameters and reproduces PEFT'sprint_trainable_parameters()output.

This sizes the adapter and its optimizer state only. The frozen base-model weights (roughly 8B params) and training activations are separate. For total GPU VRAM, use the LLM VRAM Calculator.

How it works

Low-Rank Adaptation (LoRA) freezes the base model and inserts a small, trainable low-rank update beside each targeted weight matrix. For a linear layer with weight W ∈ ℝ^(out × in), LoRA learns two matrices — A ∈ ℝ^(r × in) and B ∈ ℝ^(out × r) — and adds their product to the frozen weight. Only A and B are trained, so each module contributes exactly r · (in + out) trainable parameters (Hu et al., arXiv:2106.09685).

  1. Resolve the architecture dimensions from the chosen preset (taken from each model's official config.json) or from your custom inputs: hidden size, layers, attention heads, KV heads, head dim, and MLP intermediate size.
  2. Find each projection's in/out size. Attention: q_proj is d_model → n_heads·head_dim; k_proj/v_proj are d_model → n_kv_heads·head_dim (narrower under Grouped-Query Attention); o_proj is n_heads·head_dim → d_model. MLP: gate_proj/up_proj are d_model → intermediate and down_proj is intermediate → d_model.
  3. Compute per-module LoRA parameters as r · (in + out), sum across the selected modules, then multiply by the number of layers. Alpha is excluded — it only scales ΔW = (α/r)·B·A at inference and does not change the count.
  4. Derive the base-model parameter count from the same dimensions (embeddings, per-layer attention and MLP weights, and norms) so the trainable percentage is internally consistent.
  5. Adapter file size = trainable × bytes-per-parameter (fp16/bf16 = 2, fp32 = 4), reported in MB (÷ 1024²). Training memory = trainable × (param + gradient at adapter precision + 8 bytes for the Adam fp32 moment states) — 12 bytes per parameter in fp16. The frozen base weights and activations are counted separately.

The result reproduces what Hugging Face PEFT's print_trainable_parameters() prints for the same rank and target_modules. The tool also cross-checks the total two independent ways — the r·(in + out) identity and counting the A and B matrices separately — which must agree to the parameter.

Worked examples

Llama 3 8B · q, k, v, o · r = 16 · fp16

  1. Dims: d_model=4096, layers=32, heads=32, kv_heads=8, head_dim=128
  2. q/o out = 32×128 = 4096 ; k/v out = 8×128 = 1024
  3. q_proj: 16·(4096+4096) = 131,072
  4. k_proj: 16·(4096+1024) = 81,920 ; v_proj: 81,920
  5. o_proj: 16·(4096+4096) = 131,072
  6. Per layer = 425,984 → × 32 = 13,631,488 params (≈ 13.63 M)
  7. Base ≈ 8.03 B → 0.170% trainable
  8. Adapter (fp16): 13,631,488 × 2 = 26.0 MB
  9. Training mem: × 12 = 156.0 MB (adapter + Adam, base separate)

Llama 3 8B · all-linear · r = 8 · fp16

  1. Attention (r=8): q 65,536 + k 40,960 + v 40,960 + o 65,536 = 212,992/layer
  2. MLP (r=8, intermediate=14336): gate 147,456 + up 147,456 + down 147,456 = 442,368/layer
  3. Per layer = 655,360 → × 32 = 20,971,520 params (≈ 20.97 M)
  4. Base ≈ 8.03 B → 0.261% trainable
  5. Adapter (fp16): 20,971,520 × 2 = 40.0 MB
  6. Note: lower rank but MLP modules more than doubled the count vs Example 1 — target choice dominates.

Edge — Qwen2.5 7B · q, v only · r = 512 · fp32

  1. Dims: d_model=3584, layers=28, heads=28, kv_heads=4, head_dim=128
  2. q out = 28×128 = 3584 ; v out = 4×128 = 512
  3. q_proj: 512·(3584+3584) = 3,670,016
  4. v_proj: 512·(3584+512) = 2,097,152
  5. Per layer = 5,767,168 → × 28 = 161,480,704 params
  6. Adapter (fp32): 161,480,704 × 4 = 616.0 MB — a high rank makes even a 2-module adapter large.

Frequently asked questions

Sources & references

The model architecture dimensions and formulas on this page were last cross-checked against the cited papers and config.json files on 2026-07-02. LoRA sizing is architecture-driven, so figures change only when a model's config changes.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want another model preset added?

Email me at [email protected] — most fixes ship within 24 hours.