Skip to content

Commit f318fe2

Browse files
authored
set weights_only=True to resolve security concern (#1409)
Closes BIO-15 --------- Signed-off-by: Peter St. John <pstjohn@nvidia.com>
1 parent e2150f8 commit f318fe2

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

bionemo-recipes/recipes/codonfm_ptl_te/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ notebook_shim==0.2.4
156156
notebook==7.4.5
157157
numpy==1.26.4
158158
nvidia-dali-cuda130==1.51.2
159-
nvidia-resiliency-ext==0.4.1+cuda13
159+
nvidia-resiliency-ext==0.4.1
160160
omegaconf==2.3.0
161161
opt_einsum==3.4.0
162162
optree==0.17.0

bionemo-recipes/recipes/codonfm_ptl_te/src/utils/load_checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def load_checkpoint(checkpoint_path: str, map_location: str = "cpu"):
3636
hparams = json.load(f)
3737
return {"state_dict": state_dict, "hyper_parameters": hparams}
3838
else:
39-
return torch.load(checkpoint_path, map_location=map_location, weights_only=False)
39+
return torch.load(checkpoint_path, map_location=map_location, weights_only=True)
4040

4141

4242
def download_checkpoint(repo_id: str, local_dir: str = None) -> str: # noqa: RUF013

bionemo-recipes/recipes/codonfm_ptl_te/tests/utils/test_checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_load_pytorch_checkpoint_with_map_location(tmp_path):
5353
mock_torch_load.return_value = checkpoint_data
5454
load_checkpoint(str(checkpoint_path), map_location="cuda:0")
5555

56-
mock_torch_load.assert_called_once_with(str(checkpoint_path), map_location="cuda:0", weights_only=False)
56+
mock_torch_load.assert_called_once_with(str(checkpoint_path), map_location="cuda:0", weights_only=True)
5757

5858

5959
def test_load_safetensors_directory(tmp_path):

bionemo-recipes/recipes/esm2_native_te/checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def load_checkpoint_ddp(
124124
checkpoint = torch.load(
125125
checkpoint_path / "checkpoint.pt",
126126
map_location=f"cuda:{dist_config.local_rank}",
127-
weights_only=False,
127+
weights_only=True,
128128
)
129129

130130
model.load_state_dict(checkpoint["model"])

bionemo-recipes/recipes/llama3_native_te/checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def load_checkpoint_ddp(
124124
checkpoint = torch.load(
125125
checkpoint_path / "checkpoint.pt",
126126
map_location=f"cuda:{dist_config.local_rank}",
127-
weights_only=False,
127+
weights_only=True,
128128
)
129129

130130
model.load_state_dict(checkpoint["model"])

bionemo-recipes/recipes/vit/checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def load_torch_checkpoint(checkpoint_path, model, megatron_fsdp=False):
3636
"""
3737
# Load model checkpoint. Must load with weights_only=False
3838
# if you have an optimizer state in your checkpoint.
39-
checkpoint = torch.load(checkpoint_path, weights_only=False)
39+
checkpoint = torch.load(checkpoint_path, weights_only=True)
4040
# Remove the "module." prefix from the keys of checkpoints
4141
# derived from Megatron-FSDP.
4242
# TODO(@cspades): Remove this when the Megatron-FSDP checkpoint naming is fixed.

0 commit comments

Comments
 (0)