mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-22 21:05:46 +08:00
[Bugfix] Fix failing transformers dynamic module resolving with spawn multiproc method (#13403)
Signed-off-by: Isotr0py <2037008807@qq.com>
This commit is contained in:
parent
e2603fefb8
commit
8cf97f8661
@ -47,22 +47,31 @@ def resolve_transformers_fallback(model_config: ModelConfig,
|
|||||||
for i, arch in enumerate(architectures):
|
for i, arch in enumerate(architectures):
|
||||||
if arch == "TransformersModel":
|
if arch == "TransformersModel":
|
||||||
continue
|
continue
|
||||||
custom_module = None
|
auto_map: dict[str, str] = getattr(model_config.hf_config, "auto_map",
|
||||||
auto_map = getattr(model_config.hf_config, "auto_map", None)
|
None) or dict()
|
||||||
if auto_map is not None and "AutoModel" in auto_map:
|
# Make sure that config class is always initialized before model class,
|
||||||
custom_module = get_class_from_dynamic_module(
|
# otherwise the model class won't be able to access the config class,
|
||||||
model_config.hf_config.auto_map["AutoModel"],
|
# the expected auto_map should have correct order like:
|
||||||
model_config.model)
|
# "auto_map": {
|
||||||
|
# "AutoConfig": "<your-repo-name>--<config-name>",
|
||||||
|
# "AutoModel": "<your-repo-name>--<config-name>",
|
||||||
|
# "AutoModelFor<Task>": "<your-repo-name>--<config-name>",
|
||||||
|
# },
|
||||||
|
auto_modules = {
|
||||||
|
name: get_class_from_dynamic_module(module, model_config.model)
|
||||||
|
for name, module in sorted(auto_map.items(), key=lambda x: x[0])
|
||||||
|
}
|
||||||
|
custom_model_module = auto_modules.get("AutoModel")
|
||||||
# TODO(Isotr0py): Further clean up these raises.
|
# TODO(Isotr0py): Further clean up these raises.
|
||||||
# perhaps handled them in _ModelRegistry._raise_for_unsupported?
|
# perhaps handled them in _ModelRegistry._raise_for_unsupported?
|
||||||
if model_config.model_impl == ModelImpl.TRANSFORMERS:
|
if model_config.model_impl == ModelImpl.TRANSFORMERS:
|
||||||
if not is_transformers_impl_compatible(arch, custom_module):
|
if not is_transformers_impl_compatible(arch, custom_model_module):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"The Transformers implementation of {arch} is not "
|
f"The Transformers implementation of {arch} is not "
|
||||||
"compatible with vLLM.")
|
"compatible with vLLM.")
|
||||||
architectures[i] = "TransformersModel"
|
architectures[i] = "TransformersModel"
|
||||||
if model_config.model_impl == ModelImpl.AUTO:
|
if model_config.model_impl == ModelImpl.AUTO:
|
||||||
if not is_transformers_impl_compatible(arch, custom_module):
|
if not is_transformers_impl_compatible(arch, custom_model_module):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"{arch} has no vLLM implementation and the Transformers "
|
f"{arch} has no vLLM implementation and the Transformers "
|
||||||
"implementation is not compatible with vLLM.")
|
"implementation is not compatible with vLLM.")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user