ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

TypeError: ModelPatcherAndInjector.patch_model() got an unexpected keyword argument 'patch_weights'

Open CGMikeG opened this issue 11 months ago • 31 comments

Anybody knows a solution to this

Traceback (most recent call last): File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\comfy_extras\nodes_custom_sampler.py", line 326, in sample samples = comfy.sample.sample_custom(model, noise, cfg, sampler, sigmas, positive, negative, latent_image, noise_mask=noise_mask, callback=callback, disable_pbar=disable_pbar, seed=noise_seed) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 346, in motion_sample latents = wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\utils_model.py", line 360, in wrapped_function return function_to_wrap(*args, **kwargs) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 108, in sample_custom real_model, positive_copy, negative_copy, noise_mask, models = prepare_sampling(model, noise.shape, positive, negative, noise_mask) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 86, in prepare_sampling comfy.model_management.load_models_gpu([model] + models, model.memory_required([noise_shape[0] * 2] + list(noise_shape[1:])) + inference_memory) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 407, in load_models_gpu cur_loaded_model = loaded_model.model_load(lowvram_model_memory) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 300, in model_load raise e File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 294, in model_load self.real_model = self.model.patch_model_lowvram(device_to=patch_model_to, lowvram_model_memory=lowvram_model_memory) File "D:\COMFY\ComfyUI_windows_portable\ComfyUI\comfy\model_patcher.py", line 225, in patch_model_lowvram self.patch_model(device_to, patch_weights=False) TypeError: ModelPatcherAndInjector.patch_model() got an unexpected keyword argument 'patch_weights'

CGMikeG avatar Mar 15 '24 06:03 CGMikeG

I got the same issue. patch_model() definitely accepts patch_weights so I'm very confused what causes this. Waiting for a solution.

kriszhli avatar Mar 15 '24 07:03 kriszhli

I'm facing the same issue, and it has to be with the fact we are using vram state set to LOW_VRAM but solved (for now) by cloning the repo in a new empty folder and then revert it to the last working commit (eda8704) like this:

git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI
git reset --hard eda8704

Then if you are using the ComfyUI_windows_portable version (like me) copy and replace the files in the "ComfyUI" folder inside "ComfyUI_windows_portable" with all the files just downloaded.

And don't update ComfyUI until issue is closed.

ernestleft avatar Mar 16 '24 07:03 ernestleft

Got the same issue, but unfortunately I cannot go back to the older version as suggested by @ernestleft because then I get the following:

https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet/issues/84

Kaszanas avatar Mar 16 '24 14:03 Kaszanas

I am also getting this error:

executing KSamplerAdvanced:

ModelPatcherAndInjector.patch_model() got an unexpected keyword argument 'patch_weights'

File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1403, in sample return common_ksampler(model, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise, disable_noise=disable_noise, start_step=start_at_step, last_step=end_at_step, force_full_denoise=force_full_denoise) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1339, in common_ksampler samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 346, in motion_sample latents = wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\utils_model.py", line 360, in wrapped_function return function_to_wrap(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 93, in sample real_model, positive_copy, negative_copy, noise_mask, models = prepare_sampling(model, noise.shape, positive, negative, noise_mask) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 86, in prepare_sampling comfy.model_management.load_models_gpu([model] + models, model.memory_required([noise_shape[0] * 2] + list(noise_shape[1:])) + inference_memory) File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 407, in load_models_gpu cur_loaded_model = loaded_model.model_load(lowvram_model_memory) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 300, in model_load raise e File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 294, in model_load self.real_model = self.model.patch_model_lowvram(device_to=patch_model_to, lowvram_model_memory=lowvram_model_memory) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\New\ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_patcher.py", line 225, in patch_model_lowvram self.patch_model(device_to, patch_weights=False)

I tried going into the file and changing the patch_weights to True and then to false and tested both but still kept getting errors

DraculaSOTD avatar Mar 17 '24 20:03 DraculaSOTD

ModelPatcherAndInjector is an AnimateDiff-Evolved thing, not native to ComfyUI. Based on your error logs, it looks like a change is needed to work with patch_model_lowvram.

I didn't see this until kust now after I noticed Kaszana referencing the issue in Advanced-ControlNet. I didnt get any report about lowvram not working after the ComfyUI changes, so I assumed there were none. I'll look into it this week.

Kosinkadink avatar Mar 19 '24 15:03 Kosinkadink

File "D:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_patcher.py", line 225, in patch_model_lowvram self.patch_model(device_to, patch_weights=False) TypeError: ModelPatcherAndInjector.patch_model() got an unexpected keyword argument 'patch_weights'

I am getting this too, when I use animatediff with controlnets

meer007-cmd avatar Mar 19 '24 17:03 meer007-cmd

The fix was luckily very simple and is now merged into AnimateDiff-Evolved. Update AnimateDiff-Evolved, and the issue should be fixed. Let me know if it works now!

https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved/pull/319

Kosinkadink avatar Mar 19 '24 18:03 Kosinkadink

Works now! Thank you!

Georgerapo avatar Mar 19 '24 23:03 Georgerapo

Can you please advise a newbie and how to upgrade on windows? Just in the folder with ComfyUI use git pull? Or apparently use update_comfyui.bat

onitreyn avatar Mar 20 '24 18:03 onitreyn

I dunno I am still getting this error after I updated everything. First updated using comfy manager and then manually downloaded the model_injection.py and replaced it in my comfyUI folder.

The prompt will run to 100% done then error out. It definitely goes further than what I got as of yesterday though, which is it errors out before it even gets me to 0%. I'm almost thinking I should do a clean reinstall of comfy and see if it helps.

Error occurred when executing VAEDecode:

ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'

File "F:\comfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\comfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\comfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\comfyUI\ComfyUI_windows_portable\ComfyUI\nodes.py", line 288, in decode return (vae.decode(samples["samples"]), ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\comfyUI\ComfyUI_windows_portable\ComfyUI\comfy\sd.py", line 285, in decode model_management.load_models_gpu([self.patcher], memory_required=memory_used) File "F:\comfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 409, in load_models_gpu free_memory(total_memory_required[device] * 1.3 + extra_mem, device, models_already_loaded) File "F:\comfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 361, in free_memory m.model_unload() File "F:\comfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 312, in model_unload self.model.unpatch_model(self.model.offload_device, unpatch_weights=unpatch_weights)

supercorgiman avatar Mar 20 '24 18:03 supercorgiman

Can you please advise a newbie and how to upgrade on windows? Just in the folder with ComfyUI use git pull? Or apparently use update_comfyui.bat

You can update it via the manager

meer007-cmd avatar Mar 20 '24 18:03 meer007-cmd

Looks like ComfyUI had a new update 12 hours ago that I will need to make changes to account for, which is why you got the unpatch_weights missing thing.

To update a node pack, you can do so the easiest by using the Manager, or git pulling inside the directory of the specific custom_nodes subfolder.

Kosinkadink avatar Mar 20 '24 18:03 Kosinkadink

Can confirm, I just updated everything after not doing so for a while and while the first gen works correctly, trying to start another results in the unpatch_weights error. To the best of my knowledge I am not using lowvram mode though oO

molkemon avatar Mar 20 '24 20:03 molkemon

@Kosinkadink, I do like @molkemon, the same problem also occurs. What is strange is that it only happens at the first queue prompt. Each time not works, I have to restart it.

cmd: clear && python main.py --use-split-cross-attention --force-fp16

error: Exception in thread Thread-3 (prompt_worker): Traceback (most recent call last): File "/root/miniconda3/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/root/miniconda3/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/root/autodl-tmp/ComfyUI/main.py", line 111, in prompt_worker e.execute(item[2], prompt_id, item[3], item[4]) File "/root/autodl-tmp/ComfyUI/custom_nodes/rgthree-comfy/init.py", line 209, in rgthree_execute return self.rgthree_old_execute(*args, **kwargs) File "/root/autodl-tmp/ComfyUI/execution.py", line 371, in execute comfy.model_management.cleanup_models() File "/root/autodl-tmp/ComfyUI/comfy/model_management.py", line 451, in cleanup_models x.model_unload() File "/root/autodl-tmp/ComfyUI/comfy/model_management.py", line 312, in model_unload self.model.unpatch_model(self.model.offload_device, unpatch_weights=unpatch_weights) TypeError: ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'

O-O1024 avatar Mar 20 '24 20:03 O-O1024

A few seconds ago I pushed an update that should fix it - see if it works now. The change in ComfyUI code meant that any time a model containing AD would get unloaded, it didn't have the code to accept a new keyword parameter that ComfyUI does now when it unpatches and it would throw that error.

https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved/pull/321

Kosinkadink avatar Mar 20 '24 20:03 Kosinkadink

It seems to be working now for me, thanks for the fast fix :)

molkemon avatar Mar 20 '24 21:03 molkemon

RuntimeError: The size of tensor a (67) must match the size of tensor b (12) at non-singleton dimension 3

semaster avatar Mar 20 '24 21:03 semaster

I don't think the error you're getting there is relevant to the changes above - the changes don't affect tensor sizes.

Kosinkadink avatar Mar 20 '24 21:03 Kosinkadink

sry it was just last line. Full error is like: Traceback (most recent call last): File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\nodes.py", line 1403, in sample return common_ksampler(model, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise, disable_noise=disable_noise, start_step=start_at_step, last_step=end_at_step, force_full_denoise=force_full_denoise) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\nodes.py", line 1339, in common_ksampler samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 22, in informative_sample raise e File "D:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 9, in informative_sample return original_sample(*args, **kwargs) # This code helps interpret error messages that occur within exceptions but does not have any impact on other operations. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 365, in motion_sample latents = wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\utils_model.py", line 377, in wrapped_function return function_to_wrap(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\comfy\sample.py", line 100, in sample samples = sampler.sample(noise, positive_copy, negative_copy, cfg=cfg, latent_image=latent_image, start_step=start_step, last_step=last_step, force_full_denoise=force_full_denoise, denoise_mask=noise_mask, sigmas=sigmas, callback=callback, disable_pbar=disable_pbar, seed=seed) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\comfy\samplers.py", line 704, in sample return sample(self.model, noise, positive, negative, cfg, self.device, sampler, sigmas, self.model_options, latent_image=latent_image, denoise_mask=denoise_mask, callback=callback, disable_pbar=disable_pbar, seed=seed) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\comfy\samplers.py", line 609, in sample samples = sampler.sample(model_wrap, sigmas, extra_args, callback, noise, latent_image, denoise_mask, disable_pbar) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\comfy\samplers.py", line 548, in sample samples = self.sampler_function(model_k, noise, sigmas, extra_args=extra_args, callback=k_callback, disable=disable_pbar, **self.extra_options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\python_embeded\Lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\comfy\k_diffusion\sampling.py", line 751, in sample_lcm x = model.inner_model.inner_model.model_sampling.noise_scaling(sigmas[i + 1] * s_in, noise_sampler(sigmas[i], sigmas[i + 1]), x) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "d:\ComfyUI_containers\ComfyUI_cu121\ComfyUI\comfy\model_sampling.py", line 18, in noise_scaling noise = noise * sigma ~~~~~~^~~~~~~ RuntimeError: The size of tensor a (67) must match the size of tensor b (12) at non-singleton dimension 3

semaster avatar Mar 20 '24 21:03 semaster

This error is entirely unrelated to the one mentioned here. You can open up a new issue on AnimateDiff-Evolved, where you can also post a screenshot of your workflow.

Kosinkadink avatar Mar 20 '24 21:03 Kosinkadink

After trying to update comfyUI and animatediff it finally worked now! No more error yay!

supercorgiman avatar Mar 20 '24 21:03 supercorgiman

@semaster the error you're getting is actually a bug in ComfyUI with one of the recent updates. LCM + latent batch of greater than 1 no longer works (AKA, AnimateDiff LCM will not work). comfy has been alerted to the issue, so there should hopefully be a ComfyUI update soon to fix it.

Kosinkadink avatar Mar 20 '24 23:03 Kosinkadink

@semaster the error you're getting is actually a bug in ComfyUI with one of the recent updates. LCM + latent batch of greater than 1 no longer works (AKA, AnimateDiff LCM will not work). comfy has been alerted to the issue, so there should hopefully be a ComfyUI update soon to fix it.

I get that error too, when I switch off LCM Animatediff works fine, hope I'll fix it soon.

meer007-cmd avatar Mar 20 '24 23:03 meer007-cmd

Error occurred when executing KSampler:

ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'

微信截图_20240321174851

what's wrong? thankU

Tbler avatar Mar 21 '24 10:03 Tbler

Traceback (most recent call last): File "/content/drive/MyDrive/ComfyUI/execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) File "/content/drive/MyDrive/ComfyUI/execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) File "/content/drive/MyDrive/ComfyUI/execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) File "/content/drive/MyDrive/ComfyUI/nodes.py", line 1403, in sample return common_ksampler(model, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise, disable_noise=disable_noise, start_step=start_at_step, last_step=end_at_step, force_full_denoise=force_full_denoise) File "/content/drive/MyDrive/ComfyUI/nodes.py", line 1339, in common_ksampler samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, File "/content/drive/MyDrive/ComfyUI/custom_nodes/ComfyUI-Impact-Pack/modules/impact/sample_error_enhancer.py", line 9, in informative_sample return original_sample(*args, **kwargs) # This code helps interpret error messages that occur within exceptions but does not have any impact on other operations. File "/content/drive/MyDrive/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved (1)/animatediff/sampling.py", line 346, in motion_sample latents = wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs) File "/content/drive/MyDrive/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved (1)/animatediff/utils_model.py", line 360, in wrapped_function return function_to_wrap(*args, **kwargs) File "/content/drive/MyDrive/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/animatediff/sampling.py", line 267, in motion_sample return orig_comfy_sample(model, noise, *args, **kwargs) File "/content/drive/MyDrive/ComfyUI/comfy/sample.py", line 93, in sample real_model, positive_copy, negative_copy, noise_mask, models = prepare_sampling(model, noise.shape, positive, negative, noise_mask) File "/content/drive/MyDrive/ComfyUI/comfy/sample.py", line 86, in prepare_sampling comfy.model_management.load_models_gpu([model] + models, model.memory_required([noise_shape[0] * 2] + list(noise_shape[1:])) + inference_memory) File "/content/drive/MyDrive/ComfyUI/comfy/model_management.py", line 436, in load_models_gpu cur_loaded_model = loaded_model.model_load(lowvram_model_memory) File "/content/drive/MyDrive/ComfyUI/comfy/model_management.py", line 302, in model_load self.model_unload() File "/content/drive/MyDrive/ComfyUI/comfy/model_management.py", line 312, in model_unload self.model.unpatch_model(self.model.offload_device, unpatch_weights=unpatch_weights) TypeError: ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'

I have the newest version of Comfy and Animatediff on Colab

Uemuet avatar Mar 21 '24 16:03 Uemuet

@Uemuet your AnimateDiff-Evolved is still outdated

Kosinkadink avatar Mar 21 '24 17:03 Kosinkadink

Error occurred when executing KSampler:

ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'

微信截图_20240321174851

what's wrong? thankU

same issue here when running segsdetailerforAnimatediff.

of Detected SEGS: 1

model_type EPS Using xformers attention in VAE Using xformers attention in VAE clip missing: ['clip_l.logit_scale', 'clip_l.transformer.text_projection.weight'] loaded straight to GPU Requested to load BaseModel Loading 1 new model [AnimateDiffEvo] - INFO - Loading motion module v3_sd15_mm.ckpt Using xformers attention in VAE Using xformers attention in VAE Requested to load SD1ClipModel Loading 1 new model Detailer: segment upscale for ((172, 234)) | crop region (516, 702) x 1.094894413258487 -> (564, 768) Requested to load AutoencoderKL Loading 1 new model [AnimateDiffEvo] - INFO - Sliding context window activated - latents passed in (45) greater than context_length 16. [AnimateDiffEvo] - INFO - Using motion module v3_sd15_mm.ckpt:v3. Requested to load BaseModel Requested to load AnimateDiffModel Loading 2 new models !!! Exception during processing !!! Traceback (most recent call last): File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 299, in model_load self.real_model = self.model.patch_model(device_to=patch_model_to, patch_weights=load_weights) TypeError: ModelPatcherAndInjector.patch_model() got an unexpected keyword argument 'patch_weights'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\animatediff_nodes.py", line 92, in doit segs, cnet_images = SEGSDetailerForAnimateDiff.do_detail(image_frames, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\animatediff_nodes.py", line 69, in do_detail enhanced_image_tensor, cnet_images = core.enhance_detail_for_animatediff(cropped_image_frames, model, clip, vae, guide_size, guide_size_for, max_size, File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\core.py", line 407, in enhance_detail_for_animatediff refined_latent = impact_sampling.ksampler_wrapper(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\impact_sampling.py", line 125, in ksampler_wrapper refined_latent = nodes.KSampler().sample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise * sigma_factor)[0] File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1369, in sample return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1339, in common_ksampler samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 9, in informative_sample return original_sample(*args, **kwargs) # This code helps interpret error messages that occur within exceptions but does not have any impact on other operations. File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateLCM\animatediff\sampling.py", line 334, in motion_sample latents = wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateLCM\animatediff\utils_model.py", line 272, in wrapped_function return function_to_wrap(*args, **kwargs) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 267, in motion_sample return orig_comfy_sample(model, noise, *args, **kwargs) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 93, in sample real_model, positive_copy, negative_copy, noise_mask, models = prepare_sampling(model, noise.shape, positive, negative, noise_mask) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 86, in prepare_sampling comfy.model_management.load_models_gpu([model] + models, model.memory_required([noise_shape[0] * 2] + list(noise_shape[1:])) + inference_memory) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 436, in load_models_gpu cur_loaded_model = loaded_model.model_load(lowvram_model_memory) File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 302, in model_load self.model_unload() File "C:\Downloads\ComfyUI_windows_portable_nvidia_cu118_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 312, in model_unload self.model.unpatch_model(self.model.offload_device, unpatch_weights=unpatch_weights) TypeError: ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'

kacecarol avatar Mar 23 '24 12:03 kacecarol

I'm getting the error now as well. Fresh Comfy install too. Less than a week. Went in and foolishly updated custom nodes today and now this:

Error occurred when executing KSampler Adv. (Efficient): ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights' File "C:\SD\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\custom_nodes\efficiency-nodes-comfyui\efficiency_nodes.py", line 2206, in sample_adv return super().sample(model, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\custom_nodes\efficiency-nodes-comfyui\efficiency_nodes.py", line 713, in sample samples, images, gifs, preview = process_latent_image(model, seed, steps, cfg, sampler_name, scheduler, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\custom_nodes\efficiency-nodes-comfyui\efficiency_nodes.py", line 537, in process_latent_image samples = KSamplerAdvanced().sample(model, add_noise, seed, steps, cfg, sampler_name, scheduler, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1403, in sample return common_ksampler(model, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise, disable_noise=disable_noise, start_step=start_at_step, last_step=end_at_step, force_full_denoise=force_full_denoise) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1339, in common_ksampler samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 9, in informative_sample return original_sample(*args, **kwargs) # This code helps interpret error messages that occur within exceptions but does not have any impact on other operations. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateLCM\animatediff\sampling.py", line 334, in motion_sample latents = wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateLCM\animatediff\utils_model.py", line 272, in wrapped_function return function_to_wrap(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 267, in motion_sample return orig_comfy_sample(model, noise, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 93, in sample real_model, positive_copy, negative_copy, noise_mask, models = prepare_sampling(model, noise.shape, positive, negative, noise_mask) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 86, in prepare_sampling comfy.model_management.load_models_gpu([model] + models, model.memory_required([noise_shape[0] * 2] + list(noise_shape[1:])) + inference_memory) File "C:\SD\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 443, in load_models_gpu cur_loaded_model = loaded_model.model_load(lowvram_model_memory) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\SD\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 302, in model_load self.model_unload() File "C:\SD\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 312, in model_unload self.model.unpatch_model(self.model.offload_device, unpatch_weights=unpatch_weights)

wordbrew avatar Mar 28 '24 06:03 wordbrew

A few seconds ago I pushed an update that should fix it - see if it works now. The change in ComfyUI code meant that any time a model containing AD would get unloaded, it didn't have the code to accept a new keyword parameter that ComfyUI does now when it unpatches and it would throw that error.

Kosinkadink/ComfyUI-AnimateDiff-Evolved#321

Hi. Did ComfyUi do another update that broke this again? Was literally working for me last night and I updated nodes today and now am getting the error.

wordbrew avatar Mar 28 '24 06:03 wordbrew

@wordbrew uninstall ComfyUI-AnimateLCM. AnimateDiff-Evolved already supports LCM, and that repo is a copy of my code, including class names, which is why it conflicts with AnimateDiff-Evolved.

Kosinkadink avatar Mar 28 '24 14:03 Kosinkadink