Unsloth Integration
Unsloth provides optimized training for LoRA fine-tuning, significantly reducing training time and memory usage.Requirements
Supported Model Architectures
Unsloth is optimized for specific model families:
Other model architectures will fall back to standard training with a warning.
Quick Start
Parameters
Python API
With Quantization
Unsloth works with int4 and int8 quantization for reduced memory usage:How It Works
When Unsloth is enabled and requirements are met:- Uses
FastLanguageModelfrom Unsloth library for optimized model loading - Applies optimized gradient checkpointing (
use_gradient_checkpointing="unsloth") - Automatically configures LoRA target modules:
q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj - Integrates with PEFT for efficient adapter training
Fallback Behavior
If Unsloth cannot be used, training continues with standard transformers/PEFT:- Unsloth not installed: Warning logged, continues without Unsloth
- Unsupported model type: Warning logged, continues without Unsloth
- Unsupported trainer: Unsloth not applied (only SFT supported)
ShareGPT Mapping
Use--use-sharegpt-mapping to preserve ShareGPT format instead of converting:
Next Steps
LoRA/PEFT
Efficient fine-tuning techniques
Quantization
Reduce memory with quantization