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
8d1096e7
Unverified
Commit
8d1096e7
authored
Jul 03, 2025
by
Seiji Eicher
Committed by
GitHub
Jul 03, 2025
Browse files
[Bugfix] Register reducer even if transformers_modules not available (#19510)
Signed-off-by:
Seiji Eicher
<
seiji@anyscale.com
>
parent
8d775dd3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
15 deletions
+73
-15
tests/config/test_mp_reducer.py
tests/config/test_mp_reducer.py
+57
-0
vllm/transformers_utils/config.py
vllm/transformers_utils/config.py
+16
-15
No files found.
tests/config/test_mp_reducer.py
0 → 100644
View file @
8d1096e7
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
sys
from
unittest.mock
import
patch
from
vllm.config
import
VllmConfig
from
vllm.engine.arg_utils
import
AsyncEngineArgs
from
vllm.v1.engine.async_llm
import
AsyncLLM
def
test_mp_reducer
(
monkeypatch
):
"""
Test that _reduce_config reducer is registered when AsyncLLM is instantiated
without transformers_modules. This is a regression test for
https://github.com/vllm-project/vllm/pull/18640.
"""
# Use V1 AsyncLLM which calls maybe_register_config_serialize_by_value
monkeypatch
.
setenv
(
'VLLM_USE_V1'
,
'1'
)
# Ensure transformers_modules is not in sys.modules
if
'transformers_modules'
in
sys
.
modules
:
del
sys
.
modules
[
'transformers_modules'
]
with
patch
(
'multiprocessing.reducer.register'
)
as
mock_register
:
engine_args
=
AsyncEngineArgs
(
model
=
"facebook/opt-125m"
,
max_model_len
=
32
,
gpu_memory_utilization
=
0.1
,
disable_log_stats
=
True
,
disable_log_requests
=
True
,
)
async_llm
=
AsyncLLM
.
from_engine_args
(
engine_args
,
start_engine_loop
=
False
,
)
assert
mock_register
.
called
,
(
"multiprocessing.reducer.register should have been called"
)
vllm_config_registered
=
False
for
call_args
in
mock_register
.
call_args_list
:
# Verify that a reducer for VllmConfig was registered
if
len
(
call_args
[
0
])
>=
2
and
call_args
[
0
][
0
]
==
VllmConfig
:
vllm_config_registered
=
True
reducer_func
=
call_args
[
0
][
1
]
assert
callable
(
reducer_func
),
"Reducer function should be callable"
break
assert
vllm_config_registered
,
(
"VllmConfig should have been registered to multiprocessing.reducer"
)
async_llm
.
shutdown
()
vllm/transformers_utils/config.py
View file @
8d1096e7
...
...
@@ -655,34 +655,35 @@ def maybe_register_config_serialize_by_value() -> None:
"""
# noqa
try
:
import
transformers_modules
transformers_modules_available
=
True
except
ImportError
:
# the config does not need trust_remote_code
return
transformers_modules_available
=
False
try
:
import
cloudpickle
cloudpickle
.
register_pickle_by_value
(
transformers_modules
)
# ray vendors its own version of cloudpickle
from
vllm.executor.ray_utils
import
ray
if
ray
:
ray
.
cloudpickle
.
register_pickle_by_value
(
transformers_modules
)
# multiprocessing uses pickle to serialize arguments when using spawn
# Here we get pickle to use cloudpickle to serialize config objects
# that contain instances of the custom config class to avoid
# serialization problems if the generated module (and model) has a `.`
# in its name
import
multiprocessing
import
pickle
import
cloudpickle
from
vllm.config
import
VllmConfig
# Register multiprocessing reducers to handle cross-process
# serialization of VllmConfig objects that may contain custom configs
# from transformers_modules
def
_reduce_config
(
config
:
VllmConfig
):
return
(
pickle
.
loads
,
(
cloudpickle
.
dumps
(
config
),
))
multiprocessing
.
reducer
.
register
(
VllmConfig
,
_reduce_config
)
# Register transformers_modules with cloudpickle if available
if
transformers_modules_available
:
cloudpickle
.
register_pickle_by_value
(
transformers_modules
)
# ray vendors its own version of cloudpickle
from
vllm.executor.ray_utils
import
ray
if
ray
:
ray
.
cloudpickle
.
register_pickle_by_value
(
transformers_modules
)
except
Exception
as
e
:
logger
.
warning
(
"Unable to register remote classes used by"
...
...
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