Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions esm/pretrained.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ def ESMC_300M_202412(device: torch.device | str = "cpu", use_flash_attn: bool =
tokenizer=get_esmc_model_tokenizers(),
use_flash_attn=use_flash_attn,
).eval()
load_torch_model(model, data_root("esmc-300"))
# The 300M repo ships a single legacy .pth (no safetensors), so load it
# explicitly like the ESM3 loaders above rather than via load_torch_model,
# which (safe=True) expects a safetensors checkpoint in the directory.
state_dict = torch.load(
data_root("esmc-300") / "data/weights/esmc_300m_2024_12_v0.pth",
map_location=device,
)
model.load_state_dict(state_dict, assign=True)
model = model.to(device)
return model

Expand All @@ -86,7 +93,14 @@ def ESMC_600M_202412(device: torch.device | str = "cpu", use_flash_attn: bool =
tokenizer=get_esmc_model_tokenizers(),
use_flash_attn=use_flash_attn,
).eval()
load_torch_model(model, data_root("esmc-600"))
# The 600M repo ships a single legacy .pth (no safetensors), so load it
# explicitly like the ESM3 loaders above rather than via load_torch_model,
# which (safe=True) expects a safetensors checkpoint in the directory.
state_dict = torch.load(
data_root("esmc-600") / "data/weights/esmc_600m_2024_12_v0.pth",
map_location=device,
)
model.load_state_dict(state_dict, assign=True)
model = model.to(device)
return model

Expand Down