Skip to content

Commit

Permalink
Add Aurora.load_checkpoint_local
Browse files Browse the repository at this point in the history
  • Loading branch information
wesselb committed Sep 9, 2024
1 parent 52a1ea0 commit 465438c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion aurora/model/aurora.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,20 @@ def load_checkpoint(self, repo: str, name: str, strict: bool = True) -> None:
strict (bool, optional): Error if the model parameters are not exactly equal to the
parameters in the checkpoint. Defaults to `True`.
"""
path = hf_hub_download(repo_id=repo, filename=name)
self.load_checkpoint_local(path)

def load_checkpoint_local(self, path: str, strict: bool = True) -> None:
"""Load a checkpoint directly from a file.
Args:
path (str): Path to the checkpoint.
strict (bool, optional): Error if the model parameters are not exactly equal to the
parameters in the checkpoint. Defaults to `True`.
"""
# Assume that all parameters are either on the CPU or on the GPU.
device = next(self.parameters()).device

path = hf_hub_download(repo_id=repo, filename=name)
d = torch.load(path, map_location=device, weights_only=True)

# Rename keys to ensure compatibility.
Expand Down

0 comments on commit 465438c

Please sign in to comment.