MCPcopy Index your code
hub / github.com/NVIDIA/TensorRT-LLM / _init_hf_modules

Function _init_hf_modules

tensorrt_llm/executor/base_worker.py:47–63  ·  view source on GitHub ↗

Initialize cached HuggingFace modules for models with trust_remote_code=True. This is safe to call multiple times (idempotent) and should be called: 1. At module import time (for main process and spawned subprocesses) 2. At worker_main entry (for forked processes or external MPI ranks)

()

Source from the content-addressed store, hash-verified

45
46
47def _init_hf_modules():
48 """Initialize cached HuggingFace modules for models with trust_remote_code=True.
49
50 This is safe to call multiple times (idempotent) and should be called:
51 1. At module import time (for main process and spawned subprocesses)
52 2. At worker_main entry (for forked processes or external MPI ranks)
53
54 References: https://github.com/vllm-project/vllm/pull/871
55 """
56 try:
57 from transformers.dynamic_module_utils import init_hf_modules
58 init_hf_modules()
59 logger.debug("HF modules initialized")
60 except ImportError as e:
61 logger.warning(f"ImportError initializing HF modules: {e}")
62 except Exception as e:
63 logger.error(f"Exception initializing HF modules: {e}")
64
65
66_init_hf_modules()

Callers 2

base_worker.pyFile · 0.85
worker_mainFunction · 0.85

Calls 3

debugMethod · 0.45
warningMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected