Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
4d4d6bad
Unverified
Commit
4d4d6bad
authored
Oct 17, 2025
by
Cyrus Leung
Committed by
GitHub
Oct 17, 2025
Browse files
[Chore] Separate out `vllm.utils.importlib` (#27022)
Signed-off-by:
DarkLight1337
<
tlleungac@connect.ust.hk
>
parent
11ae016b
Changes
41
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
70 additions
and
59 deletions
+70
-59
tests/model_executor/model_loader/tensorizer_loader/test_tensorizer.py
...xecutor/model_loader/tensorizer_loader/test_tensorizer.py
+1
-1
tests/utils_/test_import_utils.py
tests/utils_/test_import_utils.py
+46
-0
tests/utils_/test_utils.py
tests/utils_/test_utils.py
+0
-41
tests/v1/attention/utils.py
tests/v1/attention/utils.py
+1
-1
vllm/assets/audio.py
vllm/assets/audio.py
+1
-1
vllm/assets/video.py
vllm/assets/video.py
+1
-1
vllm/attention/backends/registry.py
vllm/attention/backends/registry.py
+1
-1
vllm/attention/selector.py
vllm/attention/selector.py
+2
-1
vllm/benchmarks/datasets.py
vllm/benchmarks/datasets.py
+1
-1
vllm/compilation/backends.py
vllm/compilation/backends.py
+2
-1
vllm/compilation/decorators.py
vllm/compilation/decorators.py
+2
-1
vllm/config/compilation.py
vllm/config/compilation.py
+2
-1
vllm/config/model.py
vllm/config/model.py
+2
-1
vllm/config/speculative.py
vllm/config/speculative.py
+1
-1
vllm/distributed/parallel_state.py
vllm/distributed/parallel_state.py
+1
-1
vllm/entrypoints/openai/protocol.py
vllm/entrypoints/openai/protocol.py
+2
-1
vllm/entrypoints/openai/speech_to_text.py
vllm/entrypoints/openai/speech_to_text.py
+1
-1
vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
+1
-1
vllm/lora/punica_wrapper/punica_selector.py
vllm/lora/punica_wrapper/punica_selector.py
+1
-1
vllm/model_executor/layers/pooler.py
vllm/model_executor/layers/pooler.py
+1
-1
No files found.
tests/model_executor/model_loader/tensorizer_loader/test_tensorizer.py
View file @
4d4d6bad
...
...
@@ -27,7 +27,7 @@ from vllm.model_executor.model_loader.tensorizer import (
from
vllm.model_executor.model_loader.tensorizer_loader
import
(
BLACKLISTED_TENSORIZER_ARGS
,
)
from
vllm.utils
import
PlaceholderModule
from
vllm.utils
.import_utils
import
PlaceholderModule
from
.conftest
import
DummyExecutor
,
assert_from_collective_rpc
...
...
tests/utils_/test_import_utils.py
0 → 100644
View file @
4d4d6bad
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
pytest
from
vllm.utils.import_utils
import
PlaceholderModule
def
_raises_module_not_found
():
return
pytest
.
raises
(
ModuleNotFoundError
,
match
=
"No module named"
)
def
test_placeholder_module_error_handling
():
placeholder
=
PlaceholderModule
(
"placeholder_1234"
)
with
_raises_module_not_found
():
int
(
placeholder
)
with
_raises_module_not_found
():
placeholder
()
with
_raises_module_not_found
():
_
=
placeholder
.
some_attr
with
_raises_module_not_found
():
# Test conflict with internal __name attribute
_
=
placeholder
.
name
# OK to print the placeholder or use it in a f-string
_
=
repr
(
placeholder
)
_
=
str
(
placeholder
)
# No error yet; only error when it is used downstream
placeholder_attr
=
placeholder
.
placeholder_attr
(
"attr"
)
with
_raises_module_not_found
():
int
(
placeholder_attr
)
with
_raises_module_not_found
():
placeholder_attr
()
with
_raises_module_not_found
():
_
=
placeholder_attr
.
some_attr
with
_raises_module_not_found
():
# Test conflict with internal __module attribute
_
=
placeholder_attr
.
module
tests/utils_/test_utils.py
View file @
4d4d6bad
...
...
@@ -24,7 +24,6 @@ from vllm.transformers_utils.detokenizer_utils import convert_ids_list_to_tokens
from
vllm.utils
import
(
FlexibleArgumentParser
,
MemorySnapshot
,
PlaceholderModule
,
bind_kv_cache
,
common_broadcastable_dtype
,
current_stream
,
...
...
@@ -475,46 +474,6 @@ def test_common_broadcastable_dtype(dtypes, expected_result):
assert
common_broadcastable_dtype
(
dtypes
)
==
expected_result
def
test_placeholder_module_error_handling
():
placeholder
=
PlaceholderModule
(
"placeholder_1234"
)
def
build_ctx
():
return
pytest
.
raises
(
ModuleNotFoundError
,
match
=
"No module named"
)
with
build_ctx
():
int
(
placeholder
)
with
build_ctx
():
placeholder
()
with
build_ctx
():
_
=
placeholder
.
some_attr
with
build_ctx
():
# Test conflict with internal __name attribute
_
=
placeholder
.
name
# OK to print the placeholder or use it in a f-string
_
=
repr
(
placeholder
)
_
=
str
(
placeholder
)
# No error yet; only error when it is used downstream
placeholder_attr
=
placeholder
.
placeholder_attr
(
"attr"
)
with
build_ctx
():
int
(
placeholder_attr
)
with
build_ctx
():
placeholder_attr
()
with
build_ctx
():
_
=
placeholder_attr
.
some_attr
with
build_ctx
():
# Test conflict with internal __module attribute
_
=
placeholder_attr
.
module
def
test_model_specification
(
parser_with_config
,
cli_config_file
,
cli_config_file_with_model
):
...
...
tests/v1/attention/utils.py
View file @
4d4d6bad
...
...
@@ -20,7 +20,7 @@ from vllm.config import (
VllmConfig
,
)
from
vllm.config.model
import
ModelDType
from
vllm.utils
import
resolve_obj_by_qualname
from
vllm.utils
.import_utils
import
resolve_obj_by_qualname
from
vllm.v1.attention.backends.utils
import
(
AttentionMetadataBuilder
,
CommonAttentionMetadata
,
...
...
vllm/assets/audio.py
View file @
4d4d6bad
...
...
@@ -8,7 +8,7 @@ from urllib.parse import urljoin
import
numpy.typing
as
npt
from
vllm.utils
import
PlaceholderModule
from
vllm.utils
.import_utils
import
PlaceholderModule
from
.base
import
VLLM_S3_BUCKET_URL
,
get_vllm_public_assets
...
...
vllm/assets/video.py
View file @
4d4d6bad
...
...
@@ -10,7 +10,7 @@ import numpy.typing as npt
from
huggingface_hub
import
hf_hub_download
from
PIL
import
Image
from
vllm.utils
import
PlaceholderModule
from
vllm.utils
.import_utils
import
PlaceholderModule
from
.base
import
get_cache_dir
...
...
vllm/attention/backends/registry.py
View file @
4d4d6bad
...
...
@@ -4,7 +4,7 @@
import
enum
from
vllm.utils
import
resolve_obj_by_qualname
from
vllm.utils
.import_utils
import
resolve_obj_by_qualname
class
_Backend
(
enum
.
Enum
):
...
...
vllm/attention/selector.py
View file @
4d4d6bad
...
...
@@ -13,7 +13,8 @@ import vllm.envs as envs
from
vllm.attention.backends.abstract
import
AttentionBackend
from
vllm.attention.backends.registry
import
_Backend
,
backend_name_to_enum
from
vllm.logger
import
init_logger
from
vllm.utils
import
STR_BACKEND_ENV_VAR
,
resolve_obj_by_qualname
from
vllm.utils
import
STR_BACKEND_ENV_VAR
from
vllm.utils.import_utils
import
resolve_obj_by_qualname
logger
=
init_logger
(
__name__
)
...
...
vllm/benchmarks/datasets.py
View file @
4d4d6bad
...
...
@@ -39,7 +39,7 @@ from vllm.lora.utils import get_adapter_absolute_path
from
vllm.multimodal
import
MultiModalDataDict
from
vllm.multimodal.image
import
convert_image_mode
from
vllm.transformers_utils.tokenizer
import
AnyTokenizer
from
vllm.utils
import
PlaceholderModule
from
vllm.utils
.import_utils
import
PlaceholderModule
try
:
from
datasets
import
load_dataset
...
...
vllm/compilation/backends.py
View file @
4d4d6bad
...
...
@@ -24,7 +24,8 @@ from vllm.compilation.partition_rules import (
from
vllm.config
import
CompilationConfig
,
CUDAGraphMode
,
VllmConfig
from
vllm.logger
import
init_logger
from
vllm.platforms
import
current_platform
from
vllm.utils
import
is_torch_equal_or_newer
,
resolve_obj_by_qualname
from
vllm.utils
import
is_torch_equal_or_newer
from
vllm.utils.import_utils
import
resolve_obj_by_qualname
from
.caching
import
VllmSerializableFunction
from
.compiler_interface
import
(
...
...
vllm/compilation/decorators.py
View file @
4d4d6bad
...
...
@@ -21,7 +21,8 @@ from vllm.compilation.wrapper import TorchCompileWrapperWithCustomDispatcher
from
vllm.config
import
CompilationMode
,
VllmConfig
,
set_current_vllm_config
from
vllm.logger
import
init_logger
from
vllm.sequence
import
IntermediateTensors
from
vllm.utils
import
resolve_obj_by_qualname
,
supports_dynamo
from
vllm.utils
import
supports_dynamo
from
vllm.utils.import_utils
import
resolve_obj_by_qualname
from
.monitor
import
start_monitoring_torch_compile
...
...
vllm/config/compilation.py
View file @
4d4d6bad
...
...
@@ -16,7 +16,8 @@ from vllm.compilation.inductor_pass import CallableInductorPass, InductorPass
from
vllm.config.utils
import
config
from
vllm.logger
import
init_logger
from
vllm.platforms
import
current_platform
from
vllm.utils
import
is_torch_equal_or_newer
,
resolve_obj_by_qualname
from
vllm.utils
import
is_torch_equal_or_newer
from
vllm.utils.import_utils
import
resolve_obj_by_qualname
if
TYPE_CHECKING
:
from
vllm.config
import
VllmConfig
...
...
vllm/config/model.py
View file @
4d4d6bad
...
...
@@ -41,7 +41,8 @@ from vllm.transformers_utils.config import (
)
from
vllm.transformers_utils.runai_utils
import
ObjectStorageModel
,
is_runai_obj_uri
from
vllm.transformers_utils.utils
import
maybe_model_redirect
from
vllm.utils
import
LayerBlockType
,
LazyLoader
,
common_broadcastable_dtype
from
vllm.utils
import
LayerBlockType
,
common_broadcastable_dtype
from
vllm.utils.import_utils
import
LazyLoader
if
TYPE_CHECKING
:
from
transformers
import
PretrainedConfig
...
...
vllm/config/speculative.py
View file @
4d4d6bad
...
...
@@ -13,7 +13,7 @@ import vllm.envs as envs
from
vllm.config.parallel
import
ParallelConfig
from
vllm.config.utils
import
config
from
vllm.logger
import
init_logger
from
vllm.utils
import
LazyLoader
from
vllm.utils
.import_utils
import
LazyLoader
if
TYPE_CHECKING
:
from
transformers
import
PretrainedConfig
...
...
vllm/distributed/parallel_state.py
View file @
4d4d6bad
...
...
@@ -52,9 +52,9 @@ from vllm.logger import init_logger
from
vllm.utils
import
(
direct_register_custom_op
,
get_distributed_init_method
,
resolve_obj_by_qualname
,
supports_custom_op
,
)
from
vllm.utils.import_utils
import
resolve_obj_by_qualname
@
dataclass
...
...
vllm/entrypoints/openai/protocol.py
View file @
4d4d6bad
...
...
@@ -81,7 +81,8 @@ from vllm.sampling_params import (
SamplingParams
,
StructuredOutputsParams
,
)
from
vllm.utils
import
random_uuid
,
resolve_obj_by_qualname
from
vllm.utils
import
random_uuid
from
vllm.utils.import_utils
import
resolve_obj_by_qualname
EMBED_DTYPE_TO_TORCH_DTYPE
=
{
"float32"
:
torch
.
float32
,
...
...
vllm/entrypoints/openai/speech_to_text.py
View file @
4d4d6bad
...
...
@@ -32,7 +32,7 @@ from vllm.inputs.data import PromptType
from
vllm.logger
import
init_logger
from
vllm.model_executor.models
import
SupportsTranscription
from
vllm.outputs
import
RequestOutput
from
vllm.utils
import
PlaceholderModule
from
vllm.utils
.import_utils
import
PlaceholderModule
try
:
import
librosa
...
...
vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py
View file @
4d4d6bad
...
...
@@ -12,8 +12,8 @@ from vllm.entrypoints.openai.protocol import (
)
from
vllm.logger
import
init_logger
from
vllm.transformers_utils.tokenizer
import
AnyTokenizer
from
vllm.utils
import
import_from_path
from
vllm.utils.collections
import
is_list_of
from
vllm.utils.import_utils
import
import_from_path
logger
=
init_logger
(
__name__
)
...
...
vllm/lora/punica_wrapper/punica_selector.py
View file @
4d4d6bad
...
...
@@ -3,7 +3,7 @@
from
vllm.logger
import
init_logger
from
vllm.platforms
import
current_platform
from
vllm.utils
import
resolve_obj_by_qualname
from
vllm.utils
.import_utils
import
resolve_obj_by_qualname
from
.punica_base
import
PunicaWrapperBase
...
...
vllm/model_executor/layers/pooler.py
View file @
4d4d6bad
...
...
@@ -17,7 +17,7 @@ from vllm.logger import init_logger
from
vllm.model_executor.models.adapters
import
_load_st_projector
from
vllm.pooling_params
import
PoolingParams
from
vllm.tasks
import
PoolingTask
from
vllm.utils
import
resolve_obj_by_qualname
from
vllm.utils
.import_utils
import
resolve_obj_by_qualname
from
vllm.v1.outputs
import
PoolerOutput
from
vllm.v1.pool.metadata
import
PoolingCursor
,
PoolingMetadata
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment