Fix: properly error when DDP + Dtensor model by S1ro1 · Pull Request #3629 · huggingface/accelerate
A rather tiny PR, "fixes" or more likely errors properly on an issue introduced in #3628. The issue is that DDP doesn't work if model has DTensors which it has if it was loaded with device_map="auto" (it applies TP). Now we properly raise an Error.
Snippet to test:
from transformers import AutoModelForCausalLM from accelerate import Accelerator model_id = "NousResearch/Hermes-3-Llama-3.1-8B" accelerator = Accelerator() model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto") model = accelerator.prepare(model)
Before:
[rank0]: AssertionError: found no DeviceMesh from dtensor args for c10d.broadcast_.default!
After:
[rank0]: ValueError: Your model contains DTensorparameters, which is incompatible with DDP. Maybe you loaded your model withdevice_map='auto'?
cc @SunMarc