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
8e13d9fe
Unverified
Commit
8e13d9fe
authored
Aug 12, 2025
by
Isotr0py
Committed by
GitHub
Aug 11, 2025
Browse files
[Misc] Further clean up some redundant config definitions (#22649)
Signed-off-by:
Isotr0py
<
2037008807@qq.com
>
parent
3fa5b258
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
85 deletions
+34
-85
vllm/transformers_utils/config.py
vllm/transformers_utils/config.py
+33
-18
vllm/transformers_utils/configs/__init__.py
vllm/transformers_utils/configs/__init__.py
+1
-5
vllm/transformers_utils/configs/mllama.py
vllm/transformers_utils/configs/mllama.py
+0
-31
vllm/transformers_utils/configs/nvlm_d.py
vllm/transformers_utils/configs/nvlm_d.py
+0
-31
No files found.
vllm/transformers_utils/config.py
View file @
8e13d9fe
...
@@ -32,11 +32,10 @@ from vllm.logger import init_logger
...
@@ -32,11 +32,10 @@ from vllm.logger import init_logger
from
vllm.transformers_utils.configs
import
(
ChatGLMConfig
,
DeepseekVLV2Config
,
from
vllm.transformers_utils.configs
import
(
ChatGLMConfig
,
DeepseekVLV2Config
,
EAGLEConfig
,
JAISConfig
,
EAGLEConfig
,
JAISConfig
,
KimiVLConfig
,
MedusaConfig
,
KimiVLConfig
,
MedusaConfig
,
MllamaConfig
,
MLPSpeculatorConfig
,
MLPSpeculatorConfig
,
Nemotron_Nano_VL_Config
,
Nemotron_Nano_VL_Config
,
NemotronConfig
,
NVLM_D_Config
,
NemotronConfig
,
OvisConfig
,
OvisConfig
,
RWConfig
,
RWConfig
,
SpeculatorsConfig
,
SpeculatorsConfig
,
Step3TextConfig
,
Step3VLConfig
,
Step3TextConfig
,
Step3VLConfig
,
UltravoxConfig
)
UltravoxConfig
)
# yapf: enable
# yapf: enable
...
@@ -68,10 +67,6 @@ def _get_hf_token() -> Optional[str]:
...
@@ -68,10 +67,6 @@ def _get_hf_token() -> Optional[str]:
return
None
return
None
_CONFIG_REGISTRY_OVERRIDE_HF
:
dict
[
str
,
type
[
PretrainedConfig
]]
=
{
"mllama"
:
MllamaConfig
}
_CONFIG_REGISTRY
:
dict
[
str
,
type
[
PretrainedConfig
]]
=
{
_CONFIG_REGISTRY
:
dict
[
str
,
type
[
PretrainedConfig
]]
=
{
"chatglm"
:
ChatGLMConfig
,
"chatglm"
:
ChatGLMConfig
,
"deepseek_vl_v2"
:
DeepseekVLV2Config
,
"deepseek_vl_v2"
:
DeepseekVLV2Config
,
...
@@ -85,18 +80,30 @@ _CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = {
...
@@ -85,18 +80,30 @@ _CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = {
"eagle"
:
EAGLEConfig
,
"eagle"
:
EAGLEConfig
,
"speculators"
:
SpeculatorsConfig
,
"speculators"
:
SpeculatorsConfig
,
"nemotron"
:
NemotronConfig
,
"nemotron"
:
NemotronConfig
,
"NVLM_D"
:
NVLM_D_Config
,
"ovis"
:
OvisConfig
,
"ovis"
:
OvisConfig
,
"ultravox"
:
UltravoxConfig
,
"ultravox"
:
UltravoxConfig
,
"step3_vl"
:
Step3VLConfig
,
"step3_vl"
:
Step3VLConfig
,
"step3_text"
:
Step3TextConfig
,
"step3_text"
:
Step3TextConfig
,
**
_CONFIG_REGISTRY_OVERRIDE_HF
}
}
_CONFIG_ATTRS_MAPPING
:
dict
[
str
,
str
]
=
{
_CONFIG_ATTRS_MAPPING
:
dict
[
str
,
str
]
=
{
"llm_config"
:
"text_config"
,
"llm_config"
:
"text_config"
,
}
}
_AUTO_CONFIG_KWARGS_OVERRIDES
:
dict
[
str
,
dict
[
str
,
Any
]]
=
{
"internvl_chat"
:
{
"has_no_defaults_at_init"
:
True
},
# transformers regards mllama as is_encoder_decoder=False
# vllm needs is_encoder_decoder=True to enable cross-attention
"mllama"
:
{
"is_encoder_decoder"
:
True
},
"NVLM_D"
:
{
"has_no_defaults_at_init"
:
True
},
}
class
ConfigFormat
(
str
,
enum
.
Enum
):
class
ConfigFormat
(
str
,
enum
.
Enum
):
AUTO
=
"auto"
AUTO
=
"auto"
...
@@ -273,12 +280,13 @@ def thinker_uses_mrope(config: PretrainedConfig) -> bool:
...
@@ -273,12 +280,13 @@ def thinker_uses_mrope(config: PretrainedConfig) -> bool:
def
is_encoder_decoder
(
config
:
PretrainedConfig
)
->
bool
:
def
is_encoder_decoder
(
config
:
PretrainedConfig
)
->
bool
:
"""Detect if the model with this config is used as an encoder/decoder."""
"""Detect if the model with this config is used as an encoder/decoder."""
text_config
=
getattr
(
config
,
"text_config"
,
None
)
if
text_config
is
not
None
:
return
is_encoder_decoder
(
text_config
)
def
_is_encoder_decoder
(
config
:
PretrainedConfig
)
->
bool
:
return
getattr
(
config
,
"is_encoder_decoder"
,
False
)
return
getattr
(
config
,
"is_encoder_decoder"
,
False
)
return
(
_is_encoder_decoder
(
config
)
or
_is_encoder_decoder
(
config
.
get_text_config
()))
def
is_interleaved
(
config
:
PretrainedConfig
)
->
bool
:
def
is_interleaved
(
config
:
PretrainedConfig
)
->
bool
:
"""
"""
...
@@ -291,13 +299,21 @@ def is_interleaved(config: PretrainedConfig) -> bool:
...
@@ -291,13 +299,21 @@ def is_interleaved(config: PretrainedConfig) -> bool:
return
False
return
False
def
_maybe_update_auto_config_kwargs
(
kwargs
:
dict
[
str
,
Any
],
model_type
:
str
):
"""
Update kwargs for AutoConfig initialization based on model_type
"""
if
model_type
in
_AUTO_CONFIG_KWARGS_OVERRIDES
:
kwargs
.
update
(
_AUTO_CONFIG_KWARGS_OVERRIDES
[
model_type
])
return
kwargs
def
_maybe_remap_hf_config_attrs
(
config
:
PretrainedConfig
)
->
PretrainedConfig
:
def
_maybe_remap_hf_config_attrs
(
config
:
PretrainedConfig
)
->
PretrainedConfig
:
"""Remap config attributes to match the expected names."""
"""Remap config attributes to match the expected names."""
for
old_attr
,
new_attr
in
_CONFIG_ATTRS_MAPPING
.
items
():
for
old_attr
,
new_attr
in
_CONFIG_ATTRS_MAPPING
.
items
():
if
hasattr
(
config
,
old_attr
):
if
hasattr
(
config
,
old_attr
):
if
not
hasattr
(
config
,
new_attr
):
if
not
hasattr
(
config
,
new_attr
):
config
.
update
({
new_attr
:
getattr
(
config
,
old_attr
)})
config
.
update
({
new_attr
:
getattr
(
config
,
old_attr
)})
delattr
(
config
,
old_attr
)
logger
.
debug
(
"Remapped config attribute '%s' to '%s'"
,
old_attr
,
logger
.
debug
(
"Remapped config attribute '%s' to '%s'"
,
old_attr
,
new_attr
)
new_attr
)
return
config
return
config
...
@@ -408,15 +424,14 @@ def get_config(
...
@@ -408,15 +424,14 @@ def get_config(
)
)
else
:
else
:
try
:
try
:
kwargs
=
_maybe_update_auto_config_kwargs
(
kwargs
,
model_type
=
model_type
)
config
=
AutoConfig
.
from_pretrained
(
config
=
AutoConfig
.
from_pretrained
(
model
,
model
,
trust_remote_code
=
trust_remote_code
,
trust_remote_code
=
trust_remote_code
,
revision
=
revision
,
revision
=
revision
,
code_revision
=
code_revision
,
code_revision
=
code_revision
,
token
=
_get_hf_token
(),
token
=
_get_hf_token
(),
# some old custom model's config needs
# `has_no_defaults_at_init=True` to work.
has_no_defaults_at_init
=
trust_remote_code
,
**
kwargs
,
**
kwargs
,
)
)
except
ValueError
as
e
:
except
ValueError
as
e
:
...
...
vllm/transformers_utils/configs/__init__.py
View file @
8e13d9fe
...
@@ -17,13 +17,11 @@ from vllm.transformers_utils.configs.falcon import RWConfig
...
@@ -17,13 +17,11 @@ from vllm.transformers_utils.configs.falcon import RWConfig
from
vllm.transformers_utils.configs.jais
import
JAISConfig
from
vllm.transformers_utils.configs.jais
import
JAISConfig
from
vllm.transformers_utils.configs.kimi_vl
import
KimiVLConfig
from
vllm.transformers_utils.configs.kimi_vl
import
KimiVLConfig
from
vllm.transformers_utils.configs.medusa
import
MedusaConfig
from
vllm.transformers_utils.configs.medusa
import
MedusaConfig
from
vllm.transformers_utils.configs.mllama
import
MllamaConfig
from
vllm.transformers_utils.configs.mlp_speculator
import
MLPSpeculatorConfig
from
vllm.transformers_utils.configs.mlp_speculator
import
MLPSpeculatorConfig
from
vllm.transformers_utils.configs.moonvit
import
MoonViTConfig
from
vllm.transformers_utils.configs.moonvit
import
MoonViTConfig
from
vllm.transformers_utils.configs.nemotron
import
NemotronConfig
from
vllm.transformers_utils.configs.nemotron
import
NemotronConfig
from
vllm.transformers_utils.configs.nemotron_h
import
NemotronHConfig
from
vllm.transformers_utils.configs.nemotron_h
import
NemotronHConfig
from
vllm.transformers_utils.configs.nemotron_vl
import
Nemotron_Nano_VL_Config
from
vllm.transformers_utils.configs.nemotron_vl
import
Nemotron_Nano_VL_Config
from
vllm.transformers_utils.configs.nvlm_d
import
NVLM_D_Config
from
vllm.transformers_utils.configs.ovis
import
OvisConfig
from
vllm.transformers_utils.configs.ovis
import
OvisConfig
from
vllm.transformers_utils.configs.speculators.base
import
SpeculatorsConfig
from
vllm.transformers_utils.configs.speculators.base
import
SpeculatorsConfig
from
vllm.transformers_utils.configs.step3_vl
import
(
Step3TextConfig
,
from
vllm.transformers_utils.configs.step3_vl
import
(
Step3TextConfig
,
...
@@ -34,18 +32,16 @@ from vllm.transformers_utils.configs.ultravox import UltravoxConfig
...
@@ -34,18 +32,16 @@ from vllm.transformers_utils.configs.ultravox import UltravoxConfig
__all__
=
[
__all__
=
[
"ChatGLMConfig"
,
"ChatGLMConfig"
,
"DeepseekVLV2Config"
,
"DeepseekVLV2Config"
,
"EAGLEConfig"
,
"RWConfig"
,
"RWConfig"
,
"JAISConfig"
,
"JAISConfig"
,
"MedusaConfig"
,
"MedusaConfig"
,
"EAGLEConfig"
,
"MllamaConfig"
,
"MLPSpeculatorConfig"
,
"MLPSpeculatorConfig"
,
"MoonViTConfig"
,
"MoonViTConfig"
,
"KimiVLConfig"
,
"KimiVLConfig"
,
"NemotronConfig"
,
"NemotronConfig"
,
"NemotronHConfig"
,
"NemotronHConfig"
,
"Nemotron_Nano_VL_Config"
,
"Nemotron_Nano_VL_Config"
,
"NVLM_D_Config"
,
"OvisConfig"
,
"OvisConfig"
,
"SpeculatorsConfig"
,
"SpeculatorsConfig"
,
"UltravoxConfig"
,
"UltravoxConfig"
,
...
...
vllm/transformers_utils/configs/mllama.py
deleted
100644 → 0
View file @
3fa5b258
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from
transformers.models.mllama
import
configuration_mllama
as
mllama_hf_config
class
MllamaTextConfig
(
mllama_hf_config
.
MllamaTextConfig
):
'''
Use this class to override is_encoder_decoder:
- transformers regards mllama as is_encoder_decoder=False
- vllm needs is_encoder_decoder=True to enable cross-attention
'''
def
__init__
(
self
,
**
kwargs
,
):
super
().
__init__
(
**
kwargs
)
self
.
is_encoder_decoder
=
True
class
MllamaConfig
(
mllama_hf_config
.
MllamaConfig
):
def
__init__
(
self
,
text_config
=
None
,
**
kwargs
,
):
if
isinstance
(
text_config
,
dict
):
text_config
=
MllamaTextConfig
(
**
text_config
)
super
().
__init__
(
text_config
=
text_config
,
**
kwargs
)
vllm/transformers_utils/configs/nvlm_d.py
deleted
100644 → 0
View file @
3fa5b258
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Adapted from
# https://huggingface.co/nvidia/NVLM-D-72B/blob/main/configuration_nvlm_d.py
# --------------------------------------------------------
# NVLM-D
# Copyright (c) 2024 NVIDIA
# Licensed under Apache 2.0 License [see LICENSE for details]
# --------------------------------------------------------
from
transformers
import
Qwen2Config
from
transformers.configuration_utils
import
PretrainedConfig
class
NVLM_D_Config
(
PretrainedConfig
):
model_type
=
'NVLM_D'
is_composition
=
True
def
__init__
(
self
,
vision_config
=
None
,
llm_config
=
None
,
**
kwargs
):
super
().
__init__
(
**
kwargs
)
# Handle vision_config initialization
if
vision_config
is
None
:
vision_config
=
{}
# Handle llm_config initialization
if
llm_config
is
None
:
llm_config
=
{}
self
.
vision_config
=
PretrainedConfig
(
**
vision_config
)
self
.
text_config
=
Qwen2Config
(
**
llm_config
)
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