Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Fix multi-node distributed training with single GPU per node (#4143)

Mustafa Eyceoz6762a380e36d
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index f883d466f06..86849914311 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):