lllyasviel / lllyasviel/stable-diffusion-webui-forge

[Bug]: Checking for unmatched keys when loading Lora is not a versioning system.

Open
#838 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Checklist

- [x] The issue exists after disabling all extensions
- [x] The issue exists on a clean installation of webui
- [ ] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [x] The issue exists in the current version of the webui
- [x] The issue has not been reported before recently
- [ ] The issue has been reported before but has not been fixed yet

### What happened?

Some Lora will not load under an erroneous "version mismatch" error because they contain too many unmatched keys (due to https://github.com/lllyasviel/stable-diffusion-webui-forge/blob/bfee03d8d9415a925616f40ede030fe7a51cbcfd/ldm_patched/modules/sd.py#L69-L71). While this can prevent Lora from loading that were trained under newer methods that might not have been entirely implemented yet, the count of "unmatched keys" is arbitrary and does not match the reality that, despite not aligning 100% to what has been already implemented, Lora models often work to a lesser but usable degree even if every key has not been implemented. This code is, despite documentation commentary in the referenced file, neither reference only nor taken wholesale from the originating repo, and this blocking check is unique to forge. While it is understandable that version checking can prevent issues with incompatibility, models such as [4th Tail](https://civitai.com/models/312010?modelVersionId=479673) that are perfectly usable despite these missing keys are blocked by this check.

### Steps to reproduce the problem

For the example Lora listed above,
1. Load Forge with a PonyXL-based model or mix.
2. Place the 4th Tail Lora in the model prompt
3. Hit Generate

### What should have happened?

The 4th Tail Lora should apply usable weights to the running PonyXL-based model

### What browsers do you use to access the UI ?

Mozilla Firefox

### Sysinfo

N/A

### Console logs

```Shell
To create a public link, set `share=True` in `launch()`.
IIB Database file has been successfully backed up to the backup folder.
Startup time: 15.9s (prepare environment: 2.1s, import torch: 3.6s, import gradio: 0.5s, setup paths: 0.6s, other imports: 0.3s, list SD models: 0.3s, load scripts: 2.8s, scripts before_ui_callback: 1.3s, create ui: 3.6s, gradio launch: 0.2s, app_started_callback: 0.5s).
X/Y/Z plot will create 2 images on 1 1x2 grid. (Total steps to process: 40)
[LORA] LoRA version mismatch for SDXL: ###/Lora/4th_tail_v0.4.0_lyco_extract_l.safetensors
```

### Additional information

_No response_

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ldm_patched/modules/sd.py around lines 69-71, where the unmatched-key check produces the LoRA version-mismatch error. Reproduce with the 4th Tail LoRA on a PonyXL-based model and trace the loading path; done means usable weights are applied instead of being blocked solely by the unmatched-key count.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.