Skip to content

Commit bf5140a

Browse files
committed
fix(download): Fix safetensors/bin/pth download logic
The previous logic didn't handle .bin files, so if a model (like mistral) has both .bin and .safetensors, it would download both. Branch: download-fix Signed-off-by: Gabe Goodhart <[email protected]>
1 parent 98a3b11 commit bf5140a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

torchchat/cli/download.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,23 @@ def _download_hf_snapshot(
3535
model_info = model_info(model_config.distribution_path, token=hf_token)
3636
model_fnames = [f.rfilename for f in model_info.siblings]
3737

38-
# Check the model config for preference between safetensors and pth
38+
# Check the model config for preference between safetensors and pth/bin
3939
has_pth = any(f.endswith(".pth") for f in model_fnames)
40+
has_bin = any(f.endswith(".bin") for f in model_fnames)
4041
has_safetensors = any(f.endswith(".safetensors") for f in model_fnames)
4142

42-
# If told to prefer safetensors, ignore pth files
43+
# If told to prefer safetensors, ignore pth/bin files
4344
if model_config.prefer_safetensors:
4445
if not has_safetensors:
4546
print(
4647
f"Model {model_config.name} does not have safetensors files, but prefer_safetensors is set to True. Using pth files instead.",
4748
file=sys.stderr,
4849
)
4950
exit(1)
50-
ignore_patterns = "*.pth"
51+
ignore_patterns = ["*.pth", "*.bin"]
5152

5253
# If the model has both, prefer pth files over safetensors
53-
elif has_pth and has_safetensors:
54+
elif (has_pth or has_bin) and has_safetensors:
5455
ignore_patterns = "*safetensors*"
5556

5657
# Otherwise, download everything

0 commit comments

Comments
 (0)