Skip to content

Commit

Permalink
add ema to BaseTrainer init
Browse files Browse the repository at this point in the history
  • Loading branch information
IliasChair14 committed Nov 16, 2024
1 parent 90a3cf2 commit 717ebce
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/fairchem/core/trainers/base_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def __init__(
self.cpu = cpu
self.epoch = 0
self.step = 0
self.ema = None

if torch.cuda.is_available() and not self.cpu:
logging.info(f"local rank base: {local_rank}")
Expand Down Expand Up @@ -617,7 +618,7 @@ def load_checkpoint(
"Loading checkpoint in inference-only mode, not loading keys associated with trainer state!"
)

if "ema" in checkpoint and checkpoint["ema"] is not None:
if "ema" in checkpoint and checkpoint["ema"] is not None and self.ema:
self.ema.load_state_dict(checkpoint["ema"])
else:
self.ema = None
Expand Down

0 comments on commit 717ebce

Please sign in to comment.