A high-performance framework for fine-tuning large language models with multi-GPU support
Project description
OpenSloth
A multi-GPU training framework that combines Unsloth with multi-GPU support and sequence packing optimizations.
Core Components:
- Unsloth: 2x faster training with 75% VRAM savings
- Multi-GPU: NCCL-based distributed training across multiple GPUs
- Sequence Packing: Smart batching that reduces padding waste by up to 40%
The Result: Unsloth's efficiency × GPU count × sequence packing optimizations = speedups that often exceed theoretical maximums.
💾 Installation
conda create --name opensloth_env python=3.11
pip install uv
uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
pip install unsloth xformers opensloth
# or from source pip install git+https://github.com/anhvth/opensloth.git
⚡ Quickstart
# Basic multi-GPU training
python scripts/train.py
| Example | Description | Link/Command |
|---|---|---|
| Kaggle Notebook (T4x2) | Live training example on Kaggle's dual T4 GPU environment | 🔗 Qwen3 OpenSloth 2GPUs |
| Local Training Script | Check out the training script for configuration examples | python scripts/train.py |
| Local Jupyter Notebook | Interactive training notebook for local development | notebooks/train.ipynb |
⚡ Performance Benchmarks
opensloth vs Unsloth Direct Comparison
Controlled comparison with identical configurations:
- Model: Qwen3-8B-bnb-4bit
- Training Steps: 100 steps
- Global Batch Size: 32
Results:
- opensloth (2 GPUs): 8m 28s ⚡
- Unsloth (1 GPU): 19m 34s
- Performance Gain: ~2.3x faster
Why 2.3x Speedup on 2 GPUs?
OpenSloth achieves 2.3x speedup through three optimizations:
- ✅ Sequence packing: Smart batching reduces padding waste (learn more)
- ✅ Multi-GPU scaling: NCCL-based distributed training
- ✅ Load balancing: Even workload distribution across GPUs
Scaling Expectations:
- 2 GPUs: ~2.3x faster than single GPU
- 4 GPUs: ~4.6x faster than single GPU
- 8 GPUs: ~9.2x faster than single GPU
🏗 How It Works
OpenSloth combines three proven techniques:
1. Unsloth Foundation
- 2x faster training through optimized kernels
- 75% VRAM savings through memory efficiency
- Quality preservation with performance gains
2. Multi-GPU Distribution
- PyTorch DDP: Standard distributed data parallel training
- NCCL backend: Efficient gradient synchronization
- Process spawning: One process per GPU for optimal scaling
3. Sequence Packing
Based on the Hugging Face sequence packing approach:
- Length sorting: Groups sequences by similar lengths
- Smart batching: Minimizes padding tokens within batches
- Round-robin distribution: Balances workload across GPUs
- Up to 40% token savings: Reduces computational waste
🔧 Quick Tips
For faster iteration:
- Start with smaller models:
unsloth/Qwen3-0.6b-bnb-4bit - Test single GPU first: modify
gpus=[0]in script - Use fewer samples for quick testing
Recommended Configuration:
# Optimize for sequence packing and multi-GPU efficiency
TrainingConfig(
per_device_train_batch_size=4, # Larger batches per GPU
gradient_accumulation_steps=8, # Fewer gradient sync operations
# Effective batch size = 4 * 8 * num_gpus
)
🔧 Troubleshooting
Single GPU Testing:
# In your training script, change:
gpus = [0] # Use only first GPU for debugging
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opensloth-0.1.5.tar.gz.
File metadata
- Download URL: opensloth-0.1.5.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
760471cb4fc3a062f14fdab43f0494089309aa4f666fd15947321c0a36cbfe7f
|
|
| MD5 |
37b8f9a2c6885eeb2971b2f7e5faad35
|
|
| BLAKE2b-256 |
e73b7a634dd3d7531c0fa59e358fa7145a7cd6d34228a8bd5e3e587cef66e1c2
|
File details
Details for the file opensloth-0.1.5-py3-none-any.whl.
File metadata
- Download URL: opensloth-0.1.5-py3-none-any.whl
- Upload date:
- Size: 41.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd5eb00098b86b97d2c6f72bb8ad3f82eab6f032b050a570916ed82ecf80b495
|
|
| MD5 |
cb222b55d9edc72053532e7d00ff2563
|
|
| BLAKE2b-256 |
e04d13780d4ad665f80b12963282b895d00c3c4a15c965611a2b8cdc9a91ed10
|