[Performance] Load HF tokenizers and processors from a local snapshot (#60825)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Kevin H. Luu <khluu000@gmail.com>
This commit is contained in:
Harry Mellor
2026-10-12 13:45:54 +00:00
committed by GitHub
co-authored by Claude Opus 5.5 Kevin H. Luu
parent 092c35dd15
commit 3facf822b7
5 changed files with 146 additions and 4 deletions
+15 -2
View File
@@ -22,7 +22,10 @@ from typing_extensions import TypeVar
from vllm.logger import init_logger
from vllm.transformers_utils import processors
from vllm.transformers_utils.repo_utils import get_hf_file_to_dict
from vllm.transformers_utils.repo_utils import (
get_hf_file_to_dict,
get_non_weight_snapshot_path,
)
from vllm.transformers_utils.utils import convert_model_repo_to_path
from vllm.utils.func_utils import get_allowed_kwarg_only_overrides
@@ -214,7 +217,12 @@ def get_processor(
if revision is None:
revision = "main"
try:
processor_name = convert_model_repo_to_path(processor_name)
processor_name = requested_name = convert_model_repo_to_path(processor_name)
# A snapshot pinned to `revision` would shadow remote code at `code_revision`
if kwargs.get("code_revision") in (None, revision):
processor_name = get_non_weight_snapshot_path(
processor_name, revision=revision, token=kwargs.get("token")
)
registered_cls_name = get_processor_cls_name_from_config(
processor_name, revision=revision
)
@@ -269,6 +277,11 @@ def get_processor(
f"found type: {type(processor)}"
)
# Report the Hub ID rather than the local snapshot it was loaded from
tokenizer = getattr(processor, "tokenizer", processor)
if hasattr(tokenizer, "name_or_path"):
tokenizer.name_or_path = requested_name
return processor