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
Only run `get_attr_docs` if generating help text (#23723)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Harry Mellor committed
Aug 27, 2025 at 14:55 UTC
513c1fe255f7d4ec3e91f7f5c2dd2d97c0460765
1 file changed
+13
-2
vllm/engine/arg_utils.py
+13
-2
@@ -152,9 +152,17 @@ def is_online_quantization(quantization: Any) -> bool:
152
return quantization in ["inc"]
153
154
155
+NEEDS_HELP = (
156
+ "--help" in (argv := sys.argv) # vllm SUBCOMMAND --help
157
+ or (argv0 := argv[0]).endswith("mkdocs") # mkdocs SUBCOMMAND
158
+ or argv0.endswith("mkdocs/__main__.py") # python -m mkdocs SUBCOMMAND
159
+)
160
+
161
+
162
@functools.lru_cache(maxsize=30)
163
def _compute_kwargs(cls: ConfigType) -> dict[str, Any]:
157
- cls_docs = get_attr_docs(cls)
164
+ # Save time only getting attr docs if we're generating help text
165
+ cls_docs = get_attr_docs(cls) if NEEDS_HELP else {}
166
kwargs = {}
167
for field in fields(cls):
168
# Get the set of possible types for the field
@@ -172,7 +180,7 @@ def _compute_kwargs(cls: ConfigType) -> dict[str, Any]:
180
181
# Get the help text for the field
182
name = field.name
175
- help = cls_docs[name].strip()
183
+ help = cls_docs.get(name, "").strip()
184
# Escape % for argparse
185
help = help.replace("%", "%%")
186
@@ -254,6 +262,9 @@ def _compute_kwargs(cls: ConfigType) -> dict[str, Any]:
262
def get_kwargs(cls: ConfigType) -> dict[str, Any]:
263
"""Return argparse kwargs for the given Config dataclass.
264
265
+ If `--help` or `mkdocs` are not present in the command line command, the
266
+ attribute documentation will not be included in the help output.
267
+
268
The heavy computation is cached via functools.lru_cache, and a deep copy
269
is returned so callers can mutate the dictionary without affecting the
270
cached version.