fix: sdxl model invalid configuration after the hijack#12201
fix: sdxl model invalid configuration after the hijack#12201AUTOMATIC1111 merged 1 commit intoAUTOMATIC1111:devfrom
Conversation
|
This is not the solution because in addition to incorrect detection, this will fail to load weights properly. Maybe the right way to go is to change model.load_state_dict(state_dict, strict=False)
del state_dict
timer.record("apply weights to model")
if shared.opts.sd_checkpoint_cache > 0:
# cache newly loaded model
checkpoints_loaded[checkpoint_info] = model.state_dict().copy()to if shared.opts.sd_checkpoint_cache > 0:
# cache newly loaded model
checkpoints_loaded[checkpoint_info] = state_dict
model.load_state_dict(state_dict, strict=False)
del state_dict
timer.record("apply weights to model")ie store the state dict in the cache before it is applied to a model at all |
Yes, your solution is actually my first version, but I noticed that you submitted a new PR (#12227) that indirectly solves this problem. |
|
Right, well, I do not want to outright remove checkpoint cache yet because there is a scenario where it is still useful, like keeping 5 checkpoints in CPU RAM and 2 models loaded on GPU. That said checkpoint cache has a much bigger problem - it caches the currently loaded model too, so value like 1 does nothing useful and just eats RAM. |
Maybe we should only cache the checkpoint during the reload weights stage. This will save RAM. |
|
If you do not remove checkpoint_loaded, maybe I can commit following this change? |
|
Well that was my recommendation... I wanted you to test if it works well and commit it into the PR. |
Signed-off-by: AnyISalIn <anyisalin@gmail.com>
done, its works fine for me. |
fix: sdxl model invalid configuration after the hijack
Description
Currently, we are using the following code to inspect if the model is SDXL:
However, after hijack,
conditioner.embedders.1.model.ln_final.weightwill be changed toconditioner.embedders.1.wrapped.model.ln_final.weight. This will affect the choice of an invalid configuration for the SDXL model when shared.opts.sd_checkpoint_cache is enabled.Maybe we can solve this problem by preventing the addition of
wrapped?Screenshots/videos:
How to reproduce it.
When starting the webui, use the following command arguments:
--xformers --listen --ckpt=/stable-diffusion-webui/models/Stable-diffusion/sd_xl_base_1.0.safetensors --enable-insecure-extension-access --api --port 7860. Setsd_checkpoint_cacheto 3.Then, test it using the following scripts. It will switch to 0.9, switch back to 1.0, and then switch back to 0.9:
Here is the error output:
Checklist: