Skip to content

Commit e1a8ad4

Browse files
authored
[Fix] Use fresh Accelerator instance in evaluator to avoid fragile attribute check (#699)
1 parent e316f86 commit e1a8ad4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lmms_eval/evaluator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import numpy as np
1414
import torch
1515
import torch.distributed as dist
16+
from accelerate import Accelerator
1617
from datasets import Image, Sequence
1718
from loguru import logger as eval_logger
1819
from tqdm import tqdm
@@ -660,8 +661,9 @@ def evaluate(
660661
else:
661662
results_dict = None
662663

663-
if hasattr(lm, "accelerator") and distributed_executor_backend == "accelerate":
664-
lm.accelerator.wait_for_everyone()
664+
if distributed_executor_backend == "accelerate":
665+
# this should work for torchrun as well since it internally calls torch.distributed.barrier()
666+
Accelerator().wait_for_everyone()
665667
elif distributed_executor_backend == "torchrun":
666668
dist.barrier()
667669
else:

0 commit comments

Comments
 (0)