@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / e81fbefe8a
Fork 0

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 15, 03:30 UTC

[Refactor] Refactor import utils (#20269)

Signed-off-by: yewentao256 <zhyanwentao@126.com>

Wentao Ye committed Jul 1, 2025 at 21:05 UTC e81fbefe8a3fc7acef9ba7656f9da97a579af532
4 files changed +10 -11
pyproject.toml
+1 -1
@@ -76,7 +76,7 @@ line-length = 80
76 "vllm/spec_decode/**/*.py" = ["UP006", "UP035"]
77 "vllm/worker/**/*.py" = ["UP006", "UP035"]
78 # Python 3.8 typing - skip utils for ROCm
79 -"vllm/utils.py" = ["UP006", "UP035"]
79 +"vllm/utils/__init__.py" = ["UP006", "UP035"]
80
81 [tool.ruff.lint]
82 select = [
tests/build_cython.py
+1 -1
@@ -25,7 +25,7 @@ infiles += [
25 infiles += [
26 "vllm/model_executor/layers/sampler.py",
27 "vllm/sampling_params.py",
28 - "vllm/utils.py",
28 + "vllm/utils/__init__.py",
29 ]
30
31 setup(ext_modules=cythonize(infiles,
tools/check_pickle_imports.py
+1 -2
@@ -26,7 +26,6 @@ except ImportError:
26 # add to this list if absolutely necessary and after careful security review.
27 ALLOWED_FILES = set([
28 # pickle
29 - 'vllm/utils.py',
29 'vllm/v1/serial_utils.py',
30 'vllm/v1/executor/multiproc_executor.py',
31 'vllm/multimodal/hasher.py',
@@ -54,7 +53,7 @@ ALLOWED_FILES = set([
53 'vllm/entrypoints/llm.py',
54 'tests/utils.py',
55 # pickle and cloudpickle
57 - 'vllm/utils.py',
56 + 'vllm/utils/__init__.py',
57 'vllm/v1/serial_utils.py',
58 'vllm/v1/executor/multiproc_executor.py',
59 'vllm/transformers_utils/config.py',
vllm/utils/__init__.py renamed
+7 -7
@@ -39,14 +39,14 @@ from argparse import (Action, ArgumentDefaultsHelpFormatter, ArgumentParser,
39 from asyncio import FIRST_COMPLETED, AbstractEventLoop, Task
40 from collections import UserDict, defaultdict
41 from collections.abc import (AsyncGenerator, Awaitable, Collection, Generator,
42 - Hashable, Iterable, Iterator, KeysView, Mapping)
42 + Hashable, Iterable, Iterator, KeysView, Mapping,
43 + Sequence)
44 from concurrent.futures.process import ProcessPoolExecutor
45 from dataclasses import dataclass, field
46 from functools import cache, lru_cache, partial, wraps
47 from types import MappingProxyType
48 from typing import (TYPE_CHECKING, Any, Callable, Generic, Literal, NamedTuple,
48 - Optional, Sequence, Tuple, Type, TypeVar, Union, cast,
49 - overload)
49 + Optional, TypeVar, Union, cast, overload)
50 from urllib.parse import urlparse
51 from uuid import uuid4
52
@@ -1921,9 +1921,9 @@ class LazyDict(Mapping[str, T], Generic[T]):
1921 return len(self._factory)
1922
1923
1924 -class ClassRegistry(UserDict[Type[T], _V]):
1924 +class ClassRegistry(UserDict[type[T], _V]):
1925
1926 - def __getitem__(self, key: Type[T]) -> _V:
1926 + def __getitem__(self, key: type[T]) -> _V:
1927 for cls in key.mro():
1928 if cls in self.data:
1929 return self.data[cls]
@@ -2234,7 +2234,7 @@ def direct_register_custom_op(
2234 fake_impl: Optional[Callable] = None,
2235 target_lib: Optional[Library] = None,
2236 dispatch_key: str = "CUDA",
2237 - tags: Tuple[torch.Tag, ...] = (),
2237 + tags: tuple[torch.Tag, ...] = (),
2238 ):
2239 """
2240 `torch.library.custom_op` can have significant overhead because it
@@ -2489,7 +2489,7 @@ def get_exception_traceback():
2489 return err_str
2490
2491
2492 -def split_zmq_path(path: str) -> Tuple[str, str, str]:
2492 +def split_zmq_path(path: str) -> tuple[str, str, str]:
2493 """Split a zmq path into its parts."""
2494 parsed = urlparse(path)
2495 if not parsed.scheme: