Fix: prepare works even if nothing except tp specified (rare) (#3707)

This commit is contained in:
Matej Sirovatka
2025-08-05 13:07:37 +02:00
committed by GitHub
parent cb343c63d7
commit c173b4fdd6

View File

@ -1584,9 +1584,17 @@ class Accelerator:
return result if len(result) > 1 else result[0]
def _prepare_tp(self, *args):
# First pass: prepare everything except schedulers (and model, which is prepared separately below)
result = [
self._prepare_one(obj, first_pass=True) if not isinstance(obj, torch.nn.Module) else obj for obj in args
]
# Second pass: prepare schedulers
result = [self._prepare_one(obj) if not isinstance(obj, torch.nn.Module) else obj for obj in result]
device_mesh = self.torch_device_mesh
for arg in args:
for arg in result:
if not isinstance(arg, torch.nn.Module):
continue