From a59e3cb1e75ffb0ccd8d0170d80aae693ac292ca Mon Sep 17 00:00:00 2001 From: DarkLight1337 Date: Sat, 15 Nov 2025 03:48:47 +0000 Subject: [PATCH 1/9] [Doc] Fix failing doc build Signed-off-by: DarkLight1337 --- docs/configuration/serve_args.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration/serve_args.md b/docs/configuration/serve_args.md index c1cc5577bc7a..baaf21f01f06 100644 --- a/docs/configuration/serve_args.md +++ b/docs/configuration/serve_args.md @@ -5,7 +5,7 @@ The `vllm serve` command is used to launch the OpenAI-compatible server. ## CLI Arguments The `vllm serve` command is used to launch the OpenAI-compatible server. -To see the available options, take a look at the [CLI Reference](../cli/README.md#options)! +To see the available options, take a look at the [CLI Reference](../cli/README.md)! ## Configuration file From ad0c2b6b386bb35f2fd7d7d1faef5990dacb62d0 Mon Sep 17 00:00:00 2001 From: DarkLight1337 Date: Sat, 15 Nov 2025 09:39:42 +0000 Subject: [PATCH 2/9] Try fix Signed-off-by: DarkLight1337 --- mkdocs.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdocs.yaml b/mkdocs.yaml index bf97093dafb1..53584b17adf0 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -56,7 +56,8 @@ hooks: plugins: - meta - search - - autorefs + - autorefs: + resolve_closest: true - awesome-nav - glightbox - git-revision-date-localized: From 1aa039ee2a78d68826af903b0b5aa2ec3771cd25 Mon Sep 17 00:00:00 2001 From: DarkLight1337 Date: Sat, 15 Nov 2025 12:54:01 +0000 Subject: [PATCH 3/9] Improve doc build Signed-off-by: DarkLight1337 --- docs/mkdocs/hooks/generate_argparse.py | 68 ++++++++++++++++---------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/docs/mkdocs/hooks/generate_argparse.py b/docs/mkdocs/hooks/generate_argparse.py index ce1c5c53cf35..909c82c8aa56 100644 --- a/docs/mkdocs/hooks/generate_argparse.py +++ b/docs/mkdocs/hooks/generate_argparse.py @@ -1,16 +1,21 @@ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project -import importlib +import importlib.metadata +import importlib.util import logging import sys import traceback -from argparse import SUPPRESS, HelpFormatter +from argparse import SUPPRESS, Action, HelpFormatter +from collections.abc import Iterable +from importlib.machinery import ModuleSpec from pathlib import Path from typing import Literal from unittest.mock import MagicMock, patch from pydantic_core import core_schema +from vllm.utils.argparse_utils import FlexibleArgumentParser + logger = logging.getLogger("mkdocs") ROOT_DIR = Path(__file__).parent.parent.parent.parent @@ -19,6 +24,11 @@ sys.path.insert(0, str(ROOT_DIR)) +def mock_if_not_found(module_name: str, mock: MagicMock): + if not importlib.util.find_spec(module_name): + sys.modules[module_name] = mock + + # Mock custom op code class MockCustomOp: @staticmethod @@ -29,18 +39,21 @@ def decorator(cls): return decorator -noop = lambda *a, **k: None -sys.modules["vllm._C"] = MagicMock() -sys.modules["vllm.model_executor.custom_op"] = MagicMock(CustomOp=MockCustomOp) -sys.modules["vllm.utils.torch_utils"] = MagicMock(direct_register_custom_op=noop) +mock_if_not_found("vllm._C", MagicMock()) +mock_if_not_found("vllm.model_executor.custom_op", MagicMock(CustomOp=MockCustomOp)) +mock_if_not_found( + "vllm.utils.torch_utils", MagicMock(direct_register_custom_op=lambda *a, **k: None) +) + # Mock any version checks by reading from compiled CI requirements with open(ROOT_DIR / "requirements/test.txt") as f: VERSIONS = dict(line.strip().split("==") for line in f if "==" in line) importlib.metadata.version = lambda name: VERSIONS.get(name) or "0.0.0" + # Make torch.nn.Parameter safe to inherit from -sys.modules["torch.nn"] = MagicMock(Parameter=object) +mock_if_not_found("torch.nn", MagicMock(Parameter=object)) class PydanticMagicMock(MagicMock): @@ -49,31 +62,34 @@ class PydanticMagicMock(MagicMock): def __init__(self, *args, **kwargs): name = kwargs.pop("name", None) super().__init__(*args, **kwargs) - self.__spec__ = importlib.machinery.ModuleSpec(name, None) + self.__spec__ = ModuleSpec(name, None) def __get_pydantic_core_schema__(self, source_type, handler): return core_schema.any_schema() -def auto_mock(module, attr, max_mocks=100): +def auto_mock(module_name: str, attr: str, max_mocks: int = 100): """Function that automatically mocks missing modules during imports.""" - logger.info("Importing %s from %s", attr, module) + logger.info("Importing %s from %s", attr, module_name) + for _ in range(max_mocks): try: + module = importlib.import_module(module_name) + # First treat attr as an attr, then as a submodule - return getattr( - importlib.import_module(module), - attr, - importlib.import_module(f"{module}.{attr}"), - ) + if hasattr(module, attr): + return getattr(module, attr) + + return importlib.import_module(f"{module_name}.{attr}") except ModuleNotFoundError as e: + assert e.name is not None logger.info("Mocking %s for argparse doc generation", e.name) sys.modules[e.name] = PydanticMagicMock(name=e.name) - except Exception as e: - logger.warning("Failed to import %s.%s: %s", module, attr, e) + except Exception: + logger.exception("Failed to import %s.%s: %s", module_name, attr) raise ImportError( - f"Failed to import {module}.{attr} after mocking {max_mocks} imports" + f"Failed to import {module_name}.{attr} after mocking {max_mocks} imports" ) @@ -91,21 +107,19 @@ def auto_mock(module, attr, max_mocks=100): CompleteCommand = auto_mock("vllm.entrypoints.cli.openai", "CompleteCommand") openai_cli_args = auto_mock("vllm.entrypoints.openai", "cli_args") openai_run_batch = auto_mock("vllm.entrypoints.openai", "run_batch") -FlexibleArgumentParser = auto_mock( - "vllm.utils.argparse_utils", "FlexibleArgumentParser" -) class MarkdownFormatter(HelpFormatter): """Custom formatter that generates markdown for argument groups.""" - def __init__(self, prog, starting_heading_level=3): - super().__init__(prog, max_help_position=float("inf"), width=float("inf")) + def __init__(self, prog: str, starting_heading_level: int = 3): + super().__init__(prog, max_help_position=sys.maxsize, width=sys.maxsize) + self._section_heading_prefix = "#" * starting_heading_level self._argument_heading_prefix = "#" * (starting_heading_level + 1) self._markdown_output = [] - def start_section(self, heading): + def start_section(self, heading: str): if heading not in {"positional arguments", "options"}: heading_md = f"\n{self._section_heading_prefix} {heading}\n\n" self._markdown_output.append(heading_md) @@ -113,14 +127,14 @@ def start_section(self, heading): def end_section(self): pass - def add_text(self, text): + def add_text(self, text: str): if text: self._markdown_output.append(f"{text.strip()}\n\n") def add_usage(self, usage, actions, groups, prefix=None): pass - def add_arguments(self, actions): + def add_arguments(self, actions: Iterable[Action]): for action in actions: if len(action.option_strings) == 0 or "--help" in action.option_strings: continue @@ -169,7 +183,7 @@ def create_parser(add_cli_args, **kwargs) -> FlexibleArgumentParser: # Auto-mock runtime imports if tb_list := traceback.extract_tb(e.__traceback__): path = Path(tb_list[-1].filename).relative_to(ROOT_DIR) - auto_mock(module=".".join(path.parent.parts), attr=path.stem) + auto_mock(module_name=".".join(path.parent.parts), attr=path.stem) return create_parser(add_cli_args, **kwargs) else: raise e From 8ed445e909e7a4f085bc8cccd1f3eee4d4441673 Mon Sep 17 00:00:00 2001 From: DarkLight1337 Date: Sat, 15 Nov 2025 13:01:42 +0000 Subject: [PATCH 4/9] Fix Signed-off-by: DarkLight1337 --- docs/mkdocs/hooks/generate_argparse.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/mkdocs/hooks/generate_argparse.py b/docs/mkdocs/hooks/generate_argparse.py index 909c82c8aa56..e1029f5386de 100644 --- a/docs/mkdocs/hooks/generate_argparse.py +++ b/docs/mkdocs/hooks/generate_argparse.py @@ -9,13 +9,11 @@ from collections.abc import Iterable from importlib.machinery import ModuleSpec from pathlib import Path -from typing import Literal +from typing import TYPE_CHECKING, Literal from unittest.mock import MagicMock, patch from pydantic_core import core_schema -from vllm.utils.argparse_utils import FlexibleArgumentParser - logger = logging.getLogger("mkdocs") ROOT_DIR = Path(__file__).parent.parent.parent.parent @@ -108,6 +106,13 @@ def auto_mock(module_name: str, attr: str, max_mocks: int = 100): openai_cli_args = auto_mock("vllm.entrypoints.openai", "cli_args") openai_run_batch = auto_mock("vllm.entrypoints.openai", "run_batch") +if TYPE_CHECKING: + from vllm.utils.argparse_utils import FlexibleArgumentParser +else: + FlexibleArgumentParser = auto_mock( + "vllm.utils.argparse_utils", "FlexibleArgumentParser" + ) + class MarkdownFormatter(HelpFormatter): """Custom formatter that generates markdown for argument groups.""" From 154e6d54f2bd6213f9f8cebb655aa75a96fab19f Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Sat, 15 Nov 2025 13:15:23 +0000 Subject: [PATCH 5/9] Revert closest ref Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- mkdocs.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdocs.yaml b/mkdocs.yaml index 53584b17adf0..bf97093dafb1 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -56,8 +56,7 @@ hooks: plugins: - meta - search - - autorefs: - resolve_closest: true + - autorefs - awesome-nav - glightbox - git-revision-date-localized: From ac2667cd15fe9fc7d9a2c12130e3a40f9c632532 Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Sat, 15 Nov 2025 13:16:18 +0000 Subject: [PATCH 6/9] use `.inc.md` for auto-generated files that we don't want indexed Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- docs/cli/bench/latency.md | 2 +- docs/cli/bench/serve.md | 2 +- docs/cli/bench/sweep/plot.md | 2 +- docs/cli/bench/sweep/serve.md | 2 +- docs/cli/bench/sweep/serve_sla.md | 2 +- docs/cli/bench/throughput.md | 2 +- docs/cli/chat.md | 2 +- docs/cli/complete.md | 2 +- docs/cli/run-batch.md | 2 +- docs/cli/serve.md | 2 +- docs/mkdocs/hooks/generate_argparse.py | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/cli/bench/latency.md b/docs/cli/bench/latency.md index 21ab13e63781..ce6265150adc 100644 --- a/docs/cli/bench/latency.md +++ b/docs/cli/bench/latency.md @@ -6,4 +6,4 @@ ## Options ---8<-- "docs/argparse/bench_latency.md" +--8<-- "docs/argparse/bench_latency.inc.md" diff --git a/docs/cli/bench/serve.md b/docs/cli/bench/serve.md index f7c415c6becb..f406ed15669a 100644 --- a/docs/cli/bench/serve.md +++ b/docs/cli/bench/serve.md @@ -6,4 +6,4 @@ ## Options ---8<-- "docs/argparse/bench_serve.md" +--8<-- "docs/argparse/bench_serve.inc.md" diff --git a/docs/cli/bench/sweep/plot.md b/docs/cli/bench/sweep/plot.md index f29bffb64655..34a303280fed 100644 --- a/docs/cli/bench/sweep/plot.md +++ b/docs/cli/bench/sweep/plot.md @@ -6,4 +6,4 @@ ## Options ---8<-- "docs/argparse/bench_sweep_plot.md" +--8<-- "docs/argparse/bench_sweep_plot.inc.md" diff --git a/docs/cli/bench/sweep/serve.md b/docs/cli/bench/sweep/serve.md index 5b5f91a951ed..1085636f1b79 100644 --- a/docs/cli/bench/sweep/serve.md +++ b/docs/cli/bench/sweep/serve.md @@ -6,4 +6,4 @@ ## Options ---8<-- "docs/argparse/bench_sweep_serve.md" +--8<-- "docs/argparse/bench_sweep_serve.inc.md" diff --git a/docs/cli/bench/sweep/serve_sla.md b/docs/cli/bench/sweep/serve_sla.md index 5f8ab6005e50..53532e249b8b 100644 --- a/docs/cli/bench/sweep/serve_sla.md +++ b/docs/cli/bench/sweep/serve_sla.md @@ -6,4 +6,4 @@ ## Options ---8<-- "docs/argparse/bench_sweep_serve_sla.md" +--8<-- "docs/argparse/bench_sweep_serve_sla.inc.md" diff --git a/docs/cli/bench/throughput.md b/docs/cli/bench/throughput.md index e4ff5ce43c9c..f4ae7cd5654b 100644 --- a/docs/cli/bench/throughput.md +++ b/docs/cli/bench/throughput.md @@ -6,4 +6,4 @@ ## Options ---8<-- "docs/argparse/bench_throughput.md" +--8<-- "docs/argparse/bench_throughput.inc.md" diff --git a/docs/cli/chat.md b/docs/cli/chat.md index b006cb8de60d..fd0e779d3bf0 100644 --- a/docs/cli/chat.md +++ b/docs/cli/chat.md @@ -2,4 +2,4 @@ ## Options ---8<-- "docs/argparse/chat.md" +--8<-- "docs/argparse/chat.inc.md" diff --git a/docs/cli/complete.md b/docs/cli/complete.md index 400359acf4fb..7c06b0337212 100644 --- a/docs/cli/complete.md +++ b/docs/cli/complete.md @@ -2,4 +2,4 @@ ## Options ---8<-- "docs/argparse/complete.md" +--8<-- "docs/argparse/complete.inc.md" diff --git a/docs/cli/run-batch.md b/docs/cli/run-batch.md index f7d401b8dad2..65d3b4ea533f 100644 --- a/docs/cli/run-batch.md +++ b/docs/cli/run-batch.md @@ -6,4 +6,4 @@ ## Options ---8<-- "docs/argparse/run-batch.md" +--8<-- "docs/argparse/run-batch.inc.md" diff --git a/docs/cli/serve.md b/docs/cli/serve.md index 2c8f9d320f5d..61e81e3ea2cc 100644 --- a/docs/cli/serve.md +++ b/docs/cli/serve.md @@ -6,4 +6,4 @@ ## Options ---8<-- "docs/argparse/serve.md" +--8<-- "docs/argparse/serve.inc.md" diff --git a/docs/mkdocs/hooks/generate_argparse.py b/docs/mkdocs/hooks/generate_argparse.py index e1029f5386de..4d3a1676bad5 100644 --- a/docs/mkdocs/hooks/generate_argparse.py +++ b/docs/mkdocs/hooks/generate_argparse.py @@ -228,7 +228,7 @@ def on_startup(command: Literal["build", "gh-deploy", "serve"], dirty: bool): # Generate documentation for each parser for stem, parser in parsers.items(): - doc_path = ARGPARSE_DOC_DIR / f"{stem}.md" + doc_path = ARGPARSE_DOC_DIR / f"{stem}.inc.md" # Specify encoding for building on Windows with open(doc_path, "w", encoding="utf-8") as f: f.write(super(type(parser), parser).format_help()) From 36574777d69fe1f289ec8872613b459a51c016df Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Sat, 15 Nov 2025 13:16:36 +0000 Subject: [PATCH 7/9] Make a couple of info "warnings" go away Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- docs/README.md | 4 ++-- docs/usage/README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 0608794e7e65..0c279c19f96c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,8 +30,8 @@ Originally developed in the [Sky Computing Lab](https://sky.cs.berkeley.edu) at Where to get started with vLLM depends on the type of user. If you are looking to: - Run open-source models on vLLM, we recommend starting with the [Quickstart Guide](./getting_started/quickstart.md) -- Build applications with vLLM, we recommend starting with the [User Guide](./usage) -- Build vLLM, we recommend starting with [Developer Guide](./contributing) +- Build applications with vLLM, we recommend starting with the [User Guide](./usage/README.md) +- Build vLLM, we recommend starting with [Developer Guide](./contributing/README.md) For information about the development of vLLM, see: diff --git a/docs/usage/README.md b/docs/usage/README.md index 0c63d01f0f99..4e8ece2c0605 100644 --- a/docs/usage/README.md +++ b/docs/usage/README.md @@ -1,6 +1,6 @@ # Using vLLM -First, vLLM must be [installed](../getting_started/installation/) for your chosen device in either a Python or Docker environment. +First, vLLM must be [installed](../getting_started/installation/README.md) for your chosen device in either a Python or Docker environment. Then, vLLM supports the following usage patterns: From a4d19283a3e93b23fc82a13e77a5b22298a1d881 Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Sat, 15 Nov 2025 13:20:22 +0000 Subject: [PATCH 8/9] `## Options` -> `## Arguments` in CLI Reference Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- docs/cli/bench/latency.md | 2 +- docs/cli/bench/serve.md | 2 +- docs/cli/bench/sweep/plot.md | 2 +- docs/cli/bench/sweep/serve.md | 2 +- docs/cli/bench/sweep/serve_sla.md | 2 +- docs/cli/bench/throughput.md | 2 +- docs/cli/chat.md | 2 +- docs/cli/complete.md | 2 +- docs/cli/run-batch.md | 2 +- docs/cli/serve.md | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/cli/bench/latency.md b/docs/cli/bench/latency.md index ce6265150adc..ea7ea7321ffc 100644 --- a/docs/cli/bench/latency.md +++ b/docs/cli/bench/latency.md @@ -4,6 +4,6 @@ --8<-- "docs/cli/json_tip.inc.md" -## Options +## Arguments --8<-- "docs/argparse/bench_latency.inc.md" diff --git a/docs/cli/bench/serve.md b/docs/cli/bench/serve.md index f406ed15669a..f7dc8036cc26 100644 --- a/docs/cli/bench/serve.md +++ b/docs/cli/bench/serve.md @@ -4,6 +4,6 @@ --8<-- "docs/cli/json_tip.inc.md" -## Options +## Arguments --8<-- "docs/argparse/bench_serve.inc.md" diff --git a/docs/cli/bench/sweep/plot.md b/docs/cli/bench/sweep/plot.md index 34a303280fed..a101330e093c 100644 --- a/docs/cli/bench/sweep/plot.md +++ b/docs/cli/bench/sweep/plot.md @@ -4,6 +4,6 @@ --8<-- "docs/cli/json_tip.inc.md" -## Options +## Arguments --8<-- "docs/argparse/bench_sweep_plot.inc.md" diff --git a/docs/cli/bench/sweep/serve.md b/docs/cli/bench/sweep/serve.md index 1085636f1b79..f0468f06fc28 100644 --- a/docs/cli/bench/sweep/serve.md +++ b/docs/cli/bench/sweep/serve.md @@ -4,6 +4,6 @@ --8<-- "docs/cli/json_tip.inc.md" -## Options +## Arguments --8<-- "docs/argparse/bench_sweep_serve.inc.md" diff --git a/docs/cli/bench/sweep/serve_sla.md b/docs/cli/bench/sweep/serve_sla.md index 53532e249b8b..5642ec67eb00 100644 --- a/docs/cli/bench/sweep/serve_sla.md +++ b/docs/cli/bench/sweep/serve_sla.md @@ -4,6 +4,6 @@ --8<-- "docs/cli/json_tip.inc.md" -## Options +## Arguments --8<-- "docs/argparse/bench_sweep_serve_sla.inc.md" diff --git a/docs/cli/bench/throughput.md b/docs/cli/bench/throughput.md index f4ae7cd5654b..e7f618fb4d14 100644 --- a/docs/cli/bench/throughput.md +++ b/docs/cli/bench/throughput.md @@ -4,6 +4,6 @@ --8<-- "docs/cli/json_tip.inc.md" -## Options +## Arguments --8<-- "docs/argparse/bench_throughput.inc.md" diff --git a/docs/cli/chat.md b/docs/cli/chat.md index fd0e779d3bf0..0246bd431b10 100644 --- a/docs/cli/chat.md +++ b/docs/cli/chat.md @@ -1,5 +1,5 @@ # vllm chat -## Options +## Arguments --8<-- "docs/argparse/chat.inc.md" diff --git a/docs/cli/complete.md b/docs/cli/complete.md index 7c06b0337212..eb2ffdaabac2 100644 --- a/docs/cli/complete.md +++ b/docs/cli/complete.md @@ -1,5 +1,5 @@ # vllm complete -## Options +## Arguments --8<-- "docs/argparse/complete.inc.md" diff --git a/docs/cli/run-batch.md b/docs/cli/run-batch.md index 65d3b4ea533f..758fbda28397 100644 --- a/docs/cli/run-batch.md +++ b/docs/cli/run-batch.md @@ -4,6 +4,6 @@ --8<-- "docs/cli/json_tip.inc.md" -## Options +## Arguments --8<-- "docs/argparse/run-batch.inc.md" diff --git a/docs/cli/serve.md b/docs/cli/serve.md index 61e81e3ea2cc..35652fec587b 100644 --- a/docs/cli/serve.md +++ b/docs/cli/serve.md @@ -4,6 +4,6 @@ --8<-- "docs/cli/json_tip.inc.md" -## Options +## Arguments --8<-- "docs/argparse/serve.inc.md" From dd8c3bfb5213d8cdd433cc90080b6afa932c4664 Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Sat, 15 Nov 2025 13:23:05 +0000 Subject: [PATCH 9/9] Mock if torch not found Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- docs/mkdocs/hooks/generate_argparse.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/mkdocs/hooks/generate_argparse.py b/docs/mkdocs/hooks/generate_argparse.py index 4d3a1676bad5..735074c08b8c 100644 --- a/docs/mkdocs/hooks/generate_argparse.py +++ b/docs/mkdocs/hooks/generate_argparse.py @@ -22,9 +22,9 @@ sys.path.insert(0, str(ROOT_DIR)) -def mock_if_not_found(module_name: str, mock: MagicMock): - if not importlib.util.find_spec(module_name): - sys.modules[module_name] = mock +def mock_if_no_torch(mock_module: str, mock: MagicMock): + if not importlib.util.find_spec("torch"): + sys.modules[mock_module] = mock # Mock custom op code @@ -37,9 +37,9 @@ def decorator(cls): return decorator -mock_if_not_found("vllm._C", MagicMock()) -mock_if_not_found("vllm.model_executor.custom_op", MagicMock(CustomOp=MockCustomOp)) -mock_if_not_found( +mock_if_no_torch("vllm._C", MagicMock()) +mock_if_no_torch("vllm.model_executor.custom_op", MagicMock(CustomOp=MockCustomOp)) +mock_if_no_torch( "vllm.utils.torch_utils", MagicMock(direct_register_custom_op=lambda *a, **k: None) ) @@ -51,7 +51,7 @@ def decorator(cls): # Make torch.nn.Parameter safe to inherit from -mock_if_not_found("torch.nn", MagicMock(Parameter=object)) +mock_if_no_torch("torch.nn", MagicMock(Parameter=object)) class PydanticMagicMock(MagicMock):