10
10
11
11
from vllm .envs import VLLM_USE_MODELSCOPE
12
12
from vllm .logger import init_logger
13
+ # yapf conflicts with isort for this block
14
+ # yapf: disable
13
15
from vllm .transformers_utils .configs import (ChatGLMConfig , DbrxConfig ,
14
16
EAGLEConfig , ExaoneConfig ,
15
- InternVLChatConfig , JAISConfig ,
16
- MedusaConfig , MLPSpeculatorConfig ,
17
- MPTConfig , NemotronConfig ,
18
- RWConfig , UltravoxConfig )
17
+ GraniteConfig , InternVLChatConfig ,
18
+ JAISConfig , MedusaConfig ,
19
+ MLPSpeculatorConfig , MPTConfig ,
20
+ NemotronConfig , RWConfig ,
21
+ UltravoxConfig )
22
+ # yapf: enable
19
23
from vllm .transformers_utils .utils import check_gguf_file
20
24
21
25
if VLLM_USE_MODELSCOPE :
39
43
"internvl_chat" : InternVLChatConfig ,
40
44
"nemotron" : NemotronConfig ,
41
45
"ultravox" : UltravoxConfig ,
46
+ # Granite can be removed from here once we have upgraded to
47
+ # transformers 4.45+
48
+ "granite" : GraniteConfig ,
42
49
}
43
50
44
51
for name , cls in _CONFIG_REGISTRY .items ():
@@ -62,29 +69,36 @@ def get_config(
62
69
kwargs ["gguf_file" ] = Path (model ).name
63
70
model = Path (model ).parent
64
71
65
- try :
66
- config = AutoConfig .from_pretrained (
67
- model ,
68
- trust_remote_code = trust_remote_code ,
69
- revision = revision ,
70
- code_revision = code_revision ,
71
- ** kwargs )
72
- except ValueError as e :
73
- if (not trust_remote_code and
74
- "requires you to execute the configuration file" in str (e )):
75
- err_msg = (
76
- "Failed to load the model config. If the model is a custom "
77
- "model not yet available in the HuggingFace transformers "
78
- "library, consider setting `trust_remote_code=True` in LLM "
79
- "or using the `--trust-remote-code` flag in the CLI." )
80
- raise RuntimeError (err_msg ) from e
81
- else :
82
- raise e
83
- if config .model_type in _CONFIG_REGISTRY :
84
- config_class = _CONFIG_REGISTRY [config .model_type ]
72
+ config_dict , _ = PretrainedConfig .get_config_dict (
73
+ model , revision = revision , code_revision = code_revision , ** kwargs )
74
+
75
+ # Use custom model class if it's in our registry
76
+ model_type = config_dict .get ("model_type" )
77
+ if model_type in _CONFIG_REGISTRY :
78
+ config_class = _CONFIG_REGISTRY [model_type ]
85
79
config = config_class .from_pretrained (model ,
86
80
revision = revision ,
87
81
code_revision = code_revision )
82
+ else :
83
+ try :
84
+ config = AutoConfig .from_pretrained (
85
+ model ,
86
+ trust_remote_code = trust_remote_code ,
87
+ revision = revision ,
88
+ code_revision = code_revision ,
89
+ ** kwargs )
90
+ except ValueError as e :
91
+ if (not trust_remote_code
92
+ and "requires you to execute the configuration file"
93
+ in str (e )):
94
+ err_msg = (
95
+ "Failed to load the model config. If the model is a custom "
96
+ "model not yet available in the HuggingFace transformers "
97
+ "library, consider setting `trust_remote_code=True` in LLM "
98
+ "or using the `--trust-remote-code` flag in the CLI." )
99
+ raise RuntimeError (err_msg ) from e
100
+ else :
101
+ raise e
88
102
89
103
# Special architecture mapping check for GGUF models
90
104
if is_gguf :
0 commit comments