feat(model-manager): identify UNet-only SDXL LoRAs (e.g. slider LoRAs)#9383
Open
Pfannkuchensack wants to merge 1 commit into
Open
feat(model-manager): identify UNet-only SDXL LoRAs (e.g. slider LoRAs)#9383Pfannkuchensack wants to merge 1 commit into
Pfannkuchensack wants to merge 1 commit into
Conversation
Self-attention-only SDXL LoRAs (e.g. Civitai "slider" LoRAs) patch only the UNet and contain no cross-attention (attn2) or text-encoder (lora_te*) keys. lora_token_vector_length() reads the base's context dimension from exactly those keys, so it returns None for such LoRAs and identification fails with "unrecognized token vector length None". Add a structural fallback: SDXL's UNet has a deep transformer stack (up to 10 transformer blocks) in its lower-resolution attention blocks, so transformer_blocks indices reach >= 2, whereas SD1.x/SD2.x only ever have a single transformer block (index 0) per attention. _state_dict_looks_like_sdxl_unet_lora() detects SDXL from that structure alone. The regex is anchored on the UNet down/up/mid-block + attentions grouping so it won't false-positive on DiT LoRAs (FLUX/Qwen/Z-Image) that also use transformer_blocks. The fallback only runs after the normal token-vector detection returns None, so existing LoRAs are unaffected. Wired into both the LyCORIS and Diffusers base configs.
Pfannkuchensack
requested review from
JPPhoto,
blessedcoolant,
dunkeroni and
lstein
as code owners
July 25, 2026 02:00
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
Self-attention-only SDXL LoRAs (e.g. Civitai "slider" LoRAs) patch only the UNet and contain no cross-attention (
attn2) or text-encoder (lora_te*) keys.lora_token_vector_length()reads the base's context dimension from exactly those keys, so it returnsNonefor such LoRAs and identification fails with "unrecognized token vector length None".Add a structural fallback: SDXL's UNet has a deep transformer stack (up to 10 transformer blocks) in its lower-resolution attention blocks, so
transformer_blocksindices reach >= 2, whereas SD1.x/SD2.x only ever have a single transformer block (index 0) per attention._state_dict_looks_like_sdxl_unet_lora()detects SDXL from that structure alone. The regex is anchored on the UNet down/up/mid-block +attentionsgrouping so it won't false-positive on DiT LoRAs (FLUX/Qwen/Z-Image) that also usetransformer_blocks.The fallback only runs after the normal token-vector detection returns
None, so existing LoRAs are unaffected. Wired into both the LyCORIS and Diffusers base configs.Related Issues / Discussions
Closes #7709
QA Instructions
lora_unet_..._attn1_...(noattn2/lora_te*), e.g. Dramatic Lighting Slider.main, installing/scanning it fails to identify with "unrecognized token vector length None".Automated coverage:
tests/backend/model_manager/configs/test_sdxl_slider_lora_identification.py— unit tests for the structural heuristic (positive: self-attention-only slider + diffusers dot-format; negative: SD1.5 shallow stack, Qwen, FLUX, empty/non-string keys) plus end-to-end identification through the LyCORIS configs (SDXL matches, SD1/SD2 reject).uv run --extra cuda --extra test python -m pytest tests/backend/model_manager/configs/ tests/backend/patches/lora_conversions/ --no-cov -qMerge Plan
Standard merge — no DB schema or redux changes.
Checklist
What's Newcopy (if doing a release after this PR)