Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merger does not work anymore #415

Open
kalle07 opened this issue Oct 27, 2024 · 20 comments
Open

merger does not work anymore #415

kalle07 opened this issue Oct 27, 2024 · 20 comments

Comments

@kalle07
Copy link

kalle07 commented Oct 27, 2024

if i press the red button merge, nothing happend , no error on CMD
(works until last month)

and if i press save fp16 (grey button)

Traceback (most recent call last):
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\queueing.py", line 536, in process_events
response = await route_utils.call_process_api(
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\route_utils.py", line 285, in call_process_api
output = await app.get_blocks().process_api(
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\blocks.py", line 1923, in process_api
result = await self.call_function(
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\blocks.py", line 1508, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
File "e:\WebUI_Forge\system\python\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "e:\WebUI_Forge\system\python\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "e:\WebUI_Forge\system\python\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\utils.py", line 818, in wrapper
response = f(*args, **kwargs)
File "E:\WebUI_Forge\webui\extensions\sd-webui-supermerger\scripts\supermerger.py", line 573, in save_current_merge
msg = savemodel(None,None,custom_name,save_settings)
File "E:\WebUI_Forge\webui\extensions\sd-webui-supermerger\scripts\mergers\model_util.py", line 61, in savemodel
for name,module in shared.sd_model.named_modules():
AttributeError: 'StableDiffusionXL' object has no attribute 'named_modules'

@emersound
Copy link

yup me too.

File "G:\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
output = await app.get_blocks().process_api(
File "G:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
result = await self.call_function(
File "G:\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
prediction = await anyio.to_thread.run_sync(
File "G:\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "G:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "G:\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "G:\stable-diffusion-webui\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
response = f(*args, **kwargs)
File "G:\stable-diffusion-webui\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 776, in pluslora
theta_0 = newpluslora(theta_0,filenames,lweis,names, isxl,isv2, keychanger)
File "G:\stable-diffusion-webui\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 853, in newpluslora
import scripts.A1111.networks as nets
ModuleNotFoundError: No module named 'scripts.A1111'

Same issue. not sure what changed. it just started doing this one day.

@duskfallcrew
Copy link

UGH wtf lol -- that's the same exact one i got, i can deal with the diffusers one but .. bleh this is gonna kill me XD

@duskfallcrew
Copy link

duskfallcrew commented Oct 31, 2024

I'mma see if a temporary fix works by using the older plus lora: https://github.com/hako-mikan/sd-webui-supermerger/blob/ver20/scripts/mergers/pluslora.py

It's an issue in that file directly, and it's becuse they're working on FORGE and i'm not using forge yet.. because i'm lazy.

Edit:
If you use the pluslora.py from the above, restart your instance it actually as far as I can see -works, i didn't Cuda after i restarted. So yea, just literally replace the pluslora.py with the older one and it works.

@JayarCurio
Copy link

Still not working for me, with the alternate loraplus.py
I tested on forge and master webui and diffusers 0.25.0 and 0.31.0, and it's all the same.

Traceback (most recent call last):
File "D:\stable-diffusion-webui-master\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 426, in lmerge
sd = merge_lora_models(ln, lr, settings, False, calc_precision)
File "D:\stable-diffusion-webui-master\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 483, in merge_lora_models
ratio = ratios[blockfromkey(key, keylist, isv2)]
IndexError: list index out of range

@springheeledjack66
Copy link

I have a issue where it manages to generate a model using the basic method but it couldn't generate anything and kept stating clip issues

@duskfallcrew
Copy link

Look i used Web UI 1.8 or something - not forge, - and i was on a vast instance, it did throw key errors but if anything i don't know how to fix it beyond that at the moment. The main issue i had was the scripts.a1111 module that doesn't even exists

@emersound
Copy link

I'mma see if a temporary fix works by using the older plus lora: https://github.com/hako-mikan/sd-webui-supermerger/blob/ver20/scripts/mergers/pluslora.py

It's an issue in that file directly, and it's becuse they're working on FORGE and i'm not using forge yet.. because i'm lazy.

Edit: If you use the pluslora.py from the above, restart your instance it actually as far as I can see -works, i didn't Cuda after i restarted. So yea, just literally replace the pluslora.py with the older one and it works.

I tried that and it didn't work for me

@duskfallcrew
Copy link

duskfallcrew commented Nov 11, 2024 via email

@kwikmn
Copy link

kwikmn commented Nov 11, 2024

With the help of gpt o1 preview, which is the best model for coding and general reasoning tasks, I was able to fix the issue. I take no credit. Here is the solution.

I downloaded the v20 pluslora.py file, and here are the changes suggested:

What's Happening:

Function Call: The function blockfromkey(key, keylist, isv2) is called with parameters key, keylist, and isv2.
Index Retrieval: The result of this function call is used as an index to access the ratios list.
Error Trigger: The index returned is out of the valid range for the ratios list, leading to the IndexError.
Root Cause Analysis
Upon examining your pluslora.py file, the issue stems from the mismatch between the length of the LBLCOKS26 list and the ratios list. Here's a detailed breakdown:

Definition of LBLCOKS26:

LBLCOKS26 = [
"encoder",
"diffusion_model_input_blocks_0_",
"diffusion_model_input_blocks_1_",
"diffusion_model_input_blocks_2_",
"diffusion_model_input_blocks_3_",
"diffusion_model_input_blocks_4_",
"diffusion_model_input_blocks_5_",
"diffusion_model_input_blocks_6_",
"diffusion_model_input_blocks_7_",
"diffusion_model_input_blocks_8_",
"diffusion_model_input_blocks_9_",
"diffusion_model_input_blocks_10_",
"diffusion_model_input_blocks_11_",
"diffusion_model_middle_block_",
"diffusion_model_output_blocks_0_",
"diffusion_model_output_blocks_1_",
"diffusion_model_output_blocks_2_",
"diffusion_model_output_blocks_3_",
"diffusion_model_output_blocks_4_",
"diffusion_model_output_blocks_5_",
"diffusion_model_output_blocks_6_",
"diffusion_model_output_blocks_7_",
"diffusion_model_output_blocks_8_",
"diffusion_model_output_blocks_9_",
"diffusion_model_output_blocks_10_",
"diffusion_model_output_blocks_11_",
"embedders",
"transformer_resblocks"
]
Item Count: 28 items.
Definition of BLOCKID26:

BLOCKID26 = [
"BASE", "IN00", "IN01", "IN02", "IN03", "IN04", "IN05",
"IN06", "IN07", "IN08", "IN09", "IN10", "IN11",
"M00", "OUT00", "OUT01", "OUT02", "OUT03", "OUT04",
"OUT05", "OUT06", "OUT07", "OUT08", "OUT09", "OUT10", "OUT11"
]
Item Count: 26 items.
Mismatch Explanation:

The LBLCOKS26 list contains 28 items, whereas the ratios list you provided contains 26 elements.
When blockfromkey processes keys that map to the last two items ("embedders" and "transformer_resblocks"), it attempts to access ratios[26] or ratios[27], which are out of range since Python lists are zero-indexed and your ratios list only goes up to ratios[25].
Solution
To resolve this IndexError, you need to ensure that the LBLCOKS26 list and the ratios list are aligned in length. Here's how you can do that:

Adjust the LBLCOKS26 List:

Since your ratios list has 26 elements, modify the LBLCOKS26 list to contain only 26 items. This involves removing the last two items: "embedders" and "transformer_resblocks".

Modified LBLCOKS26:

LBLCOKS26 = [
"encoder",
"diffusion_model_input_blocks_0_",
"diffusion_model_input_blocks_1_",
"diffusion_model_input_blocks_2_",
"diffusion_model_input_blocks_3_",
"diffusion_model_input_blocks_4_",
"diffusion_model_input_blocks_5_",
"diffusion_model_input_blocks_6_",
"diffusion_model_input_blocks_7_",
"diffusion_model_input_blocks_8_",
"diffusion_model_input_blocks_9_",
"diffusion_model_input_blocks_10_",
"diffusion_model_input_blocks_11_",
"diffusion_model_middle_block_",
"diffusion_model_output_blocks_0_",
"diffusion_model_output_blocks_1_",
"diffusion_model_output_blocks_2_",
"diffusion_model_output_blocks_3_",
"diffusion_model_output_blocks_4_",
"diffusion_model_output_blocks_5_",
"diffusion_model_output_blocks_6_",
"diffusion_model_output_blocks_7_",
"diffusion_model_output_blocks_8_",
"diffusion_model_output_blocks_9_",
"diffusion_model_output_blocks_10_",
"diffusion_model_output_blocks_11_"
# Removed "embedders" and "transformer_resblocks"
]

Notice the comma sign after "output_blocks_11_" is also removed!

Why?

The ratios list is intended to correspond to each block in LBLCOKS26.
Having more items in LBLCOKS26 than in ratios leads to the IndexError when the script tries to access a ratio that doesn't exist.
Ensure Consistency Across the Script:

Check for Other References: Make sure that the rest of the script does not rely on "embedders" and "transformer_resblocks" being part of LBLCOKS26. Removing these items should not affect other functionalities.

Verify LoRA Model Structure: Ensure that the LoRA models you're attempting to merge do not require "embedders" and "transformer_resblocks". If they do, you'll need to provide corresponding ratios or adjust the script to handle these additional blocks.

@springheeledjack66
Copy link

With the help of gpt o1 preview, which is the best model for coding and general reasoning tasks, I was able to fix the issue. I take no credit. Here is the solution.

I downloaded the v20 pluslora.py file, and here are the changes suggested:

What's Happening:

Function Call: The function blockfromkey(key, keylist, isv2) is called with parameters key, keylist, and isv2. Index Retrieval: The result of this function call is used as an index to access the ratios list. Error Trigger: The index returned is out of the valid range for the ratios list, leading to the IndexError. Root Cause Analysis Upon examining your pluslora.py file, the issue stems from the mismatch between the length of the LBLCOKS26 list and the ratios list. Here's a detailed breakdown:

Definition of LBLCOKS26:

LBLCOKS26 = [ "encoder", "diffusion_model_input_blocks_0_", "diffusion_model_input_blocks_1_", "diffusion_model_input_blocks_2_", "diffusion_model_input_blocks_3_", "diffusion_model_input_blocks_4_", "diffusion_model_input_blocks_5_", "diffusion_model_input_blocks_6_", "diffusion_model_input_blocks_7_", "diffusion_model_input_blocks_8_", "diffusion_model_input_blocks_9_", "diffusion_model_input_blocks_10_", "diffusion_model_input_blocks_11_", "diffusion_model_middle_block_", "diffusion_model_output_blocks_0_", "diffusion_model_output_blocks_1_", "diffusion_model_output_blocks_2_", "diffusion_model_output_blocks_3_", "diffusion_model_output_blocks_4_", "diffusion_model_output_blocks_5_", "diffusion_model_output_blocks_6_", "diffusion_model_output_blocks_7_", "diffusion_model_output_blocks_8_", "diffusion_model_output_blocks_9_", "diffusion_model_output_blocks_10_", "diffusion_model_output_blocks_11_", "embedders", "transformer_resblocks" ] Item Count: 28 items. Definition of BLOCKID26:

BLOCKID26 = [ "BASE", "IN00", "IN01", "IN02", "IN03", "IN04", "IN05", "IN06", "IN07", "IN08", "IN09", "IN10", "IN11", "M00", "OUT00", "OUT01", "OUT02", "OUT03", "OUT04", "OUT05", "OUT06", "OUT07", "OUT08", "OUT09", "OUT10", "OUT11" ] Item Count: 26 items. Mismatch Explanation:

The LBLCOKS26 list contains 28 items, whereas the ratios list you provided contains 26 elements. When blockfromkey processes keys that map to the last two items ("embedders" and "transformer_resblocks"), it attempts to access ratios[26] or ratios[27], which are out of range since Python lists are zero-indexed and your ratios list only goes up to ratios[25]. Solution To resolve this IndexError, you need to ensure that the LBLCOKS26 list and the ratios list are aligned in length. Here's how you can do that:

Adjust the LBLCOKS26 List:

Since your ratios list has 26 elements, modify the LBLCOKS26 list to contain only 26 items. This involves removing the last two items: "embedders" and "transformer_resblocks".

Modified LBLCOKS26:

LBLCOKS26 = [ "encoder", "diffusion_model_input_blocks_0_", "diffusion_model_input_blocks_1_", "diffusion_model_input_blocks_2_", "diffusion_model_input_blocks_3_", "diffusion_model_input_blocks_4_", "diffusion_model_input_blocks_5_", "diffusion_model_input_blocks_6_", "diffusion_model_input_blocks_7_", "diffusion_model_input_blocks_8_", "diffusion_model_input_blocks_9_", "diffusion_model_input_blocks_10_", "diffusion_model_input_blocks_11_", "diffusion_model_middle_block_", "diffusion_model_output_blocks_0_", "diffusion_model_output_blocks_1_", "diffusion_model_output_blocks_2_", "diffusion_model_output_blocks_3_", "diffusion_model_output_blocks_4_", "diffusion_model_output_blocks_5_", "diffusion_model_output_blocks_6_", "diffusion_model_output_blocks_7_", "diffusion_model_output_blocks_8_", "diffusion_model_output_blocks_9_", "diffusion_model_output_blocks_10_", "diffusion_model_output_blocks_11_" # Removed "embedders" and "transformer_resblocks" ]

Notice the comma sign after "output_blocks_11_" is also removed!

Why?

The ratios list is intended to correspond to each block in LBLCOKS26. Having more items in LBLCOKS26 than in ratios leads to the IndexError when the script tries to access a ratio that doesn't exist. Ensure Consistency Across the Script:

Check for Other References: Make sure that the rest of the script does not rely on "embedders" and "transformer_resblocks" being part of LBLCOKS26. Removing these items should not affect other functionalities.

Verify LoRA Model Structure: Ensure that the LoRA models you're attempting to merge do not require "embedders" and "transformer_resblocks". If they do, you'll need to provide corresponding ratios or adjust the script to handle these additional blocks.

any recommendations for how we can do a temp fix job until there's an update?

@kwikmn
Copy link

kwikmn commented Nov 14, 2024

Yes,

Modified LBLCOKS26:

LBLCOKS26 = [ "encoder", "diffusion_model_input_blocks_0_", "diffusion_model_input_blocks_1_", "diffusion_model_input_blocks_2_", "diffusion_model_input_blocks_3_", "diffusion_model_input_blocks_4_", "diffusion_model_input_blocks_5_", "diffusion_model_input_blocks_6_", "diffusion_model_input_blocks_7_", "diffusion_model_input_blocks_8_", "diffusion_model_input_blocks_9_", "diffusion_model_input_blocks_10_", "diffusion_model_input_blocks_11_", "diffusion_model_middle_block_", "diffusion_model_output_blocks_0_", "diffusion_model_output_blocks_1_", "diffusion_model_output_blocks_2_", "diffusion_model_output_blocks_3_", "diffusion_model_output_blocks_4_", "diffusion_model_output_blocks_5_", "diffusion_model_output_blocks_6_", "diffusion_model_output_blocks_7_", "diffusion_model_output_blocks_8_", "diffusion_model_output_blocks_9_", "diffusion_model_output_blocks_10_", "diffusion_model_output_blocks_11_" # Removed "embedders" and "transformer_resblocks" ]

i.e. you just delete the string
", "embedders", "transformer_resblocks""

@springheeledjack66
Copy link

Yes,

Modified LBLCOKS26:

LBLCOKS26 = [ "encoder", "diffusion_model_input_blocks_0_", "diffusion_model_input_blocks_1_", "diffusion_model_input_blocks_2_", "diffusion_model_input_blocks_3_", "diffusion_model_input_blocks_4_", "diffusion_model_input_blocks_5_", "diffusion_model_input_blocks_6_", "diffusion_model_input_blocks_7_", "diffusion_model_input_blocks_8_", "diffusion_model_input_blocks_9_", "diffusion_model_input_blocks_10_", "diffusion_model_input_blocks_11_", "diffusion_model_middle_block_", "diffusion_model_output_blocks_0_", "diffusion_model_output_blocks_1_", "diffusion_model_output_blocks_2_", "diffusion_model_output_blocks_3_", "diffusion_model_output_blocks_4_", "diffusion_model_output_blocks_5_", "diffusion_model_output_blocks_6_", "diffusion_model_output_blocks_7_", "diffusion_model_output_blocks_8_", "diffusion_model_output_blocks_9_", "diffusion_model_output_blocks_10_", "diffusion_model_output_blocks_11_" # Removed "embedders" and "transformer_resblocks" ]

i.e. you just delete the string ", "embedders", "transformer_resblocks""
do you have a fixed version? I'm trying but can't seem to get it to work

@Xavia1991
Copy link

Xavia1991 commented Nov 14, 2024

Why?

The ratios list is intended to correspond to each block in LBLCOKS26. Having more items in LBLCOKS26 than in ratios leads to the IndexError when the script tries to access a ratio that doesn't exist. Ensure Consistency Across the Script:

Check for Other References: Make sure that the rest of the script does not rely on "embedders" and "transformer_resblocks" being part of LBLCOKS26. Removing these items should not affect other functionalities.

Verify LoRA Model Structure: Ensure that the LoRA models you're attempting to merge do not require "embedders" and "transformer_resblocks". If they do, you'll need to provide corresponding ratios or adjust the script to handle these additional blocks.

that seems to fix a different issue regarding index out of bounds. Which occurred regularly too. But this issue is about missing modules and not fixed by this.

@kalle07
Copy link
Author

kalle07 commented Nov 25, 2024

-> deleted "embedders" and "transformer_resblocks"
ok, there is no error at load

choose two models

but if i press
"merge" the red button

nothing happend
no error messager in CMD
(i doo all the same as 6 months ago - where all ways working fine)

@michP247
Copy link

michP247 commented Nov 29, 2024

If anyone is still having problems with the buttons not doing anything, its a bug with gradio, you have to disable this: Settings -> "Automatically open webui in browser on startup"

@kalle07
Copy link
Author

kalle07 commented Nov 29, 2024

and than? should i manualy paste local-adress:port in my browser ? and thats it ?

@michP247
Copy link

and than? should i manualy paste local-adress:port in my browser ? and thats it ?

or ctrl-click the link in the console. So it doesnt auto-launch and cause conflict with other extension

@kalle07
Copy link
Author

kalle07 commented Nov 29, 2024

i dont really understand ... i dont start forge or a1111 ?
or its only that autmatic launch?

@michP247
Copy link

Screenshot_29-11-2024_16928_127 0 0 1
disable that

@kalle07
Copy link
Author

kalle07 commented Nov 30, 2024

thx ... so the merge works at least without VAE
if i include VAE (all is on sdxl models)
this error

Stage 0/2: 100%|###################################################################| 2515/2515 [00:31<00:00, 79.66it/s]
Stage 1/2: 100%|##################################################################| 2515/2515 [00:18<00:00, 136.57it/s]
Stage 2/2: 100%|#############################################################################| 260/260 [00:00<?, ?it/s]
Baking in VAE from E:\WebUI_Forge\webui\models\VAE\sdxl_vae_fp16.safetensors
Traceback (most recent call last):
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\queueing.py", line 536, in process_events
response = await route_utils.call_process_api(
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\route_utils.py", line 285, in call_process_api
output = await app.get_blocks().process_api(
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\blocks.py", line 1923, in process_api
result = await self.call_function(
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\blocks.py", line 1508, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
File "e:\WebUI_Forge\system\python\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "e:\WebUI_Forge\system\python\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "e:\WebUI_Forge\system\python\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "e:\WebUI_Forge\system\python\lib\site-packages\gradio\utils.py", line 818, in wrapper
response = f(*args, **kwargs)
File "E:\WebUI_Forge\webui\extensions\sd-webui-supermerger\scripts\mergers\mergers.py", line 119, in smergegen
result,currentmodel,modelid,theta_0,metadata = smerge(
File "E:\WebUI_Forge\webui\extensions\sd-webui-supermerger\scripts\mergers\mergers.py", line 611, in smerge
for key in vae_dict.keys():
AttributeError: 'NoneType' object has no attribute 'keys'

and if i use it
AssertionError: You do not have CLIP state dict!
You do not have CLIP state dict!

and black image

so supermeger is done for me sorry : D
at the moment none replace NONE ... SAD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants