Skip to content

Commit 11599b0

Browse files
hardikkguptaIsotr0pygemini-code-assist[bot]
authored
feat(gguf_loader): accept HF repo paths & URLs for GGUF (#20793)
Signed-off-by: Hardik <[email protected]> Signed-off-by: Isotr0py <[email protected]> Co-authored-by: Isotr0py <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent f3137cd commit 11599b0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

vllm/model_executor/model_loader/gguf_loader.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import gguf
77
import torch
88
import torch.nn as nn
9+
from huggingface_hub import hf_hub_download
910
from transformers import AutoModelForCausalLM
1011

1112
from vllm.config import LoadConfig, ModelConfig, VllmConfig
@@ -32,8 +33,18 @@ def __init__(self, load_config: LoadConfig):
3233
def _prepare_weights(self, model_name_or_path: str):
3334
if os.path.isfile(model_name_or_path):
3435
return model_name_or_path
36+
# for raw HTTPS link
37+
if model_name_or_path.startswith(
38+
("http://", "https://")) and model_name_or_path.endswith(".gguf"):
39+
return hf_hub_download(url=model_name_or_path)
40+
# repo id/filename.gguf
41+
if "/" in model_name_or_path and model_name_or_path.endswith(".gguf"):
42+
repo_id, filename = model_name_or_path.rsplit("/", 1)
43+
return hf_hub_download(repo_id=repo_id, filename=filename)
3544
else:
36-
raise ValueError(f"{model_name_or_path} is not a file.")
45+
raise ValueError(
46+
f"Unrecognised GGUF reference: {model_name_or_path} "
47+
"(expected local file, raw URL, or <repo_id>/<filename>.gguf)")
3748

3849
def _get_gguf_weights_map(self, model_config: ModelConfig):
3950
"""

0 commit comments

Comments
 (0)