A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 11, 11:15 UTC
Remove `SkipValidation` from `ModelConfig` (#30695)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Harry Mellor committed
Dec 15, 2025 at 17:34 UTC
970713d4a40b1d83244eb0ed4eb4d690b6bb4f14
1 file changed
+14
-5
vllm/config/model.py
+14
-5
@@ -8,7 +8,7 @@ from functools import cached_property
8
from typing import TYPE_CHECKING, Any, Literal, cast, get_args
9
10
import torch
11
-from pydantic import ConfigDict, SkipValidation, field_validator, model_validator
11
+from pydantic import ConfigDict, Field, field_validator, model_validator
12
from pydantic.dataclasses import dataclass
13
from safetensors.torch import _TYPES as _SAFETENSORS_TO_TORCH_DTYPE
14
from transformers.configuration_utils import ALLOWED_LAYER_TYPES
@@ -109,7 +109,7 @@ class ModelConfig:
109
"""Convert the model using adapters defined in
110
[vllm.model_executor.models.adapters][]. The most common use case is to
111
adapt a text generation model to be used for pooling tasks."""
112
- tokenizer: SkipValidation[str] = None # type: ignore
112
+ tokenizer: str = Field(default=None)
113
"""Name or path of the Hugging Face tokenizer to use. If unspecified, model
114
name or path will be used."""
115
tokenizer_mode: TokenizerMode | str = "auto"
@@ -164,7 +164,7 @@ class ModelConfig:
164
"""The specific revision to use for the tokenizer on the Hugging Face Hub.
165
It can be a branch name, a tag name, or a commit id. If unspecified, will
166
use the default version."""
167
- max_model_len: SkipValidation[int] = None # type: ignore
167
+ max_model_len: int = Field(default=None, gt=0)
168
"""Model context length (prompt and output). If unspecified, will be
169
automatically derived from the model config.
170
@@ -175,7 +175,7 @@ class ModelConfig:
175
- 25.6k -> 25,600"""
176
spec_target_max_model_len: int | None = None
177
"""Specify the maximum length for spec decoding draft models."""
178
- quantization: SkipValidation[QuantizationMethods | None] = None
178
+ quantization: QuantizationMethods | str | None = None
179
"""Method used to quantize the weights. If `None`, we first check the
180
`quantization_config` attribute in the model config file. If that is
181
`None`, we assume the model weights are not quantized and use `dtype` to
@@ -597,6 +597,14 @@ class ModelConfig:
597
self._verify_cuda_graph()
598
self._verify_bnb_config()
599
600
+ @field_validator("tokenizer", "max_model_len", mode="wrap")
601
+ @classmethod
602
+ def _skip_none_validation(cls, value: Any, handler: Callable) -> Any:
603
+ """Skip validation if the value is `None` when initialisation is delayed."""
604
+ if value is None:
605
+ return value
606
+ return handler(value)
607
+
608
@field_validator("tokenizer_mode", mode="after")
609
def _lowercase_tokenizer_mode(cls, tokenizer_mode: str) -> str:
610
return tokenizer_mode.lower()
@@ -610,13 +618,14 @@ class ModelConfig:
618
619
@model_validator(mode="after")
620
def validate_model_config_after(self: "ModelConfig") -> "ModelConfig":
621
+ """Called after __post_init__"""
622
if not isinstance(self.tokenizer, str):
623
raise ValueError(
624
f"tokenizer must be a string, got "
625
f"{type(self.tokenizer).__name__}: {self.tokenizer!r}. "
626
"Please provide a valid tokenizer path or HuggingFace model ID."
627
)
619
- if not isinstance(self.max_model_len, int) or self.max_model_len <= 0:
628
+ if not isinstance(self.max_model_len, int):
629
raise ValueError(
630
f"max_model_len must be a positive integer, "
631
f"got {type(self.max_model_len).__name__}: {self.max_model_len!r}. "