feat(qwen3): bundle Qwen3 tokenizer for offline single-file/GGUF encoders#9338
Open
Pfannkuchensack wants to merge 3 commits into
Open
feat(qwen3): bundle Qwen3 tokenizer for offline single-file/GGUF encoders#9338Pfannkuchensack wants to merge 3 commits into
Pfannkuchensack wants to merge 3 commits into
Conversation
…ders" -m "Single-file (safetensors) and GGUF Qwen3 encoder checkpoints used by Anima (0.6B) and Z-Image (4B/8B) ship weights only — no tokenizer files. The loader pulled the tokenizer from Qwen/Qwen3-4B on HuggingFace, which fails offline / airgapped and whenever the HF cache is not persisted (e.g. Docker without a cache volume). Vendor the self-contained Qwen3 fast tokenizer (Apache-2.0, from Qwen/Qwen3-4B) in the package and load it locally, mirroring the bundled T5-XXL tokenizer (invoke-ai#9244). The Qwen3 BPE tokenizer is identical across the 0.6B/4B/8B variants, so a single copy serves every Qwen3 encoder. Removes the HuggingFace download path from both the checkpoint and GGUF loaders.
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.
Summary
Single-file (safetensors) and GGUF Qwen3 encoder checkpoints used by Anima
(0.6B) and Z-Image (4B/8B) ship weights only — no tokenizer files. The loader
pulled the tokenizer from
Qwen/Qwen3-4Bon HuggingFace, which fails offline /airgapped and whenever the HF cache is not persisted (e.g. Docker without a
cache volume).
Vendor the self-contained Qwen3 fast tokenizer (Apache-2.0, from
Qwen/Qwen3-4B)in the package and load it locally, mirroring the bundled T5-XXL tokenizer
(#9244). The Qwen3 BPE tokenizer is identical across the 0.6B/4B/8B variants, so
a single copy serves every Qwen3 encoder. Removes the HuggingFace download path
from both the checkpoint and GGUF loaders.
Changes
invokeai/backend/qwen3/tokenizer/(tokenizer.json,tokenizer_config.json,special_tokens_map.json).load_bundled_qwen3_tokenizer()helper (invokeai/backend/qwen3/qwen3_tokenizer.py), mirroringanima/t5_tokenizer.py.Qwen3EncoderCheckpointLoaderandQwen3EncoderGGUFLoaderat the bundled tokenizer; drop the deadDEFAULT_TOKENIZER_SOURCEHF-download fallback.pyproject.tomlso they ship in the wheel.Related Issues / Discussions
Follows the same approach as #9244 (bundled T5-XXL tokenizer for Anima). No linked issue.
A follow-up will apply the same fix to the Qwen2.5-VL encoder (Qwen-Image / Qwen-Image-Edit), which has the identical single-file problem for its tokenizer, config, and image processor.
QA Instructions
Automated: run the new offline test — fully passes without network:
Manual (offline single-file encoder):
~/.cache/huggingface/hub/models--Qwen--Qwen3-4B.HF_HUB_OFFLINE=1)..safetensors) and run a generation.OSError/ HF download error.Regression: confirm a diffusers-folder Qwen3 encoder (with its own
tokenizer/) and the GGUF encoder still load and generate correctly.Merge Plan
Standard merge — no DB/schema changes. Note: adds ~11 MB of vendored tokenizer JSON to the package (same rationale/precedent as the bundled T5 tokenizer in #9244).
Checklist
What's Newcopy (if doing a release after this PR) — N/A