Full fine-tuning and PEFT
| Method | Base weights | Trainable parameters |
|---|---|---|
| Full fine-tuning | BF16 / FP16 / FP32 | All |
| LoRA | Frozen (BF16 / FP16) | Adapters |
| QLoRA | Frozen (NF4) | Adapters |
Full fine-tuning starts from an existing model, not from scratch, and can update all its trainable parameters. Parameter-efficient fine-tuning (PEFT) limits the parameters updated; LoRA and QLoRA belong to this family. [1][2]
The training objective is separate from the update method. Supervised fine-tuning (SFT), continued domain pretraining and preference optimization can use different update methods. SFT does not imply full fine-tuning.
How LoRA works
For a linear matrix W of shape d_out × d_in, LoRA introduces A (r × d_in) and B (d_out × r). Classical LoRA computes Wx + (α/r)BAx; W is frozen and the optimizer updates A and B. The rank of BA is at most r. [1][3]
Rank r controls adapter capacity, α scales its contribution and dropout may reduce overfitting. Higher rank does not guarantee improvement. Target attention projections, MLP layers or a wider set of linear layers; some variants use scaling such as α/√r. [3]
For any linear layer, the adapter contains r × (d_in + d_out) parameters, whereas the base matrix contains d_in × d_out. For multiple adapters, sum the counts over all targeted matrices and separately include any trained biases, embeddings and other modules. The formula excludes those additional parameters. [1][3]
For one 4096 × 4096 matrix with r = 16, full updating involves 16,777,216 parameters and the adapter 131,072: 0.78125% of that matrix, or 128 times fewer. The fraction of the entire model depends on the dimensions and number of targeted layers.
Typical LoRA initialization assigns random values to A and zeros to B. The initial BA update is zero, so the adapter initially leaves the layer function unchanged unless another initialization scheme is used. PEFT defaults to Kaiming initialization for A. [1][3]
Freezing W does not detach the whole model from the differentiation graph. Gradients with respect to layer inputs are still needed to train earlier adapters. Updates and optimizer states for W are omitted, but activations, the forward pass and part of backpropagation remain. [1][2]
How QLoRA works
Input x ├─ Base computation: dequant(Wq)x └─ Adapter contribution: (α/r)BAx Sum: dequant(Wq)x + (α/r)BAx ↓ Output
Use dequantized weights for base computation.
QLoRA stores frozen base weights in four bits and backpropagates through computations using these weights into trainable adapters. In the classical implementation, weight blocks are dequantized for higher-precision computation, such as BF16. It does not update all weights in four bits. [2][4]
The original method uses NF4 (NormalFloat), double quantization of quantization constants and paged optimizers to handle memory spikes. NF4 is designed for normally distributed weights, not error-free quantization. Paging can introduce extra transfers. [2][4]
The authors demonstrated fine-tuning a 65B model on one 48 GB GPU under specific experimental conditions. This does not guarantee arbitrary sequence lengths, batch sizes or architectures will fit. [2]
NF4 uses 16 representable levels and blockwise scaling. Double quantization also quantizes scale constants; it does not reduce the weights again to two bits. The QLoRA authors report average savings of about 0.37 bits per parameter relative to unquantized constants in their setup. This is not a universal overhead for all formats. [2]
GPU memory and training costs
| Method | Weights and training states (GB) |
|---|---|
| Full fine-tuning | 112 |
| LoRA | 14.32 |
| QLoRA | 3.82 |
Consider a hypothetical 7B model and 20 million trainable adapter parameters. BF16 base weights alone require 14 GB; ideal four-bit storage requires 3.5 GB (decimal units). Quantization metadata and higher-precision layers add overhead.
Assume full fine-tuning uses 2 bytes of BF16 weights, 2 of BF16 gradients, 8 of FP32 Adam moments and 4 of FP32 master weights per parameter: 16 bytes, or 112 GB for 7B, excluding activations and buffers. Not every implementation keeps FP32 master weights; precision, optimizer and sharding affect the result.
Under the same assumption, 20 million adapter parameters require 0.32 GB for weights, gradients and optimizer state including master weights. Adding the base gives 14.32 GB for LoRA or 3.82 GB for QLoRA. These are not VRAM measurements or guarantees of training on an 8 GB GPU. Activations, sequence length, batch size and buffers can dominate memory.
Gradient checkpointing trades saved activations for recomputation. Gradient accumulation increases effective batch size without proportionally increasing microbatch size. Sharding changes per-device memory but can increase communication.
In the 7B example, storing the 20-million-parameter adapter alone in BF16 takes 40 MB (about 38.15 MiB), excluding configuration and extra trained modules. This differs from the 320 MB of adapter training states in the assumed memory model. Gradient checkpointing recomputes some activations rather than permanently eliminating them.
Quality, data and evaluation
LoRA can approach full fine-tuning on particular tasks; the original papers demonstrate results under their own experimental conditions, not universal equivalence. [1][2] Major domain shifts may expose low-rank capacity limits, and quantization introduces separate error.
Define acceptance criteria: factual accuracy, output format, domain performance, undesirable-action refusals and retention of general capabilities. Separate training, validation and test data; remove duplicate and near-duplicate examples across splits. Check licenses and personal data. Do not select settings using the final test set.
Compare the base model and adaptation methods on identical tasks, chat templates and generation budgets. Report quality, peak memory, training time, processed tokens and cost per accepted result. Repeat runs when variability matters.
LoRA Learns Less and Forgets Less compares instruction fine-tuning and continued domain training in programming and mathematics. In typical low-rank settings, LoRA performed worse in the target domain but retained earlier capabilities better. Evaluate both target quality and out-of-domain regressions. Do not automatically generalize these findings to other models. [5]
Shuttleworth and colleagues’ NeurIPS study found different spectral structures in weight matrices after LoRA and full fine-tuning, even when downstream performance was similar. The authors also observed difficulties with successive adaptation stages. For continual learning, therefore, test regressions after each stage rather than only after the last. [7]
The Thinking Machines Lab experimental report, covering Llama 3 and Qwen3 models, shows that with suitable hyperparameters LoRA can match full fine-tuning on smaller instruction and reasoning datasets. Performance can deteriorate when adaptation demands grow or in certain large-batch regimes. These are findings from particular experiments, not a universal equivalence guarantee. [8]
Training configuration and workflow
Start with a small experiment, for example r = 8, 16 or 32, then tune scaling, learning rate, target layers and steps using validation. These are starting points, not universal optima. Record the base revision, tokenizer, libraries, data, seed and configuration.
For QLoRA verify NF4 and computation precision support on the target hardware. PEFT documents targeting eligible linear layers; inspect architecture-specific exceptions such as the output layer. [4] Check padding and label masking, and decide which assistant-response tokens contribute to the loss.
An adapter checkpoint alone may not resume training: optimizer, scheduler, random-generator states and data position may be necessary. Test loading artifacts in a separate environment.
In the QLoRA LLaMA 7B Alpaca experiments, adapting only query and value projections did not reproduce full fine-tuning performance. Targeting all linear transformer-block layers mattered in that experiment. PEFT's target_modules="all-linear" is a starting point, not a guarantee of identical parameter coverage for every architecture. Inspect the trainable parameter list and count. [2][3][4]
An ICML study describes how the optimal learning rate depends on adapter initialization and LoRA scaling: in the configurations analyzed, it can remain approximately constant as rank changes or scale inversely with rank. Do not automatically transfer settings between variants; compare configurations after tuning their learning rates separately. [9]
In a study by Lee and colleagues, available as a preprint, conventional LoRA and four variants achieved similar peak performance on the tested mathematical and code-generation tasks once learning rates were tuned. This does not establish equivalence to full fine-tuning or QLoRA. When comparing variants, allow comparable hyperparameter-search budgets and use an independent test set. [10]
Deployment and adapter merging
Keep LoRA as an independent adapter with a compatible base revision or merge it when the format and implementation support this. Higher-precision merging removes separate adapter computation but does not guarantee bitwise equality. Separate adapters simplify task switching. [3]
Merging QLoRA into a quantized base may require dequantization and requantization, changing outputs and introducing further rounding errors. Some formats do not support merging. [4] Evaluate the exact deployed artifact.
Adapter training does not determine inference precision or API pricing. Measure latency, throughput, concurrency and KV memory in the deployment environment. An adapter needs its compatible base; it is not a complete model.
Distinguish three artifacts: the adapter with the training-time quantized base, the adapter with the original higher-precision base, and a merged, possibly requantized model. QLoRA optimizes the adapter against a quantized base, so the original base may change outputs. Keep the separate adapter and record the base identifier and revision. PEFT's adapter_model.safetensors and adapter_config.json do not normally contain the full model. [6][3]
Choosing a method
RAG vs Fine-tuning vs Long Context
For style, format or narrow task adaptation, begin with LoRA if the base fits, or QLoRA when memory is limiting. Consider full fine-tuning if adapter results fail requirements and a controlled experiment is affordable.
For current documents or changing facts, consider retrieval-augmented generation (RAG). Fine-tuning cannot guarantee factual accuracy, citations or freshness. Constrained decoding and schema validation may be more effective for enforcing output format.
In a hypothetical experiment LoRA takes 20 GPU-hours and QLoRA takes 25 at USD 2 per GPU-hour, costing USD 40 and 50. Lower memory does not guarantee shorter training or lower cost, but QLoRA may enable cheaper hardware. Include data, evaluation, deployment and maintenance costs.
Before release, record acceptance criteria and define a rollback procedure. For example, require a target classification accuracy, a limit on general-task regression and no policy violations in the test set. Independently test the merged version, deployment format and adapter-disabled baseline. An absence of detected violations is not proof of complete safety.
For a comparison with retrieval and long-context prompting, see RAG vs Fine-tuning vs Long Context. [11]
