Fix: truth value of tensor with more than 1 variable is unambiguous

This commit is contained in:
S1ro1
2025-09-23 12:17:17 +00:00
parent 14383311c2
commit a98a6f0c98

View File

@ -2862,7 +2862,7 @@ class Accelerator:
self.unscale_gradients() self.unscale_gradients()
parameters = [p for p in parameters] parameters = [p for p in parameters]
for model in self._models: for model in self._models:
if parameters == [p for p in model.parameters()]: if set(parameters) == set(model.parameters()):
if not self.is_fsdp2: if not self.is_fsdp2:
return model.clip_grad_norm_(max_norm, norm_type) return model.clip_grad_norm_(max_norm, norm_type)
else: else: