Haoming02 / sd-forge-couple

An Extension for Forge Webui that implements Attention Couple
GNU General Public License v3.0
252 stars 10 forks source link

AssertionError: k and v must be the same. #79

Open rogersohandsome opened 14 hours ago

rogersohandsome commented 14 hours ago

What's causing that error? It works perfectly until that happens.

[Memory Management] Target: KModel, Free GPU: 16154.00 MB, Model Require: 0.00 MB, Previously Loaded: 4897.05 MB, Inference Require: 1024.00 MB, Remaining: 15130.00 MB, All loaded to GPU. Moving model(s) has taken 0.04 seconds 0%| | 0/30 [00:00<?, ?it/s] Traceback (most recent call last): File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules_forge\main_thread.py", line 30, in work self.result = self.func(*self.args, self.kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules\txt2img.py", line 131, in txt2img_function processed = processing.process_images(p) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules\processing.py", line 842, in process_images res = process_images_inner(p) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules\processing.py", line 990, in process_images_inner samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules\processing.py", line 1387, in sample samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x)) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules\sd_samplers_kdiffusion.py", line 238, in sample samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, extra_params_kwargs)) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules\sd_samplers_common.py", line 278, in launch_sampling return func() File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules\sd_samplers_kdiffusion.py", line 238, in samples = self.launch_sampling(steps, lambda: self.func(self.model_wrap_cfg, x, extra_args=self.sampler_extra_args, disable=False, callback=self.callback_state, extra_params_kwargs)) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, *kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\k_diffusion\sampling.py", line 595, in sample_dpmpp_2m denoised = model(x, sigmas[i] s_in, extra_args) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl return forward_call(*args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\modules\sd_samplers_cfg_denoiser.py", line 199, in forward denoised, cond_pred, uncond_pred = sampling_function(self, denoiser_params=denoiser_params, cond_scale=cond_scale, cond_composition=cond_composition) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\sampling\sampling_function.py", line 362, in sampling_function denoised, cond_pred, uncond_pred = sampling_function_inner(model, x, timestep, uncond, cond, cond_scale, model_options, seed, return_full=True) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\sampling\sampling_function.py", line 303, in sampling_function_inner cond_pred, uncond_pred = calc_cond_uncondbatch(model, cond, uncond, x, timestep, model_options) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\sampling\sampling_function.py", line 273, in calc_cond_uncond_batch output = model.apply_model(inputx, timestep, c).chunk(batch_chunks) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\modules\k_model.py", line 45, in apply_model model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, *extra_conds).float() File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl return self._call_impl(args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl return forward_call(*args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\nn\unet.py", line 713, in forward h = module(h, emb, context, transformer_options) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl return forward_call(args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\nn\unet.py", line 83, in forward x = layer(x, context, transformer_options) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl return forward_call(*args, *kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\nn\unet.py", line 321, in forward x = block(x, context=context[i], transformer_options=transformer_options) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1532, in _wrapped_call_impl return self._call_impl(args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\nn\modules\module.py", line 1541, in _call_impl return forward_call(*args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\nn\unet.py", line 181, in forward return checkpoint(self._forward, (x, context, transformer_options), None, self.checkpoint) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\nn\unet.py", line 12, in checkpoint return f(args) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\backend\nn\unet.py", line 253, in _forward n, context_attn2, value_attn2 = p(n, context_attn2, value_attn2, extra_options) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\venv\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(args, kwargs) File "F:\VirtualPC\api\stable-diffusion-webui-forge.git\app\extensions\sd-forge-couple\lib_couple\attention_couple.py", line 49, in attn2_patch assert k.mean() == v.mean(), "k and v must be the same." AssertionError: k and v must be the same. k and v must be the same.

Haoming02 commented 14 hours ago

Got anymore information?

Otherwise, not much to go on upon...

Does restarting the Webui again works for example?

rogersohandsome commented 6 minutes ago

Found it was adetailer that was sometimes breaking it, even with compatibility on or off. first gives black image then eventually starts giving that error when trying to generate again. Only restarting forge makes it work again.

Easy workaround i guess is just sending it to img2img and do adetailer there.