Skip to content

fix(qwen-image): identify LyCORIS LoRA layouts and group dotted LoKr and LoHa keys - #10189

Merged
Pfannkuchensack merged 5 commits into
invoke-ai:mainfrom
Pfannkuchensack:fix/qwen-image-lycoris-layouts
Nov 12, 2026
Merged

Pfannkuchensack merged 5 commits into
invoke-ai:mainfrom
Pfannkuchensack:fix/qwen-image-lycoris-layouts

Conversation

@Pfannkuchensack

@Pfannkuchensack Pfannkuchensack commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Real Qwen-Image LyCORIS files did not work:

  • lycoris_transformer_blocks_… (LoKr, 43 files in 6 Hugging Face repos) installed as an unknown model.
  • lora_transformer_transformer_blocks_… (ai-toolkit LoHa) installed as a FLUX LoRA.
  • LoKr with dotted keys failed to load with Unsupported lora format, because grouping cut inside the module path.
  • LoHa and factorized LoKr in the plain and Kohya layouts were not identified.

Now:

  • Both prefixes are recognized, and the conversion handles them. They count only with a key on a Qwen-only module (img_mod, txt_mod, img_mlp, txt_mlp), so FLUX files with the same spelling stay FLUX.
  • flux_format_from_state_dict no longer claims a file with such a module.
  • Dotted LoKr and LoHa keys group by module path.
  • A learned LyCORIS scalar is applied. It is folded into the layer before key normalization, for LoKr, LoHa and plain LoRA.

Related Issues / Discussions

Closes #10020

#10184 touches the same converter, constants, test file and qwen-image.mdx. The two do not depend on each other, but whichever lands second needs a rebase.

QA Instructions

Checks run:

  • uv run --no-sync pytest -n 4 tests/backend/patches tests/backend/model_manager/configs tests/model_identification: 1949 passed, 25 skipped (CPU).
  • Ruff check and format: passed.

Real files:

  • Two real lycoris_transformer_blocks_ LoKr files identify as Qwen-Image and convert to 720 layers.
  • One of them (mikaelh's Minecraft LoKr) installed and generated through the server on an RTX 4090. At a fixed seed, weight 1 against weight 0 gives 12.93 dB PSNR, so it takes effect.
  • FLUX LoHa fixtures still identify as FLUX.

To reproduce: install a Qwen-Image LoKr whose keys start with lycoris_transformer_blocks_. It should install as Qwen-Image and change the image at weight 1.

Not run:

  • Family E2E for Qwen-Image.
  • Linux and ROCm. The change has no platform-specific code.

Review

Resolved during review:

  • The first version of the new suffix rule claimed FLUX LoHa files for Qwen-Image. New prefixes and LyCORIS-only suffixes now need a key on a Qwen-only module, and base suffixes behave as before.
  • scalar was only handled for LoKr and LoHa; it now also applies to plain LoRA layers.
  • LoHa and LoKr files that carry dora_scale, such as ThatDustyGuy/QwenImage-PersonalLoRA, were identified as Qwen-Image but failed at generation with KeyError: 'lora_up.weight'. With fix(lora): handle DoRA magnitudes on LoKr and LoHa layers #10075 merged into this branch, the shared layer factory applies them as plain LoHa and LoKr without the magnitudes. The conversion tests now keep dora_scale in the ai-toolkit LoHa header and cover dotted LoHa and LoKr with it; with DoRA dispatched first again, all three fail. The family page says the magnitudes are skipped.

Remaining limitations:

  • A file in these layouts that trains only attention layers cannot be told apart from other families: a lycoris_ file stays unknown, and a lora_transformer_transformer_blocks_ file stays FLUX.

Compatibility / Rollout

No migration. Identification only runs at install, so a file already installed as FLUX or unknown keeps that record until it is reinstalled.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Meaningful regression coverage added / updated where needed; obsolete tests/code removed
  • Persisted-state and API changes include required migrations / compatibility validation
  • Relevant performance/efficiency opportunities considered; material claims have evidence
  • Material review findings resolved and relevant checks rerun
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…and LoHa keys

Recognize lycoris_transformer_blocks_ and lora_transformer_transformer_blocks_ files by Qwen-only modules, and stop FLUX claiming them.
Group dotted LoKr and LoHa keys by module path and apply LyCORIS scalars.

Closes invoke-ai#10020
@github-actions github-actions Bot added python PRs that change python files backend PRs that change backend files python-tests PRs that change python tests docs PRs that change docs labels Nov 7, 2026
…ris-layouts

# Conflicts:
#	invokeai/backend/model_manager/configs/lora.py
…ris-layouts

# Conflicts:
#	docs/src/content/docs/Users Guide/03.Models/Local Models/qwen-image.mdx
#	invokeai/backend/patches/lora_conversions/qwen_image_lora_constants.py
#	invokeai/backend/patches/lora_conversions/qwen_image_lora_conversion_utils.py
#	tests/backend/patches/lora_conversions/test_qwen_image_lora_conversion_utils.py
@lstein lstein added the 7.0.1 label Nov 8, 2026
@lstein lstein moved this to 7.0.1: bugfixes and small features in Invoke - Community Roadmap Nov 8, 2026
@lstein lstein added 7.0.0 and removed 7.0.1 labels Nov 9, 2026
@Pfannkuchensack
Pfannkuchensack added this pull request to the merge queue Nov 12, 2026
Merged via the queue into invoke-ai:main with commit 2674a40 Nov 12, 2026
21 checks passed
@Pfannkuchensack
Pfannkuchensack deleted the fix/qwen-image-lycoris-layouts branch November 12, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.0.0 backend PRs that change backend files docs PRs that change docs python PRs that change python files python-tests PRs that change python tests

Projects

Status: 7.0.1: bugfixes and small features

Development

Successfully merging this pull request may close these issues.

[bug]: Qwen-Image LoKr with dotted keys fails to load; LoHa and factorized-w1 LoKr are not identified

3 participants