Weights · 14 min read · Updated 2026-07-24
Fine-tuning, LoRA, and QLoRA
How full-parameter and parameter-efficient tuning update a model, what an adapter contains, and how training choices affect deployment.
Key idea
LoRA reduces the parameters and optimizer state you train; it does not remove the need for a compatible base model, activations, careful data, or independent evaluation.
Fine-tuning updates a pretrained model
Fine-tuning continues gradient-based training from an existing checkpoint using a narrower objective or dataset. It can teach a task, domain, response format, language, style, tool protocol, or preference. Supervised instruction tuning is one common form of fine-tuning, but the term also includes continued task training and adapter-based updates.
The starting checkpoint matters as much as the method. Fine-tuning a base model and fine-tuning an instruct model do not begin from the same behavior. The tokenizer, chat template, license, context configuration, and architecture of the selected revision become dependencies of the result.
- Trainable weights
- Small low-rank adapter matrices
- Base weights
- Frozen
- Optimizer state
- Much smaller than full tuning
- Release artifact
- An adapter, or a merged checkpoint
- Useful when
- You need efficient specialization or several swappable behaviors.
Full-parameter tuning versus PEFT
Full fine-tuning computes updates for every model parameter. It offers maximum freedom to change the model but requires gradient storage, optimizer state, activations, and a complete output checkpoint. The optimizer state alone can be several times larger than the inference weights depending on precision and optimizer.
Parameter-efficient fine-tuning, or PEFT, freezes most base weights and trains a much smaller set of added or selected parameters. This lowers optimizer-state and checkpoint-storage costs. It can also make it practical to maintain several specialized adapters over one shared base model.
PEFT is not automatically equal to full tuning for every task. The needed behavior change, adapter placement, rank, dataset, and optimization settings determine whether the restricted update space is sufficient.
LoRA learns low-rank weight updates
LoRA freezes an existing weight matrix and learns a low-rank update represented by two smaller matrices. During inference, the update can be applied alongside the base matrix or merged into a copy of the base checkpoint.
The rank controls the dimensionality of the learned update, while target modules determine where adapters are inserted. Rank, scaling, dropout, target layers, and which modules remain fully trainable are model and task choices rather than universal defaults.
An adapter file is not a standalone model. It must identify the exact base model and revision whose tensor names and shapes it expects. Loading an adapter onto a merely similar checkpoint can fail or silently produce incorrect behavior.
QLoRA reduces the base-weight training footprint
QLoRA keeps the base model frozen in a quantized representation while training LoRA adapters. This reduces the memory occupied by base weights during training and enables adapter tuning of models that would be difficult to hold at full precision.
The forward and backward passes still require activations and higher-precision computation in selected places. QLoRA therefore does not make training memory equal to the adapter file size. Sequence length, batch size, gradient accumulation, activation checkpointing, optimizer choice, and distributed strategy remain major factors.
The output is normally an adapter tied to the original base checkpoint. Merging may require materializing a higher-precision base and should be treated as a new artifact with its own size, provenance, and evaluation.
Training data and loss masks define the behavior
Fine-tuning examples must use the tokenizer and prompt format expected by the model. For chat models, that usually means applying the correct chat template rather than manually concatenating role labels. Tool-use data must preserve the exact schema and turn boundaries used at inference time.
Loss masking determines which tokens contribute to the update. Training only on assistant tokens differs from training on the full conversation. Padding, packing multiple examples, truncation, and end-of-sequence handling can also change what the model learns.
Before a long run, inspect tokenized examples rather than only the source JSON. Decode representative batches, verify masks, measure length distributions, and confirm that no answer is accidentally truncated or exposed in the prompt.
Optimization choices interact
Learning rate, effective batch size, sequence length, warmup, scheduler, weight decay, number of epochs, adapter rank, and data mixture cannot be tuned independently. A larger effective batch can change the useful learning-rate range; longer packed sequences can alter example balance.
Track training and validation loss, but do not use loss as the sole decision rule. A lower loss can accompany worse instruction behavior or stronger memorization. Save intermediate checkpoints so behavioral evaluations can identify an earlier, better stopping point.
For LoRA, report the target modules, rank, alpha or scaling rule, dropout, trainable parameter count, base revision, and whether additional modules were saved. Without those fields, another person cannot reproduce or correctly load the adapter.
Evaluate and package the tuned result
Compare the tuned model with its exact base checkpoint on target tasks and retention tests. Use the same inference template and decoding settings. Add adversarial or out-of-domain tests so specialization does not hide a broad regression.
Release adapters and merged checkpoints as different artifacts. The adapter should carry structured base_model metadata. A merged checkpoint should explain the merge precision and whether it was quantized afterward. Neither should inherit the base model's benchmark results without measurement.
Deployment support must also be verified. Some runtimes can load LoRA adapters dynamically, while others require a merge or support only specific target modules. Runtime compatibility is part of the release evidence, not an assumption based on the file extension.
- Pin the base model repository and revision.
- Publish tokenizer and chat-template dependencies.
- Record training method, data categories, and loss masking.
- Report adapter configuration and trainable parameter count.
- Evaluate target improvement and capability retention.
- Separate adapter, merged, and quantized artifacts.