mirror of
https://github.com/huggingface/accelerate.git
synced 2025-10-20 10:03:46 +08:00
Fix: prepare works even if nothing except tp specified (rare) (#3707)
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user