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

Merging loras to model #408

Open
CasanovaSan opened this issue Oct 16, 2024 · 9 comments
Open

Merging loras to model #408

CasanovaSan opened this issue Oct 16, 2024 · 9 comments

Comments

@CasanovaSan
Copy link

i tried to merge 6 loras to a model but gives me this error (latesst a1111) (i also did try with only one)

Loading sd\cassycartoon_v30.safetensors [ff3cb00411]
Reusing loaded model sd\CassyAnimeV2.fp16.safetensors [be01adc2e1] to load sd\cassycartoon_v30.safetensors [ff3cb00411]
Loading weights [ff3cb00411] from C:\AI\StableDif\Packages\Stable Diffusion WebUI\models\Stable-diffusion\sd\cassycartoon_v30.safetensors
Applying attention optimization: xformers... done.
Weights loaded in 65.7s (send model to cpu: 0.9s, load weights from disk: 0.9s, apply weights to model: 63.3s, apply half(): 0.2s, hijack: 0.2s).
Traceback (most recent call last):
  File "C:\AI\StableDif\Packages\Stable Diffusion WebUI\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\AI\StableDif\Packages\Stable Diffusion WebUI\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "C:\AI\StableDif\Packages\Stable Diffusion WebUI\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\AI\StableDif\Packages\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 "C:\AI\StableDif\Packages\Stable Diffusion WebUI\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "C:\AI\StableDif\Packages\Stable Diffusion WebUI\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "C:\AI\StableDif\Packages\Stable Diffusion WebUI\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "C:\AI\StableDif\Packages\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 "C:\AI\StableDif\Packages\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'

I also tried to merge on Forge but i got this error

Startup time: 35.7s (prepare environment: 8.3s, import torch: 12.0s, initialize shared: 0.2s, other imports: 0.5s, load scripts: 4.2s, initialize extra networks: 0.2s, initialize google blockly: 4.1s, create ui: 3.6s, gradio launch: 2.7s, app_started_callback: 0.5s).
Environment vars changed: {'stream': False, 'inference_memory': 1395.0, 'pin_shared_memory': False}
[GPU Setting] You will use 65.93% GPU memory (2700.00 MB) to load weights, and use 34.07% GPU memory (1395.00 MB) to do matrix computation.
Environment vars changed: {'stream': False, 'inference_memory': 1024.0, 'pin_shared_memory': False}
[GPU Setting] You will use 74.99% GPU memory (3071.00 MB) to load weights, and use 25.01% GPU memory (1024.00 MB) to do matrix computation.
Model selected: {'checkpoint_info': {'filename': 'C:\\AI\\StableDif\\Packages\\stable-diffusion-webui-forge\\models\\Stable-diffusion\\sd\\cassycartoon_v30.safetensors', 'hash': '10eaf095'}, 'additional_modules': [], 'unet_storage_dtype': None}
Using online LoRAs in FP16: False
Model selected: {'checkpoint_info': {'filename': 'C:\\AI\\StableDif\\Packages\\stable-diffusion-webui-forge\\models\\Stable-diffusion\\sd\\cassycartoon_v30.safetensors', 'hash': '10eaf095'}, 'additional_modules': [], 'unet_storage_dtype': 'nf4'}
Using online LoRAs in FP16: True
Environment vars changed: {'stream': False, 'inference_memory': 1395.0, 'pin_shared_memory': False}
[GPU Setting] You will use 65.93% GPU memory (2700.00 MB) to load weights, and use 34.07% GPU memory (1395.00 MB) to do matrix computation.
Plus LoRA start
Loading sd\cassycartoon_v30.safetensors
Traceback (most recent call last):
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\venv\lib\site-packages\gradio\queueing.py", line 536, in process_events
    response = await route_utils.call_process_api(
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\venv\lib\site-packages\gradio\route_utils.py", line 285, in call_process_api
    output = await app.get_blocks().process_api(
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\venv\lib\site-packages\gradio\blocks.py", line 1923, in process_api
    result = await self.call_function(
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\venv\lib\site-packages\gradio\blocks.py", line 1508, in call_function
    prediction = await anyio.to_thread.run_sync(  # type: ignore
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\venv\lib\site-packages\gradio\utils.py", line 818, in wrapper
    response = f(*args, **kwargs)
  File "C:\AI\StableDif\Packages\stable-diffusion-webui-forge\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 743, in pluslora
    isxl = "conditioner.embedders.1.model.transformer.resblocks.9.mlp.c_proj.weight" in theta_0.keys()
AttributeError: 'NoneType' object has no attribute 'keys'
@Kortique
Copy link

i tried to merge 6 loras to a model but gives me this error (latesst a1111) (i also did try with only one)

ModuleNotFoundError: No module named 'scripts.A1111'

This error occurred after update of a October 13, namely ac3ad91. To fix it, run in cmd the command git checkout 4f47f4fad94784ea8aa5c19749f6ca9b2ac73025.

@yuu3777
Copy link

yuu3777 commented Oct 20, 2024

I am experiencing the same error, and I tried using git checkout, but I got the following result. I also tried changing the Stable Diffusion version, but the issue remains the same. I am using Windows 11 and A1111 version v1.10.1.

/d/stable-diffusion-webui ((v1.10.1)) $ git checkout 4f47f4fad94784ea8aa5c19749f6ca9b2ac73025 fatal: reference is not a tree: 4f47f4fad94784ea8aa5c19749f6ca9b2ac73025

@Kortique
Copy link

I am experiencing the same error, and I tried using git checkout, but I got the following result. I also tried changing the Stable Diffusion version, but the issue remains the same. I am using Windows 11 and A1111 version v1.10.1.

/d/stable-diffusion-webui ((v1.10.1)) $ git checkout 4f47f4fad94784ea8aa5c19749f6ca9b2ac73025 fatal: reference is not a tree: 4f47f4fad94784ea8aa5c19749f6ca9b2ac73025

The command should be run in the folder with the extension, for example \stable-diffusion-webui\extensions\sd-webui-supermerger

@yuu3777
Copy link

yuu3777 commented Oct 21, 2024

The issue has been resolved. Thank you!

@driqeks
Copy link

driqeks commented Oct 23, 2024

The issue has been resolved. Thank you!

no, I still get the same issue with the newest version of A1111 and this plugin

@Neytiri7
Copy link

Neytiri7 commented Nov 3, 2024

Please give me a rollback.

Traceback (most recent call last):
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "W:\SynologyDrive\SD1.5\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 776, in pluslora
    theta_0 = newpluslora(theta_0,filenames,lweis,names, isxl,isv2, keychanger)
  File "W:\SynologyDrive\SD1.5\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 853, in newpluslora
    import scripts.A1111.networks as nets
ModuleNotFoundError: No module named 'scripts.A1111'
Plus LoRA start
Loading Americano\CoffeeMix_Americano-s3.safetensors [a8a13ec857]
Traceback (most recent call last):
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "W:\SynologyDrive\SD1.5\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "W:\SynologyDrive\SD1.5\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 776, in pluslora
    theta_0 = newpluslora(theta_0,filenames,lweis,names, isxl,isv2, keychanger)
  File "W:\SynologyDrive\SD1.5\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 853, in newpluslora
    import scripts.A1111.networks as nets
ModuleNotFoundError: No module named 'scripts.A1111'

@vekitan55
Copy link

A1111ではNeytiri7氏と同様のエラーが発生します。どうやってもA1111.networksを見つけないので、importの行をdefの前に移動したら動くようにはなりました。きれいな解決方法ではないですよね。

Forgeというか最新版はいろんな部分が動かない印象です。
単純に1クリック版でインストールしたForgeにSupermerger(とLora Block Weight)をインストールしただけの環境でckptへのloraのマージができません。

Traceback (most recent call last):
File "D:\forge2\system\python\lib\site-packages\gradio\queueing.py", line 536, in process_events
response = await route_utils.call_process_api(
File "D:\forge2\system\python\lib\site-packages\gradio\route_utils.py", line 285, in call_process_api
output = await app.get_blocks().process_api(
File "D:\forge2\system\python\lib\site-packages\gradio\blocks.py", line 1923, in process_api
result = await self.call_function(
File "D:\forge2\system\python\lib\site-packages\gradio\blocks.py", line 1508, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
File "D:\forge2\system\python\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "D:\forge2\system\python\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "D:\forge2\system\python\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "D:\forge2\system\python\lib\site-packages\gradio\utils.py", line 818, in wrapper
response = f(*args, **kwargs)
File "D:\forge2\webui\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 846, in pluslora
load_model(revert_target, reload=True)
File "D:\forge2\webui\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 1568, in load_model
forge_model_reload()
File "D:\forge2\system\python\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\forge2\webui\modules\sd_models.py", line 504, in forge_model_reload
sd_model = forge_loader(state_dict, additional_state_dicts=additional_state_dicts)
File "D:\forge2\system\python\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\forge2\webui\backend\loader.py", line 287, in forge_loader
component = load_huggingface_component(estimated_config, component_name, lib_name, cls_name, local_path, component_sd)
File "D:\forge2\webui\backend\loader.py", line 61, in load_huggingface_component
assert isinstance(state_dict, dict) and len(state_dict) > 16, 'You do not have CLIP state dict!'
AssertionError: You do not have CLIP state dict!

ググるとFlux関係で出ることがあるエラーみたいで、Fluxのテキストエンコーダを入れたりしましたが(マージはSD1.5のモデルです)変わりません。

Loraがマージできないというissueを参考に

git checkout 4f47f4f

もやってみましたが、エラーが以下に変わるだけでした。このエラーがなくなるロールバックのはずだったと思うのですが。

Traceback (most recent call last):
File "D:\forge2\system\python\lib\site-packages\gradio\queueing.py", line 536, in process_events
response = await route_utils.call_process_api(
File "D:\forge2\system\python\lib\site-packages\gradio\route_utils.py", line 285, in call_process_api
output = await app.get_blocks().process_api(
File "D:\forge2\system\python\lib\site-packages\gradio\blocks.py", line 1923, in process_api
result = await self.call_function(
File "D:\forge2\system\python\lib\site-packages\gradio\blocks.py", line 1508, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
File "D:\forge2\system\python\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "D:\forge2\system\python\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "D:\forge2\system\python\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "D:\forge2\system\python\lib\site-packages\gradio\utils.py", line 818, in wrapper
response = f(*args, **kwargs)
File "D:\forge2\webui\extensions\sd-webui-supermerger\scripts\mergers\pluslora.py", line 743, in pluslora
isxl = "conditioner.embedders.1.model.transformer.resblocks.9.mlp.c_proj.weight" in theta_0.keys()
AttributeError: 'NoneType' object has no attribute 'keys'

@vekitan55
Copy link

ちゃんとした解決にはなっていませんがForge側の、
webui\backend\loader.py", line 61
のassertをコメントアウトしてやればエラーが出まくるもののモデルファイルは出力されることを確認しました。
アテンションとかが無茶苦茶になっている可能性はありますがそれらしい絵は出ました。
なぜかFluxだと思われて処理が進んでますよね。。。。

@vekitan55
Copy link

いろいろやって問題はForge側にあることは理解しました

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

6 participants