Skip to content

feat(anima): bundle T5-XXL tokenizer, remove t5_encoder_model input - #9244

Merged
lstein merged 4 commits into
invoke-ai:mainfrom
kappacommit:anima-bundled-t5-tokenizer
Jun 5, 2026
Merged

feat(anima): bundle T5-XXL tokenizer, remove t5_encoder_model input#9244
lstein merged 4 commits into
invoke-ai:mainfrom
kappacommit:anima-bundled-t5-tokenizer

Conversation

@kappacommit

Copy link
Copy Markdown
Contributor

Summary

Anima only needs the T5-XXL tokenizer (token IDs for the LLM Adapter embedding), not the ~9GB encoder weights. This PR stores the tokenizer itself in the repo and loads it locally. The tokenizer is Apache 2.0 license, so it is license compatible to store, and this is how both Comfy and Forge handle this as well (they both just store the tokenizer in the repo.)

Removes the t5_encoder_model input from the Anima model loader and strips all corresponding frontend state, selectors, metadata handlers, readiness checks, graph edges, i18n keys, and starter-model deps.

This saves about 9gb of space, and resolve much user confusion when they think the t5 encoder is being loaded into VRAM (it never was, but they were confused about it.)

Related Issues / Discussions

QA Instructions

  • Install Anima
  • Verify no T5 Encoder is downloaded
  • Select Anima is the canvas
  • Verify no T5 Encoder input on the UI
  • Generate an image successfully with Anima

Merge Plan

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

Anima only needs the T5-XXL tokenizer (token IDs for the LLM Adapter
embedding), not the ~9GB encoder weights. Vendor the self-contained
tokenizer.json inside the package and load it from a bundled path, so
users no longer have to download the full T5 encoder model.

Removes the t5_encoder_model input from the Anima model loader and
strips all corresponding frontend state, selectors, metadata handlers,
readiness checks, graph edges, i18n keys, and starter-model deps.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot added python PRs that change python files Root invocations PRs that change invocations backend PRs that change backend files frontend PRs that change frontend files python-tests PRs that change python tests python-deps PRs that change python dependencies labels May 28, 2026
…ma path slashes

The committed openapi.json was stale (still 1.3.0 with t5_encoder_model);
regenerate the Anima loader/text-encoder sections to match the 1.4.0 source.
Also correct two Windows backslash cache-path defaults in schema.ts to the
forward slashes the Linux typegen produces, so the openapi/typegen CI checks pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@lstein lstein self-assigned this May 30, 2026
@lstein lstein added the 6.13.5 Library Updates label May 30, 2026
@lstein lstein moved this to 6.13.5 LIBRARY UPDATES in Invoke - Community Roadmap May 30, 2026

@lstein lstein left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything checks out. Thank you for fixing this!

@lstein
lstein enabled auto-merge (squash) June 5, 2026 00:13
@lstein
lstein merged commit 3247696 into invoke-ai:main Jun 5, 2026
14 checks passed
dunkeroni pushed a commit to dunkeroni/InvokeAI that referenced this pull request Jun 29, 2026
…nvoke-ai#9244)

* feat(anima): bundle T5-XXL tokenizer, remove t5_encoder_model input

Anima only needs the T5-XXL tokenizer (token IDs for the LLM Adapter
embedding), not the ~9GB encoder weights. Vendor the self-contained
tokenizer.json inside the package and load it from a bundled path, so
users no longer have to download the full T5 encoder model.

Removes the t5_encoder_model input from the Anima model loader and
strips all corresponding frontend state, selectors, metadata handlers,
readiness checks, graph edges, i18n keys, and starter-model deps.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(anima): sync openapi.json with bundled-tokenizer loader; fix schema path slashes

The committed openapi.json was stale (still 1.3.0 with t5_encoder_model);
regenerate the Anima loader/text-encoder sections to match the 1.4.0 source.
Also correct two Windows backslash cache-path defaults in schema.ts to the
forward slashes the Linux typegen produces, so the openapi/typegen CI checks pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
lstein added a commit that referenced this pull request Jul 24, 2026
…ders (#9338)

* feat(qwen3): bundle Qwen3 tokenizer for offline single-file/GGUF encoders" -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
(#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.

* fix(qwen3): gzip bundled tokenizer to pass LFS check

The vendored Qwen3 tokenizer.json is ~11MB, over the repo's 10MB
lfs-warning threshold, failing the "lfs checks" CI job. Git LFS is
unsuitable here since the file must ship inside the wheel for offline
use. Vendor it gzip-compressed (~2MB) instead and decompress into a
temp dir at load time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(qwen3): fix stale tokenizer-loader comments and method name

The single-file/GGUF Qwen3 loaders now use the vendored tokenizer, but
the call-site comments still described the removed HuggingFace download
path and the method was still named _load_tokenizer_with_offline_fallback
despite having no fallback. Rename to _load_bundled_tokenizer and update
the comments to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(qwen3): restore chat_template in bundled tokenizer config

The vendored tokenizer_config.json was missing the chat_template that
Qwen/Qwen3-4B ships. The Z-Image text encoder formats prompts via
tokenizer.apply_chat_template(), which raises

    ValueError: Cannot use chat template functions because
    tokenizer.chat_template is not set ...

so GGUF/single-file Qwen3 encoders failed at encode time. The old
HF-download path pulled the full config (template included), so this
was a regression introduced by bundling. Restore the exact upstream
Qwen3-4B chat_template and add a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.13.5 Library Updates backend PRs that change backend files frontend PRs that change frontend files invocations PRs that change invocations python PRs that change python files python-deps PRs that change python dependencies python-tests PRs that change python tests Root

Projects

Status: 6.13.5 LIBRARY UPDATES

Development

Successfully merging this pull request may close these issues.

2 participants