leejet / stable-diffusion.cpp

Stable Diffusion and Flux in pure C/C++
MIT License
3.31k stars 279 forks source link

Prevent LoRA alpha scalars from being skipped over during model loading #263

Closed grauho closed 4 months ago

grauho commented 4 months ago

Adjusted model.cpp such that LoRA alpha scalars are not skipped for having an encoded dimension of zero.

grauho commented 4 months ago

Interestingly enough the problem this addresses isn't a problem for most LoRAs as the LoRA loading logic only needs to access the "alpha" scalars when the "scale" tensor is missing. That said I believe this addition is still valuable for two reasons. Firstly, edge cases that don't have the scale tensor may yield undesirable results if the alpha scalar tensor isn't loaded as observed with the SDXL Lightning LoRA. Secondly, this keeps the dimension check from spamming the users terminal with 'ERROR' log messages that might lead to confusion.

leejet commented 4 months ago

Thank you for your contribution, but I believe the latest master branch has already addressed this issue and is more versatile, even functioning in Debug mode.