[Bugfix] Avoid MistralCommonBackend for HF tokenizers (#54192)

Signed-off-by: Julien Denize <40604584+juliendenize@users.noreply.github.com>
This commit is contained in:
Julien Denize
2026-09-10 17:57:44 +00:00
committed by GitHub
parent 8359e15aae
commit 983b7e28c9
7 changed files with 129 additions and 157 deletions
-13
View File
@@ -14,7 +14,6 @@ from typing import TYPE_CHECKING, TypeVar
import regex as re
import torch
from cachetools import LRUCache
from transformers import MistralCommonBackend
import vllm.envs as envs
from vllm.logger import init_logger
@@ -320,18 +319,6 @@ re_llama_byte_token = re.compile(r"^<0x[0-9A-F]{2}>$")
re_replacement_seq = re.compile(r"^.{0,6}�+.{0,6}$")
def maybe_wrap_mistral_common_tokenizer(tokenizer: TokenizerLike) -> TokenizerLike:
"""The grammar backends cannot consume a `MistralCommonBackend` directly."""
if not isinstance(tokenizer, MistralCommonBackend):
return tokenizer
# Deferred: `vllm.tokenizers.mistral` pulls in a large dependency tree, and
# this module is imported by `vllm.v1.worker.gpu_model_runner`.
from vllm.tokenizers.mistral import MistralTokenizer
return MistralTokenizer(tokenizer)
def _reduced_vocabulary(tokenizer: TokenizerLike) -> dict[bytes, list[int]]:
"""Create a map from vocabulary tokens to lists of equivalent token ids.