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 10, 06:30 UTC
[Model] Handle `trust_remote_code` for transformers backend (#32194)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Cyrus Leung committed
Jan 13, 2026 at 09:30 UTC
78d13ea9de4b1ce5e4d8a5af9738fea71fb024e5
2 files changed
+14
-1
vllm/model_executor/models/registry.py
+2
@@ -887,6 +887,7 @@ class _ModelRegistry:
887
module,
888
model_config.model,
889
revision=model_config.revision,
890
+ trust_remote_code=model_config.trust_remote_code,
891
warn_on_fail=False,
892
)
893
@@ -899,6 +900,7 @@ class _ModelRegistry:
900
module,
901
model_config.model,
902
revision=model_config.revision,
903
+ trust_remote_code=model_config.trust_remote_code,
904
warn_on_fail=True,
905
)
906
if model_module is not None:
vllm/transformers_utils/dynamic_module.py
+12
-1
@@ -2,7 +2,10 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
import os
4
5
-from transformers.dynamic_module_utils import get_class_from_dynamic_module
5
+from transformers.dynamic_module_utils import (
6
+ get_class_from_dynamic_module,
7
+ resolve_trust_remote_code,
8
+)
9
10
import vllm.envs as envs
11
from vllm.logger import init_logger
@@ -13,6 +16,7 @@ logger = init_logger(__name__)
16
def try_get_class_from_dynamic_module(
17
class_reference: str,
18
pretrained_model_name_or_path: str,
19
+ trust_remote_code: bool,
20
cache_dir: str | os.PathLike | None = None,
21
force_download: bool = False,
22
resume_download: bool | None = None,
@@ -30,6 +34,13 @@ def try_get_class_from_dynamic_module(
34
but ignoring any errors.
35
"""
36
try:
37
+ resolve_trust_remote_code(
38
+ trust_remote_code,
39
+ pretrained_model_name_or_path,
40
+ has_local_code=False,
41
+ has_remote_code=True,
42
+ )
43
+
44
return get_class_from_dynamic_module(
45
class_reference,
46
pretrained_model_name_or_path,