convert : fix bytes_to_unicode import for transformers >= 5.15 - #26217
Merged
ggerganov merged 1 commit intoAug 4, 2026
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
SolshineCode
force-pushed
the
fix-bytes-to-unicode-import
branch
from
July 28, 2026 07:40
d0f3b93 to
aad3720
Compare
Contributor
Author
|
Rewrote the description and commit message per the guidelines. |
CISC
reviewed
Aug 3, 2026
CISC
left a comment
Member
There was a problem hiding this comment.
The rationale is flawed, it wasn't moved, it was simply removed in huggingface/transformers#40936 as the function was already copied to this location in huggingface/transformers#30334 (4.54.1), meaning it is safe for us to use it from there.
Please make the same fix in chatglm.py.
bytes_to_unicode was removed from transformers.models.gpt2.tokenization_gpt2 in huggingface/transformers#40936, but it had already been copied into transformers.convert_slow_tokenizer in huggingface/transformers#30334 (transformers 4.54.1), so import it directly from there. Applies the same fix to chatglm.py.
SolshineCode
force-pushed
the
fix-bytes-to-unicode-import
branch
from
August 4, 2026 00:26
aad3720 to
ef6113a
Compare
Contributor
Author
|
Thanks, you're right that it wasn't moved. It was removed in #40936 and had already been copied to convert_slow_tokenizer in #30334 (4.54.1). I've now corrected the commit message. I've also switched to importing directly from convert_slow_tokenizer, and applied the same fix to chatglm.py. |
CISC
approved these changes
Aug 4, 2026
smalinin
pushed a commit
to smalinin/llama.cpp
that referenced
this pull request
Aug 4, 2026
…rg#26217) bytes_to_unicode was removed from transformers.models.gpt2.tokenization_gpt2 in huggingface/transformers#40936, but it had already been copied into transformers.convert_slow_tokenizer in huggingface/transformers#30334 (transformers 4.54.1), so import it directly from there. Applies the same fix to chatglm.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
convert_hf_to_gguf.py fails with an ImportError on transformers >= 5.15 because bytes_to_unicode moved from transformers.models.gpt2.tokenization_gpt2 to transformers.convert_slow_tokenizer. Any model that goes through QwenModel.token_bytes_to_string hits it. This adds a try/except: old path first, new location as fallback, so both transformers ranges work.
Additional information
Hit while testing #26185 (the Kimi K3 tokenizer goes through this path). Verified on transformers 5.15.0.dev0: conversion completes and the resulting GGUF matched my HF reference outputs.
Requirements