LoRA and QLoRA: a small adapter beside a frozen base

Adapter Cost: mid Optional merge; base can stay frozen READ-ONLY

LoRA (Low-Rank Adaptation) leaves the base weights frozen and trains a pair of small matrices B and A. The layer computes

W x + B A x

with rank r much smaller than the full matrix. You can keep the adapter as a separate file, or merge BA into W later. Merging makes inference cheap, but then switching adapters means writing the weights again. Leaving them unfused keeps switching easy, and can cost latency.

Diagram of W plus a thin matrix B times a wide matrix A.
QLoRA is the same adapter idea, with the base stored in 4-bit and computations done in a higher precision. Illustration, not a run of ours.
flowchart LR
  X[Input] --> W[Frozen W]
  X --> A[A, low rank]
  A --> B[B, low rank]
  W --> Sum[W x + BA x]
  B --> Sum

I have not run LoRA or QLoRA on the ToolAlpaca setup I used for deletion masks. An MLX A/B of mask vs LoRA is queued; it is ongoing work and not measured yet. SHiRA (Bhardwaj et al., arXiv 2406.13175) is a useful contrast: it updates a sparse slice of W itself, and is aimed at fast switching without the unfused-LoRA tax. Deletion Tuning, in the spotlight, does not add values at all. It only turns some of W off.

Cost here is a relative "mid": cheaper than a full fine-tune in memory and storage, usually more moving parts than a 20 MB deletion mask. I do not have a dollar figure of my own for LoRA.

Previous: Full fine-tuning. Next: Sparse fine-tuning.

Tags: Model tuning Fine-tuning Quantization

All ship logs