OpenSloth 🦥⚡
Scale Unsloth to multiple GPUs with just torchrun. No configuration files, no custom frameworks - pure PyTorch DDP.
- 🚀 2-4x faster than single GPU
- 🎯 Zero configuration - works out of the box
- 💾 Same VRAM per GPU as single GPU Unsloth
- 🔧 Any Unsloth model - Qwen, Llama, Gemma, etc.
Installation
# Install dependencies
uv add torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
uv add unsloth datasets transformers trl
uv add git+https://github.com/anhvth/opensloth.git
Quick Start
Replace python with torchrun:
# Single GPU
python train_scripts/train_ddp.py
# Multi-GPU
torchrun --nproc_per_node=2 train_scripts/train_ddp.py # 2 GPUs
torchrun --nproc_per_node=4 train_scripts/train_ddp.py # 4 GPUs
OpenSloth automatically handles GPU distribution, gradient sync, and batch sizing.
Performance
| Setup | Time | Speedup |
|---|---|---|
| 1 GPU | 19m 34s | 1.0x |
| 2 GPUs | 8m 28s | 2.3x |
Expected scaling: 2 GPUs = ~2.3x, 4 GPUs = ~4.5x, 8 GPUs = ~9x
Usage
from unsloth import FastLanguageModel
from trl import SFTConfig, SFTTrainer
from opensloth.patching.ddp_patch import ddp_patch
ddp_patch() # Enable DDP compatibility
# Standard Unsloth setup
local_rank = int(os.environ.get("LOCAL_RANK", 0))
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="unsloth/Qwen3-0.6B",
device_map={"": local_rank},
load_in_4bit=True,
)
model = FastLanguageModel.get_peft_model(model, r=16)
trainer = SFTTrainer(model=model, tokenizer=tokenizer, ...)
trainer.train()
Run: torchrun --nproc_per_node=4 your_script.py
Migration from Old Approach
Current (Recommended): Simple torchrun + DDP patch
from opensloth.patching.ddp_patch import ddp_patch
ddp_patch()
# ... standard Unsloth code
Old Approach (v0.1.8): For complex configuration files, use:
git checkout https://github.com/anhvth/opensloth/releases/tag/v0.1.8
Links
- Unsloth - 2x faster training library
- TRL - Transformer Reinforcement Learning
- PyTorch DDP - Distributed training
git clone https://github.com/anhvth/opensloth.git
cd opensloth
torchrun --nproc_per_node=4 train_scripts/train_ddp.py
Happy training! 🦥⚡
Metadata
Release files for opensloth 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| opensloth-0.2.1.tar.gz | 3.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opensloth-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.1 MB
Release files / opensloth-0.2.1.tar.gz
| Download URL | opensloth-0.2.1.tar.gz |
|---|---|
| Size | 3.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
751b124a5b18c1fb8082c59174fb2a1fd246337e6c837d7a7ae39aa710726397
|
|
BLAKE2b-256 checksum How to use checksums |
0af85db26144a96ceb08b3e85aaac711b0bcb9efe8c548d7f577f94f53770b1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.0 CPython/3.12.11 Linux/5.4.0-216-generic
|
Release files / opensloth-0.2.1-py3-none-any.whl
| Download URL | opensloth-0.2.1-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6bd0dd918add6324c15be5b4acb7cc7964e761fc4a691774cd5fba8c1f0255e9
|
|
BLAKE2b-256 checksum How to use checksums |
9178debf3a8a5b1f2207aa4a756b1554ba8a2b2606e311dd083645eafc198d6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.0 CPython/3.12.11 Linux/5.4.0-216-generic
|