Skip to content

Support diffusers-format LoRAs for Anima - #14182

Open
dxqb wants to merge 1 commit into
Comfy-Org:masterfrom
dxqb:anima-diffusers-lora
Open

Support diffusers-format LoRAs for Anima#14182
dxqb wants to merge 1 commit into
Comfy-Org:masterfrom
dxqb:anima-diffusers-lora

Conversation

@dxqb

@dxqb dxqb commented May 30, 2026

Copy link
Copy Markdown
Contributor

diffusers have recently merged their Anima PR: huggingface/diffusers#13732

This PR adds support for diffusers LoRAs with their keys. The template for this was the existing diffusers-LoRA support for Z-Image.
It was created with AI assistance, but manually checked.

Tested with a trained diffusers LoRA: all keys load with no unmatched keys, and it
applies correctly end-to-end on anima-preview3-base.

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: da060e0c-994c-4816-8ef0-8cfee3e6edbf

📥 Commits

Reviewing files that changed from the base of the PR and between 0b04660 and 9813175.

📒 Files selected for processing (2)
  • comfy/lora.py
  • comfy/utils.py

📝 Walkthrough

Walkthrough

This PR adds support for LoRA weight mapping on Anima models (MMDiT-based architectures). A new utility function anima_to_diffusers transforms transformer block attention projections and feed-forward weights from MMDiT config format to diffusers parameter names. The LoRA key mapping in model_lora_keys_unet detects Anima models and uses this utility to generate key mappings in multiple formats: diffusion_model, transformer, lycoris (with dot-to-underscore conversion), and raw k-suffix forms.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Support diffusers-format LoRAs for Anima' directly matches the PR's main objective: adding support for diffusers-format LoRAs in Anima models.
Description check ✅ Passed The description clearly explains the changes: adding support for diffusers LoRAs for Anima by implementing key mappings, following the existing diffusers-LoRA pattern for Z-Image.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@comfyanonymous

Copy link
Copy Markdown
Member

Anima already has a standard lora format, I don't see any reason to support another.

@dxqb

dxqb commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Anima already has a standard lora format, I don't see any reason to support another.

The best answer I can give you is: consistency.

Diffusers keeps using their own layer names, and so far Comfy has supported them for all models. Please have a look at the code before making a decision - it's the same code as for z image and other models.

I can't argue that it is a great idea that diffusers changes layer names for their implementations - but they do. And supporting their keys for some models but not for others creates difficulties for the community.

@dxqb

dxqb commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

could you decide this please?
if you're not going to merge this, feel free to close. But a statement how you are making these decisions would be useful if you could - it confuses me currently. For one model yes, for the next model (potentially) no.

@comfyanonymous

Copy link
Copy Markdown
Member

Decision is mainly along these lines:

  1. How much effort is it to support?
  2. Are there any existing loras in this format?

In this case you did the work so it wouldn't take much effort to support but I don't see any public loras in this format so I'll keep this open until I do.

@turbo-boo

turbo-boo commented Jun 16, 2026

Copy link
Copy Markdown

I have trained some loras but since comfy does not supports it so I can't publish it. Can you add support?

@FuouM

FuouM commented Jun 16, 2026

Copy link
Copy Markdown

I created a simple patch custom node for Anima support based on this PR. Simply install and either types of LoRA will work in ComfyUI. Check it out here:

https://github.com/FuouM/ComfyUI-Anima-Diffusers-LoRA

@rabidcopy

rabidcopy commented Jun 20, 2026

Copy link
Copy Markdown

For what it's worth, this won't cover loading Anima LoKr/LoHas trained with OneTrainer. (LoKr which I've had good results with so far!) Have been converting them with these. Both end up loading and functioning the same and as expected.
test_lora_conversion_universal.py
test_lora_conversion_native.py

Disregard. My apologies. I didn't properly confirm things. Got mixed up when switching OS. AFAIK the LoKrs and LoHas were being handled by this PR and above custom node.

@FuouM

FuouM commented Jun 21, 2026

Copy link
Copy Markdown

Have been converting them with these. Both end up loading and functioning the same and as expected.

I have added LoKr and LoHa support to the custom node in the latest commit. I don't have real LoKr and LoHa created by OneTrainer on hand so I can't fully verify, but my OFTv2 worked as usual. Thanks!

@dxqb

dxqb commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Because of inconsistent support by inference tools and lack of standardization, OneTrainer now implements saving various LoRA formats (diffuser-, kohya, and comfy formats).

I'll therefore stop submitting PRs such as this one, that add loading diffusers LoRAs into comfy, because people can just save in another format.
I still think it's a problem for the community at large. Here is the entire mess that we've created: Nerogar/OneTrainer#1563 (scroll down to table "Standard LoRA")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants