ComfyUI-AnimateDiff-Evolved: ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'
I get this error when trying to run the AnimateDiff-Lightning sample workflow. It is triggered by the KSampler node, but the error message directly references the AnimateDiff-Evolved code. I have seen this error mentioned on the ComfyUI Issues page as well and I tried the solutions proposed in that thread, but it did not work. link to that page: https://github.com/comfyanonymous/ComfyUI/issues/3100 I deleted AnimateDiff-Evolved (after first backing up the models) and git-cloned it from scratch (and then I put the models back there) I updated Comfy. I tried installing the AnimateDiff-Evolved develop branch since the “unpatch_weights” function was mentioned quite a few times over there. I tried the current main branch version as well, of course. It’s with that one that I get the error below:
Error occurred when executing KSampler:
ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'
File "D:\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\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:\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:\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 "D:\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:\ComfyUI_windows_portable\ComfyUI\custom_nodes\Comfyui-StableSR-main\nodes.py", line 69, in hook_sample
return original_sample(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\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 "D:\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 "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateLCM\animatediff\utils_model.py", line 272, in wrapped_function
return function_to_wrap(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\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 "D:\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:\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:\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 "D:\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 302, in model_load
self.model_unload()
File "D:\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)
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Comments: 17 (7 by maintainers)
Looking at your startup log again, I have a theory - disable/delete ComfyUI-AnimateLCM, it is entirely pointless to have it. ComfyUI-AnimateDiff-Evolved supports AnimateLCM natively, and ComfyUI-AnimateLCM copies and pastes my code, INCLUDING the ModelPatcherAndInjector class. And as you can imagine, they do not keep up with the ComfyUI updates like I do lol, so they dont have unpatch_weights added.
No problem, glad we figured it out. It will help out anyone else has the same problem in the future - it was very adjacent to the “two installs, one outdated” problem.
TLDR : if you have the same problem as the one I describre above, just uninstall AnimateLCM - you don’t need it anyways.
Thanks again @Kosinkadink , it was very generous of you to help me solve this the way you did, and so quickly as well !
Y E S !
IT WORKS ! Thank you so much, I would never had that intuition without your help, and your confirmation just saved me a lot of time and hesitation.
I had the same intuition - and I can see AnimateLCM mentioned in the error message as well. This might well be the source of my problems ! I’ll check that immediately and I’ll come back asap to tell you if we have found the culprit.
Thanks for your help by the way - I really appreciate it !