Skip to main content
Launch a fine-tune across every GPU on the box with one torchrun command — the trainer detects the distributed launch and handles DDP for you.
Multi-GPU is a launch mode, not a config flag. Run the trainer under torchrun and it loads the full model per rank, routes Unsloth through its DDP-safe checkpointing path, and lets only rank 0 save and publish.

Quick Start

1

One GPU (baseline)

Run the trainer normally — a single-process, single-GPU run.
2

Two GPUs

Launch the same config under torchrun. --nproc_per_node is the number of GPUs.
3

Two GPUs + checkpointing + resume

Add checkpoint keys to config.yaml so an interrupted run picks up where it left off.

How It Works

torchrun spawns one process per GPU; each loads the full model onto its own device, and only rank 0 touches the filesystem and the Hub.
Do not set device_map: "auto" or "balanced" for multi-GPU. Those are single-process model-parallel and conflict with DDP — the trainer sets device_map = {"": local_rank} for you under torchrun.

Environment Variables

torchrun sets the distributed variables automatically; you only set your Hugging Face token.

Configuration Options

The DDP-relevant keys — all optional, all live in config.yaml.

Checkpointing, Resume & Best-Checkpoint

Full reference for the checkpoint, eval, and early-stopping keys.

Common Patterns

Two GPUs on one node

The most common case — split a run across both cards on a single machine.

Resume after preemption

Set resume_from_checkpoint: true and re-launch the same command — rank 0 loads the latest checkpoint from output_dir.

Push checkpoints during training

Stream checkpoints to the Hub as they’re written — rank 0 handles every push.

Best Practices

The trainer defaults it to true under DDP so models with adapters that don’t fire in text-only training (e.g. Gemma 4 E4B’s vision/audio paths) don’t crash with “Expected to have finished reduction…”. Only set false on pure dense-text models for a small speedup.
Checkpoints add up fast across many steps. Set save_total_limit: 3 to keep only the most recent few and avoid filling the disk mid-run.
final_model_dir (default lora_model) is where rank 0 writes the final adapter and where post-training inference reloads it from. Keep it stable so load_model finds the adapter.
Those select single-process model-parallel and conflict with DDP. The trainer sets device_map = {"": local_rank} automatically when it detects a distributed launch.

Train

Fine-tuning overview and full config reference.

Checkpointing

Save, resume, and keep the best checkpoint.

Train CLI

Multi-GPU launch and resume from the CLI.

praisonai-train Package

Install and use training without the full wrapper.