vllm - ✅(Solved) Fix [Bug]: TokenizersBackend fallback returns tokenizer without `max_chars_per_token` [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vllm-project/vllm#41719Fetched 2026-05-06 06:15:16
View on GitHub
Comments
1
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
commented ×1cross-referenced ×1labeled ×1

vLLM has a fallback for models with incorrect Hub tokenizer_class metadata:

_MODEL_TYPES_WITH_INCORRECT_TOKENIZER_CLASS = {"step3_vl"}

model_type="step3_vl" is used by stepfun-ai/step3.

This fallback returns a bare Transformers TokenizersBackend. Unlike the normal HF tokenizer path, it is not wrapped with get_cached_tokenizer(), so it misses vLLM-required properties such as max_chars_per_token.

Error Message

AttributeError: TokenizersBackend has no attribute max_chars_per_token

Root Cause

vLLM has a fallback for models with incorrect Hub tokenizer_class metadata:

_MODEL_TYPES_WITH_INCORRECT_TOKENIZER_CLASS = {"step3_vl"}

model_type="step3_vl" is used by stepfun-ai/step3.

This fallback returns a bare Transformers TokenizersBackend. Unlike the normal HF tokenizer path, it is not wrapped with get_cached_tokenizer(), so it misses vLLM-required properties such as max_chars_per_token.

Fix Action

Fix / Workaround

============================== CPU Info

Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 32 On-line CPU(s) list: 0-31 Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz CPU family: 6 Model: 45 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 2 Stepping: 7 CPU max MHz: 3300.0000 CPU min MHz: 1200.0000 BogoMIPS: 5200.17 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid xsaveopt dtherm ida arat pln pts vnmi md_clear flush_l1d Virtualization: VT-x L1d cache: 512 KiB (16 instances) L1i cache: 512 KiB (16 instances) L2 cache: 4 MiB (16 instances) L3 cache: 40 MiB (2 instances) NUMA node(s): 2 NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30 NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31 Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX vulnerable Vulnerability Mds: Vulnerable; SMT vulnerable Vulnerability Meltdown: Vulnerable Vulnerability Mmio stale data: Unknown: No mitigations Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Vulnerable Vulnerability Spectre v1: Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers Vulnerability Spectre v2: Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-eIBRS: Not affected; BHI: Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Vulnerable

PR fix notes

PR #41721: [BugFix] Wrap TokenizersBackend fallback with cached tokenizer

Description (problem / solution / changelog)

Purpose

Fix https://github.com/vllm-project/vllm/issues/41719.

Fix the incorrect-tokenizer-class fallback so it does not return a bare TokenizersBackend missing vLLM tokenizer properties such as max_chars_per_token.

The fallback now uses a cached TokenizersBackend loader, matching the normal HF tokenizer path.

Test Plan

from transformers import PretrainedConfig
import vllm.tokenizers.registry as registry
from vllm.renderers.params import TokenizeParams

registry.get_config = lambda *args, **kwargs: PretrainedConfig(model_type="step3_vl")

tok = registry.get_tokenizer("gpt2")
params = TokenizeParams(max_total_tokens=10, max_output_tokens=1)
print(type(tok))
print(tok.max_chars_per_token)
print(params._text_len_check(tok, "hello"))

Test Result

<img width="915" height="326" alt="image" src="https://github.com/user-attachments/assets/51fbd28f-b47b-4ca5-b342-62eb8fd5e0ae" />
<details> <summary> Essential Elements of an Effective PR Description Checklist </summary>
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
</details>

Changed files

  • tests/tokenizers_/test_registry.py (modified, +31/-0)
  • vllm/tokenizers/hf.py (modified, +30/-4)
  • vllm/tokenizers/registry.py (modified, +11/-7)

Code Example

Collecting environment information...
uv is set
==============================
        System Info
==============================
OS                           : Ubuntu 22.04.5 LTS (x86_64)
GCC version                  : (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
Clang version                : 14.0.0-1ubuntu1.1
CMake version                : version 3.22.1
Libc version                 : glibc-2.35

==============================
       PyTorch Info
==============================
PyTorch version              : 2.11.0+cu126
Is debug build               : False
CUDA used to build PyTorch   : 12.6
ROCM used to build PyTorch   : N/A
XPU used to build PyTorch    : N/A

==============================
      Python Environment
==============================
Python version               : 3.12.12 (main, Feb  3 2026, 22:51:04) [Clang 21.1.4 ] (64-bit runtime)
Python platform              : Linux-6.8.0-90-generic-x86_64-with-glibc2.35
    
==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : Could not collect
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : 
GPU 0: NVIDIA RTX 4000 SFF Ada Generation
GPU 1: NVIDIA RTX 4000 SFF Ada Generation

Nvidia driver version        : 560.35.03
cuDNN version                : Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.7
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        46 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               32
On-line CPU(s) list:                  0-31
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz
CPU family:                           6
Model:                                45
Thread(s) per core:                   2
Core(s) per socket:                   8
Socket(s):                            2
Stepping:                             7
CPU max MHz:                          3300.0000
CPU min MHz:                          1200.0000
BogoMIPS:                             5200.17
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid xsaveopt dtherm ida arat pln pts vnmi md_clear flush_l1d
Virtualization:                       VT-x
L1d cache:                            512 KiB (16 instances)
L1i cache:                            512 KiB (16 instances)
L2 cache:                             4 MiB (16 instances)
L3 cache:                             40 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
NUMA node1 CPU(s):                    1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Mitigation; PTE Inversion; VMX vulnerable
Vulnerability Mds:                    Vulnerable; SMT vulnerable
Vulnerability Meltdown:               Vulnerable
Vulnerability Mmio stale data:        Unknown: No mitigations
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Vulnerable
Vulnerability Spectre v1:             Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers
Vulnerability Spectre v2:             Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-eIBRS: Not affected; BHI: Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Vulnerability Vmscape:                Vulnerable

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.6.8.post1
[pip3] numpy==2.4.3
[pip3] nvidia-cublas-cu12==12.6.4.1
[pip3] nvidia-cuda-cupti-cu12==12.6.80
[pip3] nvidia-cuda-nvrtc-cu12==12.6.85
[pip3] nvidia-cuda-runtime-cu12==12.6.77
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.0.4
[pip3] nvidia-cufile-cu12==1.11.1.6
[pip3] nvidia-curand-cu12==10.3.7.77
[pip3] nvidia-cusolver-cu12==11.7.1.2
[pip3] nvidia-cusparse-cu12==12.5.4.2
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.2
[pip3] nvidia-cutlass-dsl-libs-base==4.4.2
[pip3] nvidia-ml-py==13.595.45
[pip3] nvidia-nccl-cu12==2.28.9
[pip3] nvidia-nvjitlink-cu12==12.6.85
[pip3] nvidia-nvshmem-cu12==3.4.5
[pip3] nvidia-nvtx-cu12==12.6.77
[pip3] pyzmq==27.1.0
[pip3] torch==2.11.0+cu126
[pip3] torch-c-dlpack-ext==0.1.5
[pip3] torchaudio==2.11.0+cu129
[pip3] torchvision==0.26.0+cu126
[pip3] transformers==5.7.0
[pip3] triton==3.6.0
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.1.dev16277+g6fe067d41 (git sha: 6fe067d41)
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled; XPU: Disabled
GPU Topology:
  	GPU0	GPU1	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	SYS	0,2,4,6,8,10	0		N/A
GPU1	SYS	 X 	1,3,5,7,9,11	1		N/A

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

==============================
     Environment Variables
==============================
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_yien-tsai

---

_MODEL_TYPES_WITH_INCORRECT_TOKENIZER_CLASS = {"step3_vl"}

---

from transformers import PretrainedConfig
import vllm.tokenizers.registry as registry
from vllm.renderers.params import TokenizeParams

registry.get_config = lambda *args, **kwargs: PretrainedConfig(model_type="step3_vl")

tok = registry.get_tokenizer("gpt2")

params = TokenizeParams(max_total_tokens=10, max_output_tokens=1)
print(params._text_len_check(tok, "hello"))

---

AttributeError: TokenizersBackend has no attribute max_chars_per_token
RAW_BUFFERClick to expand / collapse

Your current environment

<details> <summary>The output of <code>python collect_env.py</code></summary>
Collecting environment information...
uv is set
==============================
        System Info
==============================
OS                           : Ubuntu 22.04.5 LTS (x86_64)
GCC version                  : (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
Clang version                : 14.0.0-1ubuntu1.1
CMake version                : version 3.22.1
Libc version                 : glibc-2.35

==============================
       PyTorch Info
==============================
PyTorch version              : 2.11.0+cu126
Is debug build               : False
CUDA used to build PyTorch   : 12.6
ROCM used to build PyTorch   : N/A
XPU used to build PyTorch    : N/A

==============================
      Python Environment
==============================
Python version               : 3.12.12 (main, Feb  3 2026, 22:51:04) [Clang 21.1.4 ] (64-bit runtime)
Python platform              : Linux-6.8.0-90-generic-x86_64-with-glibc2.35
    
==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : Could not collect
CUDA_MODULE_LOADING set to   : 
GPU models and configuration : 
GPU 0: NVIDIA RTX 4000 SFF Ada Generation
GPU 1: NVIDIA RTX 4000 SFF Ada Generation

Nvidia driver version        : 560.35.03
cuDNN version                : Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.7
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.7
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                         x86_64
CPU op-mode(s):                       32-bit, 64-bit
Address sizes:                        46 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               32
On-line CPU(s) list:                  0-31
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz
CPU family:                           6
Model:                                45
Thread(s) per core:                   2
Core(s) per socket:                   8
Socket(s):                            2
Stepping:                             7
CPU max MHz:                          3300.0000
CPU min MHz:                          1200.0000
BogoMIPS:                             5200.17
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid xsaveopt dtherm ida arat pln pts vnmi md_clear flush_l1d
Virtualization:                       VT-x
L1d cache:                            512 KiB (16 instances)
L1i cache:                            512 KiB (16 instances)
L2 cache:                             4 MiB (16 instances)
L3 cache:                             40 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
NUMA node1 CPU(s):                    1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Mitigation; PTE Inversion; VMX vulnerable
Vulnerability Mds:                    Vulnerable; SMT vulnerable
Vulnerability Meltdown:               Vulnerable
Vulnerability Mmio stale data:        Unknown: No mitigations
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Not affected
Vulnerability Spec store bypass:      Vulnerable
Vulnerability Spectre v1:             Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers
Vulnerability Spectre v2:             Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-eIBRS: Not affected; BHI: Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected
Vulnerability Vmscape:                Vulnerable

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.6.8.post1
[pip3] numpy==2.4.3
[pip3] nvidia-cublas-cu12==12.6.4.1
[pip3] nvidia-cuda-cupti-cu12==12.6.80
[pip3] nvidia-cuda-nvrtc-cu12==12.6.85
[pip3] nvidia-cuda-runtime-cu12==12.6.77
[pip3] nvidia-cudnn-cu12==9.10.2.21
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft-cu12==11.3.0.4
[pip3] nvidia-cufile-cu12==1.11.1.6
[pip3] nvidia-curand-cu12==10.3.7.77
[pip3] nvidia-cusolver-cu12==11.7.1.2
[pip3] nvidia-cusparse-cu12==12.5.4.2
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cutlass-dsl==4.4.2
[pip3] nvidia-cutlass-dsl-libs-base==4.4.2
[pip3] nvidia-ml-py==13.595.45
[pip3] nvidia-nccl-cu12==2.28.9
[pip3] nvidia-nvjitlink-cu12==12.6.85
[pip3] nvidia-nvshmem-cu12==3.4.5
[pip3] nvidia-nvtx-cu12==12.6.77
[pip3] pyzmq==27.1.0
[pip3] torch==2.11.0+cu126
[pip3] torch-c-dlpack-ext==0.1.5
[pip3] torchaudio==2.11.0+cu129
[pip3] torchvision==0.26.0+cu126
[pip3] transformers==5.7.0
[pip3] triton==3.6.0
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : Could not collect
vLLM Version                 : 0.1.dev16277+g6fe067d41 (git sha: 6fe067d41)
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled; XPU: Disabled
GPU Topology:
  	GPU0	GPU1	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	SYS	0,2,4,6,8,10	0		N/A
GPU1	SYS	 X 	1,3,5,7,9,11	1		N/A

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

==============================
     Environment Variables
==============================
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_yien-tsai
</details>

🐛 Describe the bug

Summary

vLLM has a fallback for models with incorrect Hub tokenizer_class metadata:

_MODEL_TYPES_WITH_INCORRECT_TOKENIZER_CLASS = {"step3_vl"}

model_type="step3_vl" is used by stepfun-ai/step3.

This fallback returns a bare Transformers TokenizersBackend. Unlike the normal HF tokenizer path, it is not wrapped with get_cached_tokenizer(), so it misses vLLM-required properties such as max_chars_per_token.

Repro

from transformers import PretrainedConfig
import vllm.tokenizers.registry as registry
from vllm.renderers.params import TokenizeParams

registry.get_config = lambda *args, **kwargs: PretrainedConfig(model_type="step3_vl")

tok = registry.get_tokenizer("gpt2")

params = TokenizeParams(max_total_tokens=10, max_output_tokens=1)
print(params._text_len_check(tok, "hello"))

Actual

AttributeError: TokenizersBackend has no attribute max_chars_per_token

Expected

The fallback tokenizer should expose the same cached properties as normal HF tokenizers in vLLM.

Suggested Fix

Wrap the TokenizersBackend fallback with get_cached_tokenizer(), for example by adding a CachedTokenizersBackend loader.

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

extent analysis

TL;DR

The issue can be fixed by wrapping the TokenizersBackend fallback with get_cached_tokenizer() to expose the required properties like max_chars_per_token.

Guidance

  • Identify the fallback code in vllm.tokenizers.registry where TokenizersBackend is returned for models with incorrect tokenizer_class metadata.
  • Modify this fallback to wrap the TokenizersBackend instance with get_cached_tokenizer() to ensure it includes necessary properties.
  • Verify that the modified fallback correctly exposes properties like max_chars_per_token for the affected models.
  • Test the fix using the provided repro code to confirm that the AttributeError is resolved.

Example

# In vllm.tokenizers.registry
from vllm.tokenizers.utils import get_cached_tokenizer

# ...

def get_tokenizer(model_id):
    # ...
    if model_type in _MODEL_TYPES_WITH_INCORRECT_TOKENIZER_CLASS:
        # Wrap TokenizersBackend with get_cached_tokenizer
        return get_cached_tokenizer(TokenizersBackend(...))
    # ...

Notes

This fix assumes that get_cached_tokenizer() is correctly implemented to add the necessary properties to the tokenizer instance. If this is not the case, additional modifications may be required.

Recommendation

Apply the suggested fix by wrapping the TokenizersBackend fallback with get_cached_tokenizer() to ensure consistency with normal HF tokenizers in vLLM.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

vllm - ✅(Solved) Fix [Bug]: TokenizersBackend fallback returns tokenizer without `max_chars_per_token` [1 pull requests, 1 comments, 1 participants]