Skip to content

feat(anima): Make Anima respect the precision property in Invoke.yaml#9183

Merged
lstein merged 4 commits into
invoke-ai:mainfrom
kappacommit:anima-precision
May 17, 2026
Merged

feat(anima): Make Anima respect the precision property in Invoke.yaml#9183
lstein merged 4 commits into
invoke-ai:mainfrom
kappacommit:anima-precision

Conversation

@kappacommit
Copy link
Copy Markdown
Contributor

@kappacommit kappacommit commented May 15, 2026

Summary

Makes it so that Anima respects the precision property in invoke.yaml

Why?

Anima runs in bf16 precision. This is slow on 2000 series and earlier Nvidia GPUs, and on mac. Allowing the user to configure this, enables that hardware to run the model at adequate performance on those systems.

Why only Anima?

Today - Qwen and Z-Image do not respect the precision property. Which is fine, because neither Z-Image nor Qwen support fp16 at all (it produces broken output.) If we make Z-Image and Qwen respect precision, they will break if set to float16 and if set to float32 they will double their VRAM cost and realistically not be usable on consumer hardware. (Qwen will take >40gb of VRAM)

Anima, SD, and Flux 1 are the only models which safely and feasibly support all precisions. So it is natural to add Anima to the list.

I have documented an issue here for a more robust fix for all models by implementing a similar fix to how Forge and Comfy both handle this automatically. However, testing this is difficult. It requires testing on many different devices (2000 series nvidia gpu, mac): #9153

QA Instructions

  1. Generate an image with anima, you will use this as a reference for the other steps
  2. In invoke.yaml add precision: float32
  3. Generate the same image with anima (same seed / settings). You will notice 2 things: it should take up 2x the VRAM and likely run a bit slower. You will also notice very slight changes to the output image.
  4. In invoke.yaml add precision: float16
  5. Generate the same image with anima (same seed / settings). You will again notice very slight changes to the image. You likely won't notice much of a VRAM difference this time.

Merge Plan

Standard merge. Backend-only change isolated to Anima paths.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added (4 new unit tests in tests/backend/util/test_devices.py)
  • No redux slice migrations needed
  • No docs needed (internal helper)

🤖 Generated with Claude Code

Your Name and others added 2 commits May 14, 2026 23:38
…sion

When precision='auto', delegates to the existing choose_bfloat16_safe_dtype
probe. When set to a specific value (float16/bfloat16/float32), returns that
dtype directly so the user's config choice is honored. Anima call sites will
migrate to this helper in a follow-up commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Swaps choose_bfloat16_safe_dtype for choose_anima_inference_dtype at:
- _run_diffusion (transformer / latents / LoRA dtype)
- anima_text_encoder (text-encoder LoRA dtype)
- model_loaders/anima (transformer load dtype)

precision='auto' preserves the current bf16-probe fallback; specific values
are now honored end-to-end.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot added python PRs that change python files invocations PRs that change invocations backend PRs that change backend files python-tests PRs that change python tests labels May 15, 2026
@kappacommit kappacommit changed the title feat(anima): honor config.precision for Anima dtype selection feat(anima): Make Anima respect the precision property in Invoke.yaml May 15, 2026
@lstein lstein added the bug Something isn't working label May 16, 2026
Copy link
Copy Markdown
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

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

I'm seeing more dramatic differences than I expected, and want to double-check that these are within the acceptable range:

No precision in the config file:

Image

precision: float32:
Image

precision: float16:
Image

All were generated with the same prompt, settings and seed.

@lstein lstein self-assigned this May 16, 2026
@lstein lstein added the v6.13.x label May 16, 2026
@lstein lstein moved this to 6.13.x Theme: MODELS in Invoke - Community Roadmap May 16, 2026
@kappacommit
Copy link
Copy Markdown
Contributor Author

I'm seeing more dramatic differences than I expected, and want to double-check that these are within the acceptable range:
All were generated with the same prompt, settings and seed.

I did another pass to confirm things and it seems this is just an expected quirk of the model. I do also get noticeable differences when switching between them.

There isn't really anything special happening in the code, we just pass the config file value directly to torch and that's it. This is just a configuration option for hardware that can barely run the model otherwise, so they'll likely be happy to make this trade-off.

Copy link
Copy Markdown
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

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

Change in appearance of model confirmed not-a-bug by the author.
Approved

@lstein lstein merged commit 61d1eaa into invoke-ai:main May 17, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files bug Something isn't working invocations PRs that change invocations python PRs that change python files python-tests PRs that change python tests v6.13.x

Projects

Status: 6.13.x Theme: MODELS

Development

Successfully merging this pull request may close these issues.

3 participants