From 6762a380e36d91a85a6fea24f3fbc144f6bb8165 Mon Sep 17 00:00:00 2001 From: Mustafa Eyceoz Date: Tue, 3 Mar 2026 09:45:41 -0500 Subject: [PATCH] Fix multi-node distributed training with single GPU per node (#4143) --- unsloth/models/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index f883d466f0..8684991431 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -1473,7 +1473,7 @@ BitsAndBytesConfig__init__ = BitsAndBytesConfig__init__.replace( ) exec(BitsAndBytesConfig__init__, globals()) -if DEVICE_COUNT == 1: +if DEVICE_COUNT == 1 and int(os.environ.get("WORLD_SIZE", "1")) <= 1: from accelerate.utils.dataclasses import DistributedType def _prepare_backend(self, *args, **kwargs):