[Mypy Fix] Mypy fix for "vllm/model_executor/models/[cC][dD]" (#52003)

This commit is contained in:
Wentao Ye
2026-08-13 11:33:55 +08:00
committed by GitHub
parent 15227b934a
commit 9a276d6375
24 changed files with 153 additions and 66 deletions
+11 -2
View File
@@ -9,6 +9,7 @@ if TYPE_CHECKING:
from transformers import PretrainedConfig
from vllm.config import CacheConfig, ModelConfig, VllmConfig
from vllm.config.cache import MambaDType
logger = init_logger(__name__)
@@ -452,6 +453,7 @@ class JambaForSequenceClassificationConfig(VerifyAndUpdateConfig):
@staticmethod
def verify_and_update_model_config(model_config: "ModelConfig") -> None:
pooler_config = model_config.pooler_config
assert pooler_config is not None
if pooler_config.use_activation is None:
pooler_config.use_activation = False
@@ -518,6 +520,7 @@ class JinaVLForSequenceClassificationConfig(VerifyAndUpdateConfig):
config = model_config.hf_config
config.num_labels = 1
pooler_config = model_config.pooler_config
assert pooler_config is not None
if pooler_config.logit_mean is None:
pooler_config.logit_mean = 2.65
@@ -540,6 +543,7 @@ class LlamaBidirectionalConfig(VerifyAndUpdateConfig):
if pooling_type is None:
raise ValueError(f"pool_type {hf_config.pooling!r} not supported")
assert model_config.pooler_config is not None
model_config.pooler_config.seq_pooling_type = pooling_type
@@ -572,10 +576,13 @@ class LlamaNemotronVLConfig(VerifyAndUpdateConfig):
if pooling is None and hasattr(hf_config, "llm_config"):
pooling = getattr(hf_config.llm_config, "pooling", "avg")
assert isinstance(pooling, str)
pooling_type = pooling_type_map.get(pooling)
if pooling_type is None:
raise ValueError(f"pool_type {pooling!r} not supported")
assert model_config.pooler_config is not None
model_config.pooler_config.seq_pooling_type = pooling_type
@@ -631,7 +638,7 @@ class MambaModelConfig(VerifyAndUpdateConfig):
class NemotronHForCausalLMConfig(VerifyAndUpdateConfig):
DEFAULT_MAMBA_SSM_CACHE_DTYPE = "float32"
DEFAULT_MAMBA_SSM_CACHE_DTYPE: "MambaDType" = "float32"
"""Only `float32` is known to have no accuracy issues by default."""
@classmethod
@@ -643,7 +650,7 @@ class NemotronHForCausalLMConfig(VerifyAndUpdateConfig):
`float32` if not specified.
"""
if cache_config.mamba_ssm_cache_dtype == "auto":
mamba_ssm_cache_dtype = getattr(
mamba_ssm_cache_dtype: MambaDType = getattr(
hf_config, "mamba_ssm_cache_dtype", cls.DEFAULT_MAMBA_SSM_CACHE_DTYPE
)
logger.info(
@@ -729,6 +736,7 @@ class Qwen2ForProcessRewardModelConfig(VerifyAndUpdateConfig):
@staticmethod
def verify_and_update_model_config(model_config: "ModelConfig") -> None:
pooler_config = model_config.pooler_config
assert pooler_config is not None
if pooler_config.step_tag_id is None:
pooler_config.step_tag_id = 151651
@@ -738,6 +746,7 @@ class Qwen2ForRewardModelConfig(VerifyAndUpdateConfig):
@staticmethod
def verify_and_update_model_config(model_config: "ModelConfig") -> None:
pooler_config = model_config.pooler_config
assert pooler_config is not None
if pooler_config.use_activation is None:
pooler_config.use_activation = False