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 13, 03:15 UTC
[Doc] Fix failing doc build (#28772)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Cyrus Leung committed
Nov 15, 2025 at 21:33 UTC
89d3679221023fc18fd47df8fc426347fa9694e1
14 files changed
+72
-53
docs/README.md
+2
-2
@@ -30,8 +30,8 @@ Originally developed in the [Sky Computing Lab](https://sky.cs.berkeley.edu) at
30
Where to get started with vLLM depends on the type of user. If you are looking to:
31
32
- Run open-source models on vLLM, we recommend starting with the [Quickstart Guide](./getting_started/quickstart.md)
33
-- Build applications with vLLM, we recommend starting with the [User Guide](./usage)
34
-- Build vLLM, we recommend starting with [Developer Guide](./contributing)
33
+- Build applications with vLLM, we recommend starting with the [User Guide](./usage/README.md)
34
+- Build vLLM, we recommend starting with [Developer Guide](./contributing/README.md)
35
36
For information about the development of vLLM, see:
37
docs/cli/bench/latency.md
+2
-2
@@ -4,6 +4,6 @@
4
5
--8<-- "docs/cli/json_tip.inc.md"
6
7
-## Options
7
+## Arguments
8
9
---8<-- "docs/argparse/bench_latency.md"
9
+--8<-- "docs/argparse/bench_latency.inc.md"
docs/cli/bench/serve.md
+2
-2
@@ -4,6 +4,6 @@
4
5
--8<-- "docs/cli/json_tip.inc.md"
6
7
-## Options
7
+## Arguments
8
9
---8<-- "docs/argparse/bench_serve.md"
9
+--8<-- "docs/argparse/bench_serve.inc.md"
docs/cli/bench/sweep/plot.md
+2
-2
@@ -4,6 +4,6 @@
4
5
--8<-- "docs/cli/json_tip.inc.md"
6
7
-## Options
7
+## Arguments
8
9
---8<-- "docs/argparse/bench_sweep_plot.md"
9
+--8<-- "docs/argparse/bench_sweep_plot.inc.md"
docs/cli/bench/sweep/serve.md
+2
-2
@@ -4,6 +4,6 @@
4
5
--8<-- "docs/cli/json_tip.inc.md"
6
7
-## Options
7
+## Arguments
8
9
---8<-- "docs/argparse/bench_sweep_serve.md"
9
+--8<-- "docs/argparse/bench_sweep_serve.inc.md"
docs/cli/bench/sweep/serve_sla.md
+2
-2
@@ -4,6 +4,6 @@
4
5
--8<-- "docs/cli/json_tip.inc.md"
6
7
-## Options
7
+## Arguments
8
9
---8<-- "docs/argparse/bench_sweep_serve_sla.md"
9
+--8<-- "docs/argparse/bench_sweep_serve_sla.inc.md"
docs/cli/bench/throughput.md
+2
-2
@@ -4,6 +4,6 @@
4
5
--8<-- "docs/cli/json_tip.inc.md"
6
7
-## Options
7
+## Arguments
8
9
---8<-- "docs/argparse/bench_throughput.md"
9
+--8<-- "docs/argparse/bench_throughput.inc.md"
docs/cli/chat.md
+2
-2
@@ -1,5 +1,5 @@
1
# vllm chat
2
3
-## Options
3
+## Arguments
4
5
---8<-- "docs/argparse/chat.md"
5
+--8<-- "docs/argparse/chat.inc.md"
docs/cli/complete.md
+2
-2
@@ -1,5 +1,5 @@
1
# vllm complete
2
3
-## Options
3
+## Arguments
4
5
---8<-- "docs/argparse/complete.md"
5
+--8<-- "docs/argparse/complete.inc.md"
docs/cli/run-batch.md
+2
-2
@@ -4,6 +4,6 @@
4
5
--8<-- "docs/cli/json_tip.inc.md"
6
7
-## Options
7
+## Arguments
8
9
---8<-- "docs/argparse/run-batch.md"
9
+--8<-- "docs/argparse/run-batch.inc.md"
docs/cli/serve.md
+2
-2
@@ -4,6 +4,6 @@
4
5
--8<-- "docs/cli/json_tip.inc.md"
6
7
-## Options
7
+## Arguments
8
9
---8<-- "docs/argparse/serve.md"
9
+--8<-- "docs/argparse/serve.inc.md"
docs/configuration/serve_args.md
+1
-1
@@ -5,7 +5,7 @@ The `vllm serve` command is used to launch the OpenAI-compatible server.
5
## CLI Arguments
6
7
The `vllm serve` command is used to launch the OpenAI-compatible server.
8
-To see the available options, take a look at the [CLI Reference](../cli/README.md#options)!
8
+To see the available options, take a look at the [CLI Reference](../cli/README.md)!
9
10
## Configuration file
11
docs/mkdocs/hooks/generate_argparse.py
+48
-29
@@ -1,12 +1,15 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
-import importlib
3
+import importlib.metadata
4
+import importlib.util
5
import logging
6
import sys
7
import traceback
7
-from argparse import SUPPRESS, HelpFormatter
8
+from argparse import SUPPRESS, Action, HelpFormatter
9
+from collections.abc import Iterable
10
+from importlib.machinery import ModuleSpec
11
from pathlib import Path
9
-from typing import Literal
12
+from typing import TYPE_CHECKING, Literal
13
from unittest.mock import MagicMock, patch
14
15
from pydantic_core import core_schema
@@ -19,6 +22,11 @@ ARGPARSE_DOC_DIR = ROOT_DIR / "docs/argparse"
22
sys.path.insert(0, str(ROOT_DIR))
23
24
25
+def mock_if_no_torch(mock_module: str, mock: MagicMock):
26
+ if not importlib.util.find_spec("torch"):
27
+ sys.modules[mock_module] = mock
28
+
29
+
30
# Mock custom op code
31
class MockCustomOp:
32
@staticmethod
@@ -29,18 +37,21 @@ class MockCustomOp:
37
return decorator
38
39
32
-noop = lambda *a, **k: None
33
-sys.modules["vllm._C"] = MagicMock()
34
-sys.modules["vllm.model_executor.custom_op"] = MagicMock(CustomOp=MockCustomOp)
35
-sys.modules["vllm.utils.torch_utils"] = MagicMock(direct_register_custom_op=noop)
40
+mock_if_no_torch("vllm._C", MagicMock())
41
+mock_if_no_torch("vllm.model_executor.custom_op", MagicMock(CustomOp=MockCustomOp))
42
+mock_if_no_torch(
43
+ "vllm.utils.torch_utils", MagicMock(direct_register_custom_op=lambda *a, **k: None)
44
+)
45
+
46
47
# Mock any version checks by reading from compiled CI requirements
48
with open(ROOT_DIR / "requirements/test.txt") as f:
49
VERSIONS = dict(line.strip().split("==") for line in f if "==" in line)
50
importlib.metadata.version = lambda name: VERSIONS.get(name) or "0.0.0"
51
52
+
53
# Make torch.nn.Parameter safe to inherit from
43
-sys.modules["torch.nn"] = MagicMock(Parameter=object)
54
+mock_if_no_torch("torch.nn", MagicMock(Parameter=object))
55
56
57
class PydanticMagicMock(MagicMock):
@@ -49,31 +60,34 @@ class PydanticMagicMock(MagicMock):
60
def __init__(self, *args, **kwargs):
61
name = kwargs.pop("name", None)
62
super().__init__(*args, **kwargs)
52
- self.__spec__ = importlib.machinery.ModuleSpec(name, None)
63
+ self.__spec__ = ModuleSpec(name, None)
64
65
def __get_pydantic_core_schema__(self, source_type, handler):
66
return core_schema.any_schema()
67
68
58
-def auto_mock(module, attr, max_mocks=100):
69
+def auto_mock(module_name: str, attr: str, max_mocks: int = 100):
70
"""Function that automatically mocks missing modules during imports."""
60
- logger.info("Importing %s from %s", attr, module)
71
+ logger.info("Importing %s from %s", attr, module_name)
72
+
73
for _ in range(max_mocks):
74
try:
75
+ module = importlib.import_module(module_name)
76
+
77
# First treat attr as an attr, then as a submodule
64
- return getattr(
65
- importlib.import_module(module),
66
- attr,
67
- importlib.import_module(f"{module}.{attr}"),
68
- )
78
+ if hasattr(module, attr):
79
+ return getattr(module, attr)
80
+
81
+ return importlib.import_module(f"{module_name}.{attr}")
82
except ModuleNotFoundError as e:
83
+ assert e.name is not None
84
logger.info("Mocking %s for argparse doc generation", e.name)
85
sys.modules[e.name] = PydanticMagicMock(name=e.name)
72
- except Exception as e:
73
- logger.warning("Failed to import %s.%s: %s", module, attr, e)
86
+ except Exception:
87
+ logger.exception("Failed to import %s.%s: %s", module_name, attr)
88
89
raise ImportError(
76
- f"Failed to import {module}.{attr} after mocking {max_mocks} imports"
90
+ f"Failed to import {module_name}.{attr} after mocking {max_mocks} imports"
91
)
92
93
@@ -91,21 +105,26 @@ ChatCommand = auto_mock("vllm.entrypoints.cli.openai", "ChatCommand")
105
CompleteCommand = auto_mock("vllm.entrypoints.cli.openai", "CompleteCommand")
106
openai_cli_args = auto_mock("vllm.entrypoints.openai", "cli_args")
107
openai_run_batch = auto_mock("vllm.entrypoints.openai", "run_batch")
94
-FlexibleArgumentParser = auto_mock(
95
- "vllm.utils.argparse_utils", "FlexibleArgumentParser"
96
-)
108
+
109
+if TYPE_CHECKING:
110
+ from vllm.utils.argparse_utils import FlexibleArgumentParser
111
+else:
112
+ FlexibleArgumentParser = auto_mock(
113
+ "vllm.utils.argparse_utils", "FlexibleArgumentParser"
114
+ )
115
116
117
class MarkdownFormatter(HelpFormatter):
118
"""Custom formatter that generates markdown for argument groups."""
119
102
- def __init__(self, prog, starting_heading_level=3):
103
- super().__init__(prog, max_help_position=float("inf"), width=float("inf"))
120
+ def __init__(self, prog: str, starting_heading_level: int = 3):
121
+ super().__init__(prog, max_help_position=sys.maxsize, width=sys.maxsize)
122
+
123
self._section_heading_prefix = "#" * starting_heading_level
124
self._argument_heading_prefix = "#" * (starting_heading_level + 1)
125
self._markdown_output = []
126
108
- def start_section(self, heading):
127
+ def start_section(self, heading: str):
128
if heading not in {"positional arguments", "options"}:
129
heading_md = f"\n{self._section_heading_prefix} {heading}\n\n"
130
self._markdown_output.append(heading_md)
@@ -113,14 +132,14 @@ class MarkdownFormatter(HelpFormatter):
132
def end_section(self):
133
pass
134
116
- def add_text(self, text):
135
+ def add_text(self, text: str):
136
if text:
137
self._markdown_output.append(f"{text.strip()}\n\n")
138
139
def add_usage(self, usage, actions, groups, prefix=None):
140
pass
141
123
- def add_arguments(self, actions):
142
+ def add_arguments(self, actions: Iterable[Action]):
143
for action in actions:
144
if len(action.option_strings) == 0 or "--help" in action.option_strings:
145
continue
@@ -169,7 +188,7 @@ def create_parser(add_cli_args, **kwargs) -> FlexibleArgumentParser:
188
# Auto-mock runtime imports
189
if tb_list := traceback.extract_tb(e.__traceback__):
190
path = Path(tb_list[-1].filename).relative_to(ROOT_DIR)
172
- auto_mock(module=".".join(path.parent.parts), attr=path.stem)
191
+ auto_mock(module_name=".".join(path.parent.parts), attr=path.stem)
192
return create_parser(add_cli_args, **kwargs)
193
else:
194
raise e
@@ -209,7 +228,7 @@ def on_startup(command: Literal["build", "gh-deploy", "serve"], dirty: bool):
228
229
# Generate documentation for each parser
230
for stem, parser in parsers.items():
212
- doc_path = ARGPARSE_DOC_DIR / f"{stem}.md"
231
+ doc_path = ARGPARSE_DOC_DIR / f"{stem}.inc.md"
232
# Specify encoding for building on Windows
233
with open(doc_path, "w", encoding="utf-8") as f:
234
f.write(super(type(parser), parser).format_help())
docs/usage/README.md
+1
-1
@@ -1,6 +1,6 @@
1
# Using vLLM
2
3
-First, vLLM must be [installed](../getting_started/installation/) for your chosen device in either a Python or Docker environment.
3
+First, vLLM must be [installed](../getting_started/installation/README.md) for your chosen device in either a Python or Docker environment.
4
5
Then, vLLM supports the following usage patterns:
6