Skip to content

Fix safetensors detection in try_collect_weight_map (missing dot in glob) - #2520

Open
iamgrootns wants to merge 1 commit into
huggingface:mainfrom
iamgrootns:fix/safetensors-glob-dot
Open

iamgrootns wants to merge 1 commit into
huggingface:mainfrom
iamgrootns:fix/safetensors-glob-dot

Conversation

@iamgrootns

Copy link
Copy Markdown

Problem

In optimum/fx/parallelization/utils.py:467 try_collect_weight_map builds patterns as ["*safetensors", "*.bin"] but compares pattern == "*.safetensors" on line 470.

Since glob("*safetensors") still matches model.safetensors files, the loop breaks but use_safetensors stays False.

Impact for safetensors-only model:

  • index uses pytorch_model.bin.index.json instead of model.safetensors.index.json
  • weight_files globs *.bin -> empty
  • convert_bin_to_safetensors runs needlessly

Verified locally with synthetic sharded dir: buggy -> False + wrong index, fixed -> True + correct index.

Fix

- ["*safetensors", "*.bin"]
+ ["*.safetensors", "*.bin"]

Matches sibling globs on lines 473, 489.

…lob)

try_collect_weight_map builds patterns as ["*safetensors", "*.bin"] but compares against "*.safetensors", so use_safetensors is always False even for safetensors-only models. This causes wrong index (pytorch_model.bin.index.json) and empty weight_files. Add missing dot to match sibling globs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant