Skip to content

Commit 3783f3f

Browse files
authored
Fix reduce_across_processes inconsistent return type (#4733)
1 parent 9ae833a commit 3783f3f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

references/classification/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ def store_model_weights(model, checkpoint_path, checkpoint_key="model", strict=T
403403

404404
def reduce_across_processes(val):
405405
if not is_dist_avail_and_initialized():
406-
return val
406+
# nothing to sync, but we still convert to tensor for consistency with the distributed case.
407+
return torch.tensor(val)
408+
407409
t = torch.tensor(val, device="cuda")
408410
dist.barrier()
409411
dist.all_reduce(t)

0 commit comments

Comments
 (0)