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.
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 inconfig.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
Setresume_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
Leave ddp_find_unused_parameters at the default for multimodal / MoE
Leave ddp_find_unused_parameters at the default for multimodal / MoE
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.Set save_total_limit to bound disk
Set save_total_limit to bound disk
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.Always set final_model_dir to a stable path
Always set final_model_dir to a stable path
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.Don't use device_map auto/balanced under torchrun
Don't use device_map auto/balanced under torchrun
Those select single-process model-parallel and conflict with DDP. The trainer sets
device_map = {"": local_rank} automatically when it detects a distributed launch.Related
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.

