diffusers
aae97e79 - fix: scope save_pretrained shard cleanup to the saved variant (avoid deleting another variant's shards) (#14844)

Commit
5 days ago
fix: scope save_pretrained shard cleanup to the saved variant (avoid deleting another variant's shards) (#14844) * fix(modeling): scope save_pretrained shard cleanup to the saved variant The previous-save cleanup in save_pretrained matched shards by a bare prefix startswith plus a generic shard regex. Saving default weights (weights_name 'diffusion_pytorch_model') into a directory holding another variant's sharded checkpoint ('diffusion_pytorch_model.ema-00001-of-...') matched and deleted that variant's shards while leaving its index, so the variant could no longer be reloaded. A formerly-sharded checkpoint re-saved as a single file also left a stale index that load then followed instead of the new weights. Anchor the match to the exact per-variant/format shard name (<weights_without_ext>-NNNNN-of-NNNNN) and remove this checkpoint's own now-obsolete index when it is no longer sharded. Fixes #14719 * simplify variant shard cleanup using _REGEX_SHARD * Apply style fixes --------- Co-authored-by: DN6 <dhruv.nair@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Author
Parents
Loading