Custom AI models for the enterprise · New York · LondonSecurityResearchContact sales
Finetune the World
Glossary

QLoRA: definition, math and practical numbers

QLoRA trains LoRA adapters on top of a base model stored in 4-bit NormalFloat precision, so a 70B-class model can be fine-tuned on a single 80 GB GPU.

Definition#

QLoRA (Dettmers et al. 2023) combines LoRA with a quantized frozen base model. Three ingredients make it work: the 4-bit NormalFloat (NF4) data type, designed for normally distributed weights; double quantization, which quantizes the per-block scaling constants themselves, bringing their overhead to about 0.127 bits per parameter; and paged optimizers that move optimizer state to CPU memory during spikes.

During training, each 4-bit weight block is de-quantized to bf16 for the matrix multiply; gradients flow through the frozen weights into bf16 adapters. Memory per parameter of the frozen base falls from 2 bytes to about 0.52:

Trade-offs#

Steps are slower than bf16 LoRA because of de-quantization, and adapters are trained against a quantized approximation of the base. Merge adapters into a bf16 copy of the base before serving and re-run the evaluation. For a 7B model QLoRA needs about 7.3 GB including activations, against 17.9 GB for LoRA (memory model).

Bring us one task. We’ll show you what a specialist model can do.

A 45-minute briefing with a senior research engineer. You leave with a feasibility read, a data plan and a fixed quote, whether or not you hire us.

Book a briefing →