Skip to content

apply_loras does not unapply old lora weights #410

@maj160

Description

@maj160

This only matters when the same sd_ctx is used for multiple prompts - Loras that have been applied in a previous prompt but don't appear in the current prompt are not unapplied.

Steps to reproduce:

  • Create an sd_ctx
  • Generate an image using a prompt with a lora
  • Generate an image using a prompt without the lora in the previous step
    Expected results:
  • The lora is no longer applied to the second image
    Actual results:
  • The lora is still applied to the second image

Why this happens:
curr_lora_state contains the loras that are currently applied and their weights. However, inside apply_loras, we only handle loras in the current prompt, and we don't consider any other loras that are in curr_lora_state and might need to be removed.

Potential fix:
In apply_loras(), loop over curr_lora_state and unapply any loras that do not appear in the lora_state (that is, add them to lora_state_diff with negative multiplier)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions