Skip to content

Commit ffb6777

Browse files
authored
remove format check for safetensors file (#10864)
remove check
1 parent 85fcbaf commit ffb6777

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

src/diffusers/models/model_loading_utils.py

-14
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,6 @@ def _fetch_remapped_cls_from_config(config, old_class):
134134
return old_class
135135

136136

137-
def _check_archive_and_maybe_raise_error(checkpoint_file, format_list):
138-
"""
139-
Check format of the archive
140-
"""
141-
with safetensors.safe_open(checkpoint_file, framework="pt") as f:
142-
metadata = f.metadata()
143-
if metadata is not None and metadata.get("format") not in format_list:
144-
raise OSError(
145-
f"The safetensors archive passed at {checkpoint_file} does not contain the valid metadata. Make sure "
146-
"you save your model with the `save_pretrained` method."
147-
)
148-
149-
150137
def _determine_param_device(param_name: str, device_map: Optional[Dict[str, Union[int, str, torch.device]]]):
151138
"""
152139
Find the device of param_name from the device_map.
@@ -183,7 +170,6 @@ def load_state_dict(
183170
# tensors are loaded on cpu
184171
with dduf_entries[checkpoint_file].as_mmap() as mm:
185172
return safetensors.torch.load(mm)
186-
_check_archive_and_maybe_raise_error(checkpoint_file, format_list=["pt", "flax"])
187173
if disable_mmap:
188174
return safetensors.torch.load(open(checkpoint_file, "rb").read())
189175
else:

0 commit comments

Comments
 (0)