Skip to content

Support loading AnyFlow embedder and weights as PEFT LoRA#7

Open
bghira wants to merge 1 commit into
NVlabs:mainfrom
bghira:feature/lora
Open

Support loading AnyFlow embedder and weights as PEFT LoRA#7
bghira wants to merge 1 commit into
NVlabs:mainfrom
bghira:feature/lora

Conversation

@bghira
Copy link
Copy Markdown

@bghira bghira commented May 27, 2026

Hello, thank you for the thorough source code release for AnyFlow. I've done work on several distillation methods that did not release their source code and this was a dream in comparison.

One thing that I noticed which really inhibits adoption of this is that the full transformer weights have to be downloaded; there's no extracted LoRA to use for inference post-hoc.

I put together a patched LoRA loader and extraction scripts to help downstream consumers address the gap here and make whatever size adapter is efficient for their use case. The LoRA contains the delta embedder weights, added manually, because the plain Wan 2.1 transformer didn't have them for the extraction script to naively pull the delta for.

If it's helpful, I can supply the extracted LoRA safetensors.

This code is all licensed Apache 2.0, the same as the rest of the repo. I didn't see any CLA required to sign for contributing, so I hope this is adequate.

python scripts/extract_anyflow_peft_lora.py \
  Wan-AI/Wan2.1-T2V-1.3B-Diffusers \
  nvidia/AnyFlow-Wan2.1-T2V-1.3B-Diffusers \
  ~/lora/wan/2.1/t2v/1.3b/anyflow-wan2.1-t2v-1.3b_all-linear_rank256_anyflow-sidecar.safetensors \
  --rank 256 \
  --alpha 256 \
  --device cuda \
  --dtype float16 \
  --target-modules all-linear \
  --anyflow-sidecar

@bghira
Copy link
Copy Markdown
Author

bghira commented May 27, 2026

the resulting LoRA weights and a small patch file for use in eg. Diffusers: https://huggingface.co/bghira/AnyFlow-Wan2.1-T2V-1.3B-LoRA

@guyuchao
Copy link
Copy Markdown
Collaborator

Thanks! I’ll review the PR this weekend. I’ll also release the official LoRA checkpoint if it would be helpful for users.

@bghira
Copy link
Copy Markdown
Author

bghira commented May 28, 2026

thanks yeah the lora approach is fundamentally sound for most end users especially continued training

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.

2 participants