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
[Docs] Reduce requirements for docs build (#23651)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Harry Mellor committed
Aug 26, 2025 at 16:43 UTC
379f828fba68bcafec8b283acfd2b831fc35afb9
4 files changed
+72
-59
docs/mkdocs/hooks/generate_argparse.py
+40
-12
@@ -1,5 +1,6 @@
1
# SPDX-License-Identifier: Apache-2.0
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+import importlib
4
import logging
5
import sys
6
from argparse import SUPPRESS, HelpFormatter
@@ -7,25 +8,52 @@ from pathlib import Path
8
from typing import Literal
9
from unittest.mock import MagicMock, patch
10
11
+from pydantic_core import core_schema
12
+
13
+logger = logging.getLogger("mkdocs")
14
+
15
ROOT_DIR = Path(__file__).parent.parent.parent.parent
16
ARGPARSE_DOC_DIR = ROOT_DIR / "docs/argparse"
17
18
sys.path.insert(0, str(ROOT_DIR))
14
-sys.modules["aiohttp"] = MagicMock()
15
-sys.modules["blake3"] = MagicMock()
19
sys.modules["vllm._C"] = MagicMock()
20
18
-from vllm.benchmarks import latency # noqa: E402
19
-from vllm.benchmarks import serve # noqa: E402
20
-from vllm.benchmarks import throughput # noqa: E402
21
-from vllm.engine.arg_utils import AsyncEngineArgs, EngineArgs # noqa: E402
22
-from vllm.entrypoints.cli.openai import ChatCommand # noqa: E402
23
-from vllm.entrypoints.cli.openai import CompleteCommand # noqa: E402
24
-from vllm.entrypoints.openai import cli_args # noqa: E402
25
-from vllm.entrypoints.openai import run_batch # noqa: E402
26
-from vllm.utils import FlexibleArgumentParser # noqa: E402
21
28
-logger = logging.getLogger("mkdocs")
22
+class PydanticMagicMock(MagicMock):
23
+ """`MagicMock` that's able to generate pydantic-core schemas."""
24
+
25
+ def __get_pydantic_core_schema__(self, source_type, handler):
26
+ return core_schema.any_schema()
27
+
28
+
29
+def auto_mock(module, attr, max_mocks=50):
30
+ """Function that automatically mocks missing modules during imports."""
31
+ logger.info("Importing %s from %s", attr, module)
32
+ for _ in range(max_mocks):
33
+ try:
34
+ # First treat attr as an attr, then as a submodule
35
+ return getattr(importlib.import_module(module), attr,
36
+ importlib.import_module(f"{module}.{attr}"))
37
+ except importlib.metadata.PackageNotFoundError as e:
38
+ raise e
39
+ except ModuleNotFoundError as e:
40
+ logger.info("Mocking %s for argparse doc generation", e.name)
41
+ sys.modules[e.name] = PydanticMagicMock()
42
+
43
+ raise ImportError(
44
+ f"Failed to import {module}.{attr} after mocking {max_mocks} imports")
45
+
46
+
47
+latency = auto_mock("vllm.benchmarks", "latency")
48
+serve = auto_mock("vllm.benchmarks", "serve")
49
+throughput = auto_mock("vllm.benchmarks", "throughput")
50
+AsyncEngineArgs = auto_mock("vllm.engine.arg_utils", "AsyncEngineArgs")
51
+EngineArgs = auto_mock("vllm.engine.arg_utils", "EngineArgs")
52
+ChatCommand = auto_mock("vllm.entrypoints.cli.openai", "ChatCommand")
53
+CompleteCommand = auto_mock("vllm.entrypoints.cli.openai", "CompleteCommand")
54
+cli_args = auto_mock("vllm.entrypoints.openai", "cli_args")
55
+run_batch = auto_mock("vllm.entrypoints.openai", "run_batch")
56
+FlexibleArgumentParser = auto_mock("vllm.utils", "FlexibleArgumentParser")
57
58
59
class MarkdownFormatter(HelpFormatter):
requirements/docs.txt
-14
@@ -14,20 +14,6 @@ ruff
14
# Required for argparse hook only
15
-f https://download.pytorch.org/whl/cpu
16
cachetools
17
-cbor2
18
-cloudpickle
19
-fastapi
17
msgspec
21
-openai
22
-openai-harmony
23
-partial-json-parser
24
-pillow
25
-psutil
26
-pybase64
18
pydantic
28
-setproctitle
19
torch
30
-transformers
31
-zmq
32
-uvloop
33
-prometheus-client
vllm/sequence.py
+5
-2
@@ -16,14 +16,17 @@ import msgspec
16
import torch
17
18
from vllm.inputs import SingletonInputs
19
-from vllm.lora.request import LoRARequest
19
from vllm.multimodal import MultiModalKwargs, MultiModalPlaceholderDict
20
from vllm.pooling_params import PoolingParams
21
from vllm.sampling_params import RequestOutputKind, SamplingParams
22
23
if TYPE_CHECKING:
24
+ from vllm.lora.request import LoRARequest
25
from vllm.v1.worker.kv_connector_model_runner_mixin import (
26
KVConnectorOutput)
27
+else:
28
+ LoRARequest = Any
29
+ KVConnectorOutput = Any
30
31
VLLM_TOKEN_ID_ARRAY_TYPE = "l"
32
@@ -1138,7 +1141,7 @@ class IntermediateTensors:
1141
"""
1142
1143
tensors: dict[str, torch.Tensor]
1141
- kv_connector_output: Optional["KVConnectorOutput"]
1144
+ kv_connector_output: Optional[KVConnectorOutput]
1145
1146
def __init__(self, tensors):
1147
# manually define this function, so that
vllm/transformers_utils/config.py
+27
-31
@@ -27,19 +27,6 @@ from transformers.utils import CONFIG_NAME as HF_CONFIG_NAME
27
28
from vllm import envs
29
from vllm.logger import init_logger
30
-# yapf conflicts with isort for this block
31
-# yapf: disable
32
-from vllm.transformers_utils.configs import (ChatGLMConfig, DeepseekVLV2Config,
33
- EAGLEConfig, JAISConfig,
34
- KimiVLConfig, MedusaConfig,
35
- MLPSpeculatorConfig,
36
- Nemotron_Nano_VL_Config,
37
- NemotronConfig, OvisConfig,
38
- RWConfig, SpeculatorsConfig,
39
- Step3TextConfig, Step3VLConfig,
40
- UltravoxConfig)
41
-# yapf: enable
42
-from vllm.transformers_utils.configs.mistral import adapt_config_dict
30
from vllm.transformers_utils.utils import check_gguf_file
31
32
if envs.VLLM_USE_MODELSCOPE:
@@ -67,24 +54,31 @@ def _get_hf_token() -> Optional[str]:
54
return None
55
56
70
-_CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = {
71
- "chatglm": ChatGLMConfig,
72
- "deepseek_vl_v2": DeepseekVLV2Config,
73
- "kimi_vl": KimiVLConfig,
74
- "Llama_Nemotron_Nano_VL": Nemotron_Nano_VL_Config,
75
- "RefinedWeb": RWConfig, # For tiiuae/falcon-40b(-instruct)
76
- "RefinedWebModel": RWConfig, # For tiiuae/falcon-7b(-instruct)
77
- "jais": JAISConfig,
78
- "mlp_speculator": MLPSpeculatorConfig,
79
- "medusa": MedusaConfig,
80
- "eagle": EAGLEConfig,
81
- "speculators": SpeculatorsConfig,
82
- "nemotron": NemotronConfig,
83
- "ovis": OvisConfig,
84
- "ultravox": UltravoxConfig,
85
- "step3_vl": Step3VLConfig,
86
- "step3_text": Step3TextConfig,
87
-}
57
+class LazyConfigDict(dict):
58
+
59
+ def __getitem__(self, key):
60
+ import vllm.transformers_utils.configs as configs
61
+ return getattr(configs, super().__getitem__(key))
62
+
63
+
64
+_CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = LazyConfigDict(
65
+ chatglm="ChatGLMConfig",
66
+ deepseek_vl_v2="DeepseekVLV2Config",
67
+ kimi_vl="KimiVLConfig",
68
+ Llama_Nemotron_Nano_VL="Nemotron_Nano_VL_Config",
69
+ RefinedWeb="RWConfig", # For tiiuae/falcon-40b(-instruct)
70
+ RefinedWebModel="RWConfig", # For tiiuae/falcon-7b(-instruct)
71
+ jais="JAISConfig",
72
+ mlp_speculator="MLPSpeculatorConfig",
73
+ medusa="MedusaConfig",
74
+ eagle="EAGLEConfig",
75
+ speculators="SpeculatorsConfig",
76
+ nemotron="NemotronConfig",
77
+ ovis="OvisConfig",
78
+ ultravox="UltravoxConfig",
79
+ step3_vl="Step3VLConfig",
80
+ step3_text="Step3TextConfig",
81
+)
82
83
_CONFIG_ATTRS_MAPPING: dict[str, str] = {
84
"llm_config": "text_config",
@@ -461,6 +455,8 @@ def get_config(
455
model, revision, **kwargs)
456
config_dict["max_position_embeddings"] = max_position_embeddings
457
458
+ from vllm.transformers_utils.configs.mistral import adapt_config_dict
459
+
460
config = adapt_config_dict(config_dict)
461
462
# Mistral configs may define sliding_window as list[int]. Convert it