Skip to content

Qwen3.8-Flash-Next: transformers 5.16 drops \p{M} from the pre-tokenizer, so combining-mark text gets different ids #648

Open

Description

@gdevenyi

load_tokenizer (utils/hf.py) uses AutoTokenizer. With the pinned transformers 5.16.x, this checkpoint loads as Qwen2Tokenizer, which replaces the tokenizer.json pre-tokenizer with a split regex that lacks \p{M}. Text with combining marks then gets different ids than the model was trained on: नमस्ते दुनिया gives 10 ids instead of 6, and สวัสดีครับ gives 7 instead of 3. ASCII and precomposed Latin text are unaffected. It is the same on 5.15.1 and 5.17.0, and correct on 5.18.0+, which loads Qwen3_5Tokenizer.

from freetoken.utils.hf import load_tokenizer
from tokenizers import Tokenizer
p = "<local nvidia/Qwen3.8-Flash-Next-NVFP4 dir>"; t = "नमस्ते दुनिया"
print(len(load_tokenizer(p).encode(t, add_special_tokens=False)),
      len(Tokenizer.from_file(p + "/tokenizer.json").encode(t, add_special_tokens=False).ids))  # 10 6

Expected: ids match tokenizer.json. For example, raise the pin to >=5.18, or keep the file's pre-tokenizer in load_tokenizer.

Environment: main 07813248 (CPU-only check), transformers 5.16.1, Python 3.14.

Scope (transformers 5.16.1 Qwen2Tokenizer against tokenizer.json):

  • Identical:
    • emoji with variation selectors (⚠️, ✅, ❤️, ✔️, 1️⃣);
    • Latin with a combining accent (café), precomposed Latin, Japanese, Korean, Greek, Cyrillic;
    • all 770 text files of this repository (.py, .md, .json, .sh, .cu, ...);
    • the last 3,000 commit messages.
  • Different: scripts whose marks combine inside a word, e.g. Devanagari (नमस्ते) and Thai (สวัสดี).

ASCII and code-heavy traffic is unaffected. Indic and Southeast Asian text gets out-of-distribution ids.

Activity

  1. gdevenyi commented on Oct 13, 2026

    @gdevenyi
    ContributorAuthor

    Reproduced in the 1080 Ti deployment branch, rebuilt today on main 9c635a1 (torch 2.14.1+cu126, Triton 3.8, GTX 1080 Ti sm_61, Qwen3.8-Flash-Next-NVFP4 at 262K), which still resolves transformers 5.16.1: load_tokenizer returns Qwen2Tokenizer and gives 10 vs 6 ids for नमस्ते दुनिया and 7 vs 3 for สวัสดีครับ against tokenizer.json; café ✅ hello matches (4 vs 4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions