You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Multi-node distributed training broken only in one-GPU-per-node setting (one-line fix) #4142
When running multi-node distributed training with each node having a single GPU (or reproducible with CUDA_VISIBLE_DEVICES=0), Unsloth incorrectly disables distributed training by patching accelerate.state.PartialState._prepare_backend to return DistributedType.NO.
This is because the check in unsloth/models/_utils.py only looks at DEVICE_COUNT (which comes from torch.cuda.device_count()), which returns the number of locally visible devices. It does not account for multi-node setups where each node may have only 1 visible GPU but WORLD_SIZE > 1.
Steps to Reproduce
Set up a 2-node distributed training run, each with 1 GPU per node or set CUDA_VISIBLE_DEVICES=0 on each node
Activity
Maxusmusti commentedon Mar 2, 2026
Worth noting that multi-node DP works great and entirely as expected otherwise (when each node has more than one GPU, even if only using one per node)
I will raise a PR very shortly with the tested fix!
Maxusmusti commentedon Mar 2, 2026
Put up the tested fix: #4143