A PEFT adapter checkpoint does not contain all base-model weights; adapter config and adapter weights depend on the base model.
Understand adapter_model.safetensors, adapter_config.json, Trainer checkpoints, resume_from_checkpoint, merge_and_unload, quantized merging and validation.
A PEFT adapter checkpoint does not contain all base-model weights; adapter config and adapter weights depend on the base model.
`merge_and_unload()` is not in-place; you must assign the returned model.
After merging, PEFT-specific functionality is removed, and some quantization/PEFT combinations may not support merging.
A PEFT adapter saved with `save_pretrained()` is a small inference artifact. A Trainer checkpoint can include optimizer, scheduler, RNG and training state for resuming. A merged model is a standalone base-plus-adapter model.
A typical LoRA adapter directory includes `adapter_model.safetensors` and `adapter_config.json`. If the tokenizer changed, ship tokenizer files too. If embeddings were resized or trained, follow PEFT embedding-save guidance.
To continue the exact training state, optimizer state, scheduler step, global step and RNG state matter. Loading only the adapter continues weights but does not reproduce the original optimizer/scheduler trajectory.
If base model revision, tokenizer, PEFT config, dataset preprocessing or package versions changed, a checkpoint may load but behave differently. Store model revision, environment and dataset fingerprint with each run.
PEFT's official pattern is `model = model.merge_and_unload()`. The result is a standalone model without normal PEFT adapter switching/disable features. Use merge_adapter/unmerge_adapter when reversible merging is needed.
During 4-bit training the base model uses quantized representations. Many workflows reload the base model in the target output dtype and merge the adapter there. Direct merging into quantized modules is not universally supported.
Wrong base revision, tokenizer mismatch, dtype changes, adapter scaling, missing resized embeddings or unmerged modules can change outputs. Run deterministic A/B tests before and after merging.
Start a fresh Python process and load from disk. Compare adapter-loaded and merged outputs on fixed prompts; print dtypes, vocab size, EOS/PAD IDs and generation config. Success in the original process is not enough.
Instead of keeping every checkpoint forever, retain the best metric checkpoint, latest resumable checkpoint and selected milestones. Adapter files are small, but optimizer states can be large.
| Artifact | Purpose | For resume |
|---|---|---|
| adapter_model.safetensors | LoRA weights | Not full state alone |
| adapter_config.json | PEFT config | Required context |
| Trainer checkpoint | Optimizer/scheduler/state | Yes |
| Merged model | Standalone inference | No |
Do not blindly upgrade packages in a working training environment. Record GPU, driver, CUDA/PyTorch runtime, Transformers, Accelerate, PEFT, TRL, bitsandbytes/Diffusers, model revision and dataset fingerprint for every run. Reproduce minimally before changing production training.
It transforms the in-memory model; adapter files on disk remain unless you delete them.
Not through normal PEFT adapter controls. Keep the adapter separately or use reversible merge_adapter workflows.
Evaluate model size, precision, context, batch, LoRA/QLoRA or full fine-tuning and multi-GPU needs together instead of choosing by GPU name alone.