Skip to content

Commit

Permalink
quick fix (#367)
Browse files Browse the repository at this point in the history
* quick fix

* another fix

---------

Co-authored-by: Tuan Tran <[email protected]>
  • Loading branch information
antoine-tran and Tuan Tran authored Feb 29, 2024
1 parent 0cb619d commit fb6e3fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fairseq2/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,18 @@ def sync_and_compute_metrics(*bags: MetricBag) -> Optional[Dict[str, Any]]:
if not bags:
return None

gang = bags[0].gang
gang = bags[0]._gang

if len(bags) == 1:
all_metrics = bags[0].metrics
all_metrics = bags[0]._metrics
else:
all_metrics = {}

for bag in bags:
if bag.gang is not gang:
if bag._gang is not gang:
raise ValueError("All metric bags in `bags` must use the same gang.")

all_metrics.update(bag.metrics)
all_metrics.update(bag._metrics)

if gang.size == 1:
values = {name: m.compute() for name, m in all_metrics.items()}
Expand Down

0 comments on commit fb6e3fb

Please sign in to comment.