From 7c9258b66736edf385dd13c4ecd15068c9c20576 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Mon, 25 Oct 2021 12:10:09 +0100 Subject: [PATCH] Fix reduce_across_processes inconsistent return type --- references/classification/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/references/classification/utils.py b/references/classification/utils.py index 9e043582d13..bf6689a9a8c 100644 --- a/references/classification/utils.py +++ b/references/classification/utils.py @@ -400,7 +400,9 @@ def store_model_weights(model, checkpoint_path, checkpoint_key="model", strict=T def reduce_across_processes(val): if not is_dist_avail_and_initialized(): - return val + # nothing to sync, but we still convert to tensor for consistency with the distributed case. + return torch.tensor(val) + t = torch.tensor(val, device="cuda") dist.barrier() dist.all_reduce(t)