Skip to content

Commit ee49dfc

Browse files
committed
fix: remove weights_only=False from torch.load in multimodal example
Hardcoding weights_only=False is a security risk as it allows arbitrary code execution. Users who need legacy checkpoint loading should opt in via TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1. Signed-off-by: Faradawn Yang <73060648+faradawn@users.noreply.github.com>
1 parent fe5291f commit ee49dfc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

examples/multimodal/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Update the paths to point to the mcore converted CLIP and Mistral models and run
3939
examples/multimodal/combine_lm_vision_checkpoints.sh /path/to/mistral/model /path/to/clip/model /output/dir
4040
```
4141

42+
> **Note:** If you encounter a loading error, try setting `TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1`.
43+
4244
## Training
4345

4446
### Pretraining

examples/multimodal/combine_state_dicts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def combine(input_files, module_prefixes, output_files):
2727
zip(current_input_files, current_module_prefixes)
2828
):
2929
# initialize the combined state dict using the first provided input file
30-
current_state_dict = torch.load(input_file, weights_only=False)
30+
# NOTE: To load legacy checkpoints, set TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1
31+
# (only use with trusted files — allows arbitrary code execution).
32+
current_state_dict = torch.load(input_file)
3133
if i == 0:
3234
combined_state_dict = current_state_dict.copy()
3335
combined_state_dict["model"] = dict()

0 commit comments

Comments
 (0)