Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
3a763ba0
Unverified
Commit
3a763ba0
authored
Nov 15, 2024
by
youkaichao
Committed by
GitHub
Nov 15, 2024
Browse files
[core][misc] keep compatibility for old-style classes (#10356)
Signed-off-by:
youkaichao
<
youkaichao@gmail.com
>
parent
f2056f72
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
vllm/model_executor/model_loader/loader.py
vllm/model_executor/model_loader/loader.py
+28
-12
No files found.
vllm/model_executor/model_loader/loader.py
View file @
3a763ba0
...
@@ -94,18 +94,34 @@ def _initialize_model(vllm_config: VllmConfig, prefix: str = "") -> nn.Module:
...
@@ -94,18 +94,34 @@ def _initialize_model(vllm_config: VllmConfig, prefix: str = "") -> nn.Module:
model_config
=
vllm_config
.
model_config
model_config
=
vllm_config
.
model_config
model_class
,
_
=
get_model_architecture
(
model_config
)
model_class
,
_
=
get_model_architecture
(
model_config
)
signatures
=
inspect
.
signature
(
model_class
.
__init__
)
signatures
=
inspect
.
signature
(
model_class
.
__init__
)
# collect all kw-only parameters
all_params
=
[
param
.
name
for
param
in
signatures
.
parameters
.
values
()]
kw_only_params
=
[
if
"vllm_config"
in
all_params
and
"prefix"
in
all_params
:
param
.
name
for
param
in
signatures
.
parameters
.
values
()
# new-style model class
if
param
.
kind
==
inspect
.
Parameter
.
KEYWORD_ONLY
]
assert
"vllm_config"
in
kw_only_params
and
"prefix"
in
kw_only_params
,
\
(
"vLLM model class must accept `vllm_config` and `prefix` as kw-only "
"arguments. Possibly you have an old-style model class registered from "
"out of tree and it is used for new vLLM version. "
"Please check https://docs.vllm.ai/en/latest/design/class_hierarchy.html "
"for the design and update the model class accordingly."
)
return
model_class
(
vllm_config
=
vllm_config
,
prefix
=
prefix
)
return
model_class
(
vllm_config
=
vllm_config
,
prefix
=
prefix
)
msg
=
(
"vLLM model class should accept `vllm_config` and `prefix` as "
"input arguments. Possibly you have an old-style model class"
" registered from out of tree and it is used for new vLLM version. "
"Check https://docs.vllm.ai/en/latest/design/class_hierarchy.html "
"for the design and update the model class accordingly."
)
logger
.
warning
(
msg
)
logger
.
warning
(
"Trying to guess the arguments for old-style model class %s"
,
model_class
)
# try to be compatible with old-style model class
kwargs
=
{}
if
"prefix"
in
all_params
:
kwargs
[
"prefix"
]
=
prefix
if
"config"
in
all_params
:
kwargs
[
"config"
]
=
model_config
.
hf_config
if
"cache_config"
in
all_params
:
kwargs
[
"cache_config"
]
=
vllm_config
.
cache_config
if
"quant_config"
in
all_params
:
kwargs
[
"quant_config"
]
=
vllm_config
.
quant_config
if
"lora_config"
in
all_params
:
kwargs
[
"lora_config"
]
=
vllm_config
.
lora_config
if
"scheduler_config"
in
all_params
:
kwargs
[
"scheduler_config"
]
=
vllm_config
.
scheduler_config
return
model_class
(
**
kwargs
)
class
BaseModelLoader
(
ABC
):
class
BaseModelLoader
(
ABC
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment