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 14, 05:30 UTC
Fix `validate-config` pre-commit check (#25157)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Harry Mellor committed
Sep 18, 2025 at 13:06 UTC
3ed1ec4af25a9cb7dcfea74b839864fc3c8ba09d
3 files changed
+19
-10
.pre-commit-config.yaml
+1
-3
@@ -164,9 +164,7 @@ repos:
164
name: Validate configuration has default values and that each field has a docstring
165
entry: python tools/validate_config.py
166
language: python
167
- types: [python]
168
- pass_filenames: true
169
- files: vllm/config.py|tests/test_config.py|vllm/entrypoints/openai/cli_args.py
167
+ additional_dependencies: [regex]
168
# Keep `suggestion` last
169
- id: suggestion
170
name: Suggestion
tools/validate_config.py
+16
-7
@@ -9,6 +9,8 @@ import ast
9
import inspect
10
import sys
11
12
+import regex as re
13
+
14
15
def get_attr_docs(cls_node: ast.ClassDef) -> dict[str, str]:
16
"""
@@ -88,11 +90,12 @@ def validate_class(class_node: ast.ClassDef):
90
for stmt in class_node.body:
91
# A field is defined as a class variable that has a type annotation.
92
if isinstance(stmt, ast.AnnAssign):
91
- # Skip ClassVar
93
+ # Skip ClassVar and InitVar
94
# see https://docs.python.org/3/library/dataclasses.html#class-variables
93
- if isinstance(stmt.annotation, ast.Subscript) and isinstance(
94
- stmt.annotation.value,
95
- ast.Name) and stmt.annotation.value.id == "ClassVar":
95
+ # and https://docs.python.org/3/library/dataclasses.html#init-only-variables
96
+ if (isinstance(stmt.annotation, ast.Subscript)
97
+ and isinstance(stmt.annotation.value, ast.Name)
98
+ and stmt.annotation.value.id in {"ClassVar", "InitVar"}):
99
continue
100
101
if isinstance(stmt.target, ast.Name):
@@ -132,7 +135,7 @@ def validate_ast(tree: ast.stmt):
135
136
def validate_file(file_path: str):
137
try:
135
- print(f"validating {file_path} config dataclasses ", end="")
138
+ print(f"Validating {file_path} config dataclasses ", end="")
139
with open(file_path, encoding="utf-8") as f:
140
source = f.read()
141
@@ -140,7 +143,7 @@ def validate_file(file_path: str):
143
validate_ast(tree)
144
except ValueError as e:
145
print(e)
143
- SystemExit(2)
146
+ raise SystemExit(1) from e
147
else:
148
print("✅")
149
@@ -151,7 +154,13 @@ def fail(message: str, node: ast.stmt):
154
155
def main():
156
for filename in sys.argv[1:]:
154
- validate_file(filename)
157
+ # Only run for Python files in vllm/ or tests/
158
+ if not re.match(r"^(vllm|tests)/.*\.py$", filename):
159
+ continue
160
+ # Only run if the file contains @config
161
+ with open(filename, encoding="utf-8") as f:
162
+ if "@config" in f.read():
163
+ validate_file(filename)
164
165
166
if __name__ == "__main__":
vllm/config/__init__.py
+2
@@ -450,6 +450,8 @@ class ModelConfig:
450
451
# Multimodal config and init vars
452
multimodal_config: Optional[MultiModalConfig] = None
453
+ """Configuration for multimodal model. If `None`, this will be inferred
454
+ from the architecture of `self.model`."""
455
limit_mm_per_prompt: InitVar[Optional[dict[str, int]]] = None
456
media_io_kwargs: InitVar[Optional[dict[str, dict[str, Any]]]] = None
457
mm_processor_kwargs: InitVar[Optional[dict[str, Any]]] = None