@@ -721,6 +721,9 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
721721 loading `from_flax`.
722722 dduf_file(`str`, *optional*):
723723 Load weights from the specified dduf file.
724+ disable_mmap ('bool', *optional*, defaults to 'False'):
725+ Whether to disable mmap when loading a Safetensors model. This option can perform better when the model
726+ is on a network mount or hard drive, which may not handle the seeky-ness of mmap very well.
724727
725728 > [!TIP] > To use private or [gated](https://huggingface.co/docs/hub/models-gated#gated-models) models, log-in
726729 with `hf > auth login`.
@@ -772,6 +775,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
772775 use_onnx = kwargs .pop ("use_onnx" , None )
773776 load_connected_pipeline = kwargs .pop ("load_connected_pipeline" , False )
774777 quantization_config = kwargs .pop ("quantization_config" , None )
778+ disable_mmap = kwargs .pop ("disable_mmap" , False )
775779
776780 if torch_dtype is not None and not isinstance (torch_dtype , dict ) and not isinstance (torch_dtype , torch .dtype ):
777781 torch_dtype = torch .float32
@@ -1059,6 +1063,7 @@ def load_module(name, value):
10591063 use_safetensors = use_safetensors ,
10601064 dduf_entries = dduf_entries ,
10611065 provider_options = provider_options ,
1066+ disable_mmap = disable_mmap ,
10621067 quantization_config = quantization_config ,
10631068 )
10641069 logger .info (
0 commit comments