Arama Yap Mesaj Submit
Request a Callback
+90
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro

Contact Us

Location Halkali merkez neighborhood fatih st ozgur apt no 46 , Kucukcekmece , Istanbul , 34303 , TR
EKA SUNUCU · AI TRAINING ERROR CENTER

LoRA/QLoRA Save, Resume, Merge and Unload and Checkpoint Guide

Understand adapter_model.safetensors, adapter_config.json, Trainer checkpoints, resume_from_checkpoint, merge_and_unload, quantized merging and validation.

PyTorchTransformersPEFT / TRLLast technical review: 14 August 2026
01

Key facts verified with official documentation

01

A PEFT adapter checkpoint does not contain all base-model weights; adapter config and adapter weights depend on the base model.

02

`merge_and_unload()` is not in-place; you must assign the returned model.

03

After merging, PEFT-specific functionality is removed, and some quantization/PEFT combinations may not support merging.

02

Three different artifacts: adapter, Trainer checkpoint, merged model

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.

03

What should be in an adapter folder?

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.

04

Adapter weights alone are not enough for exact resume

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.

05

Checks before `resume_from_checkpoint`

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.

06

Correct `merge_and_unload()` usage

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.

07

Why QLoRA merging is more sensitive

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.

08

Why quality can change after merging

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.

09

Validation after saving

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.

10

Checkpoint retention strategy

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.

DIAGNOSTIC MATRIX

What each artifact is for

ArtifactPurposeFor resume
adapter_model.safetensorsLoRA weightsNot full state alone
adapter_config.jsonPEFT configRequired context
Trainer checkpointOptimizer/scheduler/stateYes
Merged modelStandalone inferenceNo
Production note

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.

FAQ

Frequently asked questions

Does `merge_and_unload()` delete adapter files?

It transforms the in-memory model; adapter files on disk remain unless you delete them.

Can I unmerge after merge_and_unload?

Not through normal PEFT adapter controls. Keep the adapter separately or use reversible merge_adapter workflows.

OFFICIAL SOURCES

Official technical sources and project issues

CLUSTER

Related AI training guides

EKA SUNUCU · GPU ALTYAPISI

Choose the GPU around the training configuration.

Evaluate model size, precision, context, batch, LoRA/QLoRA or full fine-tuning and multi-GPU needs together instead of choosing by GPU name alone.

GPU Sunucu VPS Destek
Top