This repository was archived by the owner on Oct 4, 2026. It is now read-only.
feat(anima): support Anima-2.9B and Anima-3.8B finetunes - #394
Closed
Pfannkuchensack wants to merge 1 commit into
Closed
Pfannkuchensack wants to merge 1 commit into
Pfannkuchensack wants to merge 1 commit into
Conversation
- Read the DiT depth from the checkpoint instead of hard-coding 28 blocks (Anima-2.9B silently lost 12 of 40 blocks); load int8_tensorwise builds - Anima-3.8B v1.1: AnimaVariantType, bundled semantic connector recomputed per denoise step, new Qwen3.5 encoder model type with vendored tokenizer - Migration 2026_10_01_add_anima_variant for installed Anima records - webv2: Qwen3.5 encoder slot and graph wiring for the anima_qwen35 variant - Starter models, user guide, and integration guide section on extending an existing architecture; package-data guard test
Pfannkuchensack
requested review from
JPPhoto,
blessedcoolant and
lstein
as code owners
October 1, 2026 22:56
Member
Author
|
Opened against the wrong repository. Moved to invoke-ai#9639 (stacked on invoke-ai#9613). |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Two community finetunes of Anima now install and generate correctly: Anima-2.9B and Anima-3.8B.
Anima-2.9B (40 DiT blocks instead of 28) already installed as Anima, but the loader built the transformer from a hard-coded 28-block config and loaded with
strict=False. It filled the first 28 blocks and dropped the other 12 (240 tensors) as unexpected keys, logged at DEBUG only. The result was a degraded image and no error. The loader now reads the depth from the checkpoint and refuses gaps. The int8_tensorwise build from the same repo loads too, throughinstall_int8_convrot_layers.Anima-3.8B v1.1 (52 blocks) bundles a "semantic connector" into its checkpoint that reads a second text encoder, Qwen3.5 4B. The connector is timestep-aware, so its context changes at every step. Until now the checkpoint installed as Anima, loaded 28 blocks and dropped the connector. Now:
AnimaVariantType(anima_qwen3,anima_qwen35), detected from the bundledanima_v2_connector.*keysModelType.Qwen35Encoder(qwen3_5_encoder): single-file config and loader built on thetransformersqwen3_5decoder layers, with the tokenizer vendored fromQwen/Qwen3.5-4B@851bf6e(Apache-2.0). The encoder checkpoint is not a stock export: it ships layer 31 without its MLP, and the encoder reproduces that exactly.invokeai/backend/anima/semantic_connector.py), whose module names match the checkpointanima_qwen35variant, plus graph, regional guidance and recall wiringInvalidMatchErrorthat names v1.1Also included:
new-model-integration.mdx, from the gaps this change hit:Related Issues / Discussions
upstream-merge(Version 7.0 Alpha Upgrade InvokeAI#9613).anima_text_encoder.pyand the conditioning it stores; whichever lands second needs a small merge.QA Instructions
Automated
uv run pytest -n 8 tests/backend/model_manager tests/backend/architectures tests/backend/anima tests/backend/qwen3_5 tests/backend/util tests/backend/patches tests/app/invocations tests/app/services/shared tests/app/services/model_records tests/test_package_data.py: 6254 passed, 1 failed. The failure,test_16_channel_vae_loader.py::test_an_ldm_layout_file_is_converted_and_loses_no_tensor, reads an LFS fixture that was not pulled in the test worktree; it is unrelated.ruff check .andruff format --check .: clean.lint:tsc,lint:oxc,format:checkandarchitecture:checkpass. Vitest oversrc/features/generation,src/workbench,src/features/modelsandsrc/features/workflow: 7277 passed, 2 failed. Both failures are in image-map (clusterStats,indexProgress) and come from German-locale digit grouping on the test machine; unrelated.openapi.json/schema.ts, the capabilities fixture, and the graph-coverage snapshot. The docs build passes, andcheck-docs-datashows no diff.Numerical checks against the reference implementation, on the real weights
End to end: RTX 4090, fresh root, models installed in place through the API, 832×1216, 30 steps, Euler, seed 1234.
Speed, single runs only (not a benchmark): ~1.7 it/s for 2.9B against ~1.3 it/s for 3.8B, which also runs the connector every step.
Browser (built webv2 against the same server):
qwen3_5_encoder.The migration is unit-tested against an in-memory
modelstable and ran on a fresh database. It has not been run against a populated production database.Review
Remaining risks and limitations:
time_mlp,time_modulation) in bf16, by analogy witht_embedder. This is not measured, and no fp8 quality comparison was run on either finetune.res_multistepand a beta schedule, which Anima's scheduler set does not offer.Compatibility / Rollout
2026_10_01_add_anima_variant(depends on2026_09_26_add_workflow_revision):variantis now a required field on Anima main records. Without the migration, every installed Anima model would fail validation on read and vanish from the model list. The migration reads each checkpoint's header, so a 3.8B installed on an earlier v7 build becomesanima_qwen35. A record whose file cannot be read getsanima_qwen3.qwen3_5_encoder, variantsanima_qwen3,anima_qwen35andqwen3_5_4b.anima_model_loader1.5.0 andanima_text_encoder1.5.0. The new inputs and outputs are optional, so existing workflows keep validating.invokeai.backend.qwen3_5is added topackage-data. A newtests/test_package_data.pychecks that every vendored*.json/*.json.gzunderinvokeai/backendships in the wheel.Checklist
What's Newcopy (if doing a release after this PR)