Skip to main content

A high-performance framework for fine-tuning large language models with multi-GPU support

Project description

opensloth Logo

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: 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

📊 View Full WandB Comparison

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: Distributed training across GPUs
  • 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

🔧 Quick Tips

  • Enable packing, set bz=1, long sequence length (8k, 16k, etc.) with larger gradient accumulation steps (64, 128). Unsloth's will automatically handle sequence packing on global batch to optimize gpu utilization.

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

📖 Documentation

How to Prepare and Store a Trainer Dataset

Follow these steps to extract and save a dataset from an Unsloth notebook:

  1. Visit the Unsloth Notebooks Documentation.

  2. Select the notebook for your target model.

  3. Export the notebook to a Python script.

  4. Copy all code up to (but not including) trainer.train().

  5. Run the code to initialize the trainer.

  6. Save the trainer's dataset:

    trainer.train_dataset.save_to_disk("data/cache_qwen3_dataset")
    

This will store the processed dataset for later use.

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

opensloth-0.1.7.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opensloth-0.1.7-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file opensloth-0.1.7.tar.gz.

File metadata

  • Download URL: opensloth-0.1.7.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.11 Linux/6.8.0-59-generic

File hashes

Hashes for opensloth-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e564e5c1be1e02e5fa730f1af2d87d2049603673c025314217e793ce5f2e5c05
MD5 3388dd91d6d0400b36cffa3d4208830e
BLAKE2b-256 c23082a200f2ae7ae4b7a4cce3d756e51f9ea8bc091c294d14eed62185f94927

See more details on using hashes here.

File details

Details for the file opensloth-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: opensloth-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 43.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.11 Linux/6.8.0-59-generic

File hashes

Hashes for opensloth-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a6adcda00ecc1a90787d033cd148b9da8f49beb9b69e38e53c9f627d09731157
MD5 42a5e4a73628f9bf85a0aee99bf383a8
BLAKE2b-256 95ed1f7783a073671b9fba4fd8e1745a31c3d9148b41ad053e92e4a590985879

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page