Repository navigation
fix(lora): identify SimpleTuner LyCORIS flat-key LoRAs - #10239
Open
Shanmukh-l33t wants to merge 1 commit into
Open
Shanmukh-l33t wants to merge 1 commit into
Shanmukh-l33t wants to merge 1 commit into
Conversation
SimpleTuner's LyCORIS output flattens each module name behind a lycoris_ prefix; no probe recognized it, so the files installed as unknown on every base. The names now resolve against each family's module list and convert through the existing per-family routes on FLUX.1, FLUX.2, SDXL, Z-Image and Wan; Wan's variant detection reads LoKR factor widths.
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
SimpleTuner's LyCORIS training writes LoRA/LoKR/LoHA layers named by flattening the model's own diffusers module
path with underscores behind a
lycoris_prefix (lycoris_single_transformer_blocks_0_attn_to_k.lokr_w1), orbehind
lycoris__. No probe recognized the layout, so the files installed asunknownon every base and forcingthe base failed in the converters (#10174's table). They now identify and convert on FLUX.1 (both spellings),
FLUX.2 Klein, SDXL, Z-Image and Wan, the way SD 3's own flat spelling already did.
lycoris_flat_lora_constantsresolves each flattened name against the family's module list (module namescontain underscores of their own, so only the whole list can unflatten them). A family is claimed on names only
it holds —
single_transformer_blocks.N.attn.to_qfor FLUX.1,to_qkv_mlp_proj/ff.linear_infor FLUX.2Klein, the UNet's deep
transformer_blocksfor SDXL,layers.N.attentionfor Z-Image,blocks.N.attn1forWan — with the width check that keeps Z-Image off Ideogram 4 and SDXL's block depth that keeps it off SD 1/2.
Names several families share without one only-this-family name identify nothing: SD 3's flat files stay SD 3
(locked in by
test_the_sd3_flat_layout_is_still_sd3), files of no family stay unknown.the diffusers-to-BFL mapping (fused QKV, swapped final modulation) unchanged, Wan through the kohya converter's
lora_unet_blocks_<idx>_<tail>names, SDXL through the SD converter's flattenedlora_unet_keys. A key thatnames no module of the claimed family raises instead of being dropped.
issue's 5120-wide Wan file records its variant.
Before → after on the issue's files (key layouts captured from their safetensors headers):
toxicwind/glassobject-lokr-fluxlycoris__)jimmycarter/flux-training-losercity-next-lycoris5gattaplayer/besch-flux2-klein-9b-lokr-lion-5e-6-bs2-ga2-v01davidrd123/Hiroshige-SDXL-LoKrUnrecognized SDXL LoRA key prefixwhen forced)noodlecake/Retro_Anime_Painting_lokr-R8-LR2-HIGHNOISEBIASuxoah/wan2.1_lokr_simpletunerRelated Issues / Discussions
Fixes #10174.
The issue's Qwen-Image row is covered by #10189 (its probe takes Qwen-Image's own module names as evidence), and
the SD 3 rows already worked. #10184 and #10189 touch adjacent converter and test files; this PR touches only
configs/lora.pyin common with them, in different functions.QA Instructions
Regression first:
tests/backend/model_manager/configs/test_lycoris_flat_lora_config.pyfails on unmodified mainshowing exactly the misdetection —
assert [] == ['LoRA_LyCORIS_FLUX_Config'](and the same for Flux2, SDXL,Z-Image, Wan) in
test_a_flat_lycoris_lora_is_claimed_by_its_family_alone[*]andtest_a_flat_lycoris_lora_records_its_base[*]: 12 failed, 2 passed (the two negative controls pass on main too).Checks run (CPU,
.venv/bin/python -m pytestin a freshuv sync --extra testenvironment):pytest -n 4 tests/backend/patches: 616 passed, 24 skipped.pytest -n 4 tests/backend/model_manager/configs: 1578 passed, 1 skipped, 13 failed — the 13 are all intest_model_path_validation.pyand fail identically on unmodified main in this environment (verified bystashing this branch's changes and re-running the file: the same 13 failures), unrelated to LoRA code.
pytest -n 4 tests/model_identification: 129 passed.pytest -n 4 tests/backend/model_manager/load tests/test_model_manager: 1301 passed, 127 skipped (the loadergained the new dispatch).
ruff checkandruff formaton every changed path: clean.Not run: the full test suite (large) and the frontend checks (no frontend changes).
The real-file evidence is at the key-layout level: the new fixtures are the six issue files' safetensors headers,
and every converted layer is resolved against the model it patches — Invoke's BFL FLUX class for FLUX.1, and
diffusers' own models (Flux2Transformer2DModel, ZImageTransformer2DModel, WanTransformer3DModel, and an SDXL UNet
with the released block structure) for the rest — with the FLUX.1 layers' weight deltas checked against the real
modules' shapes. Applying one through a live generation was not done (no GPU here).
Review
No material review findings; this is the initial version. Known limitations, in the same spirit as the existing
probes' documented ones:
transformer_blocks.N.attn.to_q, ...) carriesno only-this-family name and stays unidentified rather than being guessed at.
_state_dict_looks_like_sdxl_unet_loraalready documents.lycoris_…names are a different layout and remain unrecognized, as its family page says.Compatibility / Rollout
No migrations and no API or persisted-state changes. Identification runs at install, so a file already installed
as unknown keeps that record until it is reinstalled (Re-identify model in the Model Manager).
Checklist
What's Newcopy (if doing a release after this PR)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.