LoRA rank sizing calculator

Pick your base model, LoRA rank r, target linear modules, and base quantization to compute exact trainable parameter counts from real transformer dimensions (d_model, d_ff, d_kv, n_layers), adapter checkpoint size on disk, and total training VRAM.

Interactive calculator

Rank (r)Rec. AlphaTrainable Params% of BaseAdapter File (BF16)Total Train VRAM

Frequently asked questions

What LoRA rank (r) should I start with for LLM fine-tuning?

For most instruction tuning, JSON extraction, and style tasks, r=16 or r=32 applied to all linear layers (q, k, v, o, gate, up, down) matches full fine-tuning quality. Use r=64 to r=128 only for heavy domain adaptation, new coding languages, or large (>50M token) datasets.

Why does targeting all linear layers matter more than cranking up rank on q,v?

The QLoRA paper (Dettmers et al., 2023) showed that applying LoRA to all 7 transformer linear projections (attention + SwiGLU MLP) at r=16 outperforms attention-only q,v LoRA even at r=64, because most factual and behavioral capacity sits in the MLP layers.

How should I set lora_alpha relative to rank r?

The standard heuristic is lora_alpha = 2 * r (effective scaling = 2.0) or lora_alpha = r (scaling = 1.0). For high ranks (r >= 64), enable rsLoRA (alpha / sqrt(r)) so gradient magnitudes stay stable without shrinking the learning rate.

How much extra VRAM does increasing LoRA rank from 16 to 64 actually use?

Surprisingly little. On Llama 3.1 8B with all-linear adapters and paged 8-bit AdamW, jumping from r=16 (42M trainable params) to r=64 (168M trainable params) adds only ~0.75 GB of VRAM — far smaller than the base model weights or activation memory.

How big is a saved LoRA adapter checkpoint on disk?

In BF16/FP16 safetensors format, a LoRA adapter takes exactly 2 bytes per trainable parameter. A 42M-parameter adapter (Llama 3.1 8B, r=16, all-linear) is ~84 MB on disk, making it easy to hot-swap multiple adapters on one base model.

All calculations run locally in your browser. VRAM estimates assume gradient checkpointing enabled with FlashAttention-2 and micro-batch size 1; larger micro-batches increase activation memory proportionally.