[Bugfix][Config] Keep pydantic validation for fields with a TYPE_CHECKING Literal alias (#46220)
Signed-off-by: Ting Sun <suntcrick@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Ting SUN committed
Jun 24, 2026 at 19:25 UTC
f1a6703edd9f0e99743549408a323a3bd6e49085
3 files changed
+6
-4
vllm/config/load.py
+3
-1
@@ -14,8 +14,10 @@ DEFAULT_SAFETENSORS_PREFETCH_BLOCK_SIZE = 16 * 1024 * 1024
14
SafetensorsLoadStrategy: TypeAlias = Literal["lazy", "eager", "prefetch", "torchao"]
15
16
if TYPE_CHECKING:
17
+ from vllm.model_executor.model_loader import LoadFormats
18
from vllm.model_executor.model_loader.tensorizer import TensorizerConfig
19
else:
20
+ LoadFormats = str
21
TensorizerConfig = Any
22
23
logger = init_logger(__name__)
@@ -25,7 +27,7 @@ logger = init_logger(__name__)
27
class LoadConfig:
28
"""Configuration for loading the model weights."""
29
28
- load_format: str = "auto"
30
+ load_format: str | LoadFormats = "auto"
31
"""
32
The format of the model weights to load.
33
vllm/config/model.py
+1
-1
@@ -69,7 +69,7 @@ else:
69
me_models = LazyLoader("model_executor", globals(), "vllm.model_executor.models")
70
LoadConfig = Any
71
ParallelConfig = Any
72
- QuantizationMethods = Any
72
+ QuantizationMethods = str
73
LogitsProcessor = Any
74
75
logger = init_logger(__name__)
vllm/engine/arg_utils.py
+2
-2
@@ -127,8 +127,8 @@ if TYPE_CHECKING:
127
from vllm.v1.executor import Executor
128
else:
129
Executor = Any
130
- QuantizationMethods = Any
131
- LoadFormats = Any
130
+ QuantizationMethods = str
131
+ LoadFormats = str
132
UsageContext = Any
133
134