Skip to content

Commit

Permalink
Add better error message when custom model is used without `--trust-r…
Browse files Browse the repository at this point in the history
…emote-code`

Signed-off-by: Harry Mellor <[email protected]>
  • Loading branch information
hmellor committed Feb 14, 2025
1 parent 3b56faf commit 58257b7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions vllm/model_executor/model_loader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ def resolve_transformers_fallback(model_config: ModelConfig,
custom_module = None
auto_map = getattr(model_config.hf_config, "auto_map", None)
if auto_map is not None and "AutoModel" in auto_map:
custom_module = get_class_from_dynamic_module(
model_config.hf_config.auto_map["AutoModel"],
model_config.model)
try:
custom_module = get_class_from_dynamic_module(
model_config.hf_config.auto_map["AutoModel"],
model_config.model)
except ModuleNotFoundError as e:
raise ValueError(
f"'{model_config.model}' might be a custom model defined "
"on the Hub. If you trust the author and have read the "
"code, try using `--trust-remote-code` or "
"`trust_remote_code`.") from e
# TODO(Isotr0py): Further clean up these raises.
# perhaps handled them in _ModelRegistry._raise_for_unsupported?
if model_config.model_impl == ModelImpl.TRANSFORMERS:
Expand Down

0 comments on commit 58257b7

Please sign in to comment.