From d6249d069965f88ff0042b638704f4cc66d52de4 Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Thu, 11 Sep 2025 11:41:39 +0100 Subject: [PATCH] Fix typing for `safetensors_load_strategy` (#24641) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- vllm/config/load.py | 2 +- vllm/engine/arg_utils.py | 3 +-- vllm/model_executor/model_loader/weight_utils.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/vllm/config/load.py b/vllm/config/load.py index 68253359fc567..26ffec23ad5c6 100644 --- a/vllm/config/load.py +++ b/vllm/config/load.py @@ -51,7 +51,7 @@ class LoadConfig: download_dir: Optional[str] = None """Directory to download and load the weights, default to the default cache directory of Hugging Face.""" - safetensors_load_strategy: Optional[str] = "lazy" + safetensors_load_strategy: str = "lazy" """Specifies the loading strategy for safetensors weights. - "lazy" (default): Weights are memory-mapped from the file. This enables on-demand loading and is highly efficient for models on local storage. diff --git a/vllm/engine/arg_utils.py b/vllm/engine/arg_utils.py index d9a29511eb529..be456af4d19d6 100644 --- a/vllm/engine/arg_utils.py +++ b/vllm/engine/arg_utils.py @@ -289,8 +289,7 @@ class EngineArgs: trust_remote_code: bool = ModelConfig.trust_remote_code allowed_local_media_path: str = ModelConfig.allowed_local_media_path download_dir: Optional[str] = LoadConfig.download_dir - safetensors_load_strategy: Optional[ - str] = LoadConfig.safetensors_load_strategy + safetensors_load_strategy: str = LoadConfig.safetensors_load_strategy load_format: Union[str, LoadFormats] = LoadConfig.load_format config_format: str = ModelConfig.config_format dtype: ModelDType = ModelConfig.dtype diff --git a/vllm/model_executor/model_loader/weight_utils.py b/vllm/model_executor/model_loader/weight_utils.py index c6ca9cd48d009..f2c66763d0816 100644 --- a/vllm/model_executor/model_loader/weight_utils.py +++ b/vllm/model_executor/model_loader/weight_utils.py @@ -519,7 +519,7 @@ def np_cache_weights_iterator( def safetensors_weights_iterator( hf_weights_files: list[str], use_tqdm_on_load: bool, - safetensors_load_strategy: Optional[str] = "lazy", + safetensors_load_strategy: str = "lazy", ) -> Generator[tuple[str, torch.Tensor], None, None]: """Iterate over the weights in the model safetensor files.""" loading_desc = "Loading safetensors checkpoint shards"