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

LoRAScheduler output can differ from LoraLoader if both are used in the same workflow #36

Closed
JoyfulTemplate opened this issue Apr 13, 2024 · 2 comments

Comments

@JoyfulTemplate
Copy link

The LoRAScheduler output image is different from normal Lora loader uses the same checkpoint. (Sometimes it occurs at the first run, sometimes occurs runs later after changing seed, prompt etc.)
different_result
Interestingly, if the LoRAScheduler uses a separate checkpoint loader then the results become the same.

@asagi4
Copy link
Owner

asagi4 commented Apr 13, 2024

This looks like unpatching the model after sampling isn't happening properly, but I'm not sure where the actual problem is. Maybe ComfyUI doesn't always unpatch models after sampling.

ComfyUI's model object is actually a thin wrapper over the "real" model object that contains the loaded weights, and applying LoRAs modifies those weights directly. The patcher maintains a backup of modified weights that should get restored when sampling is done. It seems that's not happening. It might be that ComfyUI is being smart and not "needlessly" unpatching a model that doesn't change.

With a separate checkpoint loader, the ModelPatcher objects will not share the same underlying weights, so you don't get problems like this.

Maybe I'll figure out a fix at some point, but for now I'd just suggest not mixing the LoRAScheduler or ScheduleToModel with LoRALoader

@asagi4 asagi4 changed the title LoRAScheduler output differs from Lora Loader LoRAScheduler output can differ from LoraLoader if both are used in the same workflow Apr 13, 2024
asagi4 added a commit that referenced this issue Apr 13, 2024
@JoyfulTemplate
Copy link
Author

@asagi4 Thanks for the explanation, I tried use multiple LoRAScheduler in the same workflow and results look fine. So for now I'll only use LoRAScheduler if I need to schedule loras. Thanks again for bring this feature to comfyUI :)

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

2 participants