Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion vllm/model_executor/model_loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ def get_end_ptr(tensor: torch.Tensor) -> int:
result[k] = t
return result

def _prepare_weights(self, model_name_or_path: str,
revision: Optional[str]):
if os.path.isdir(model_name_or_path):
return model_name_or_path
else:
allow_patterns = ["*.safetensors"]
return download_weights_from_hf(model_name_or_path,
self.load_config.download_dir,
allow_patterns, revision)
Comment thread
ywang96 marked this conversation as resolved.

def load_model(self, *, model_config: ModelConfig,
device_config: DeviceConfig,
lora_config: Optional[LoRAConfig],
Expand All @@ -432,14 +442,18 @@ def load_model(self, *, model_config: ModelConfig,
from safetensors.torch import safe_open

from vllm.distributed import get_tensor_model_parallel_rank

local_model_path = self._prepare_weights(model_config.model,
model_config.revision)

with set_default_torch_dtype(model_config.dtype):
with torch.device(device_config.device):
model = _initialize_model(model_config, self.load_config,
lora_config, vision_language_config,
cache_config)
rank = get_tensor_model_parallel_rank()
pattern = os.path.join(
model_config.model,
local_model_path,
self.pattern.format(rank=rank, part="*"),
)
filepaths = glob.glob(pattern)
Expand Down