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)
()
| 45 | |
| 46 | |
| 47 | def _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() |
no test coverage detected