[Mypy] Fix mypy for vllm/config (#37808)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
Wentao Ye
2026-03-23 14:33:59 +00:00
committed by GitHub
parent 10a1018c12
commit 45bd5c8e75
15 changed files with 68 additions and 59 deletions
+11 -10
View File
@@ -93,7 +93,7 @@ LayerBlockType = Literal["attention", "linear_attention", "mamba"]
_RUNNER_CONVERTS: dict[RunnerType, list[ConvertType]] = {
"generate": [],
"pooling": ["embed", "classify", "reward"],
"pooling": ["embed", "classify"],
"draft": [],
}
@@ -102,8 +102,8 @@ AttnTypeStr = Literal[
]
@config(config=ConfigDict(arbitrary_types_allowed=True))
class ModelConfig:
@config(config=ConfigDict(arbitrary_types_allowed=True)) # type: ignore[arg-type,misc]
class ModelConfig: # type: ignore[misc]
"""Configuration for the model."""
model: str = "Qwen/Qwen3-0.6B"
@@ -121,7 +121,7 @@ class ModelConfig:
"""Convert the model using adapters defined in
[vllm.model_executor.models.adapters][]. The most common use case is to
adapt a text generation model to be used for pooling tasks."""
tokenizer: str = Field(default=None)
tokenizer: str = Field(default=None) # type: ignore[assignment]
"""Name or path of the Hugging Face tokenizer to use. If unspecified, model
name or path will be used."""
tokenizer_mode: TokenizerMode | str = "auto"
@@ -177,7 +177,7 @@ class ModelConfig:
"""The specific revision to use for the tokenizer on the Hugging Face Hub.
It can be a branch name, a tag name, or a commit id. If unspecified, will
use the default version."""
max_model_len: int = Field(default=None, ge=-1)
max_model_len: int = Field(default=None, ge=-1) # type: ignore[assignment]
"""Model context length (prompt and output). If unspecified, will be
automatically derived from the model config.
@@ -454,7 +454,7 @@ class ModelConfig:
self.hf_config_path = maybe_model_redirect(self.hf_config_path)
if callable(self.hf_overrides):
hf_overrides_kw = {}
hf_overrides_kw: dict[str, Any] = {}
hf_overrides_fn = self.hf_overrides
dict_overrides: dict[str, Any] = {}
else:
@@ -582,7 +582,7 @@ class ModelConfig:
self.dtype,
is_pooling_model=self.runner_type == "pooling",
revision=self.revision,
config_format=self.config_format,
config_format=self.config_format, # type: ignore[arg-type]
)
self.original_max_model_len = self.max_model_len
@@ -626,7 +626,7 @@ class ModelConfig:
k: v for k, v in mm_config_kwargs.items() if v is not None
}
self.multimodal_config = MultiModalConfig(**mm_config_kwargs)
self.multimodal_config = MultiModalConfig(**mm_config_kwargs) # type: ignore[arg-type]
# Multimodal GGUF models must use original repo for mm processing
if is_gguf(self.tokenizer) and self.is_multimodal_model:
@@ -732,7 +732,7 @@ class ModelConfig:
@property
def architectures(self) -> list[str]:
return self.model_arch_config.architectures
return self.model_arch_config.architectures # type: ignore[return-value]
@property
def architecture(self) -> str:
@@ -1004,7 +1004,7 @@ class ModelConfig:
is_bitsandbytes = self.quantization == "bitsandbytes"
has_quantization_config = self.model_arch_config.quantization_config is not None
is_8bit = (
self.model_arch_config.quantization_config.get("load_in_8bit", False)
self.model_arch_config.quantization_config.get("load_in_8bit", False) # type: ignore[union-attr]
if has_quantization_config
else False
)
@@ -1292,6 +1292,7 @@ class ModelConfig:
"attn_type_list, or a layer_types in the hf_config, "
f"cannot determine the num of {block_type} layers"
)
raise AssertionError(f"Unsupported block type: {block_type}")
def get_mamba_chunk_size(self) -> int | None:
"""