Skip to content

monkeypatch_lora does not correctly replace to_out Linear #64

@hafriedlander

Description

@hafriedlander

monkeypatch_lora finds CrossAttention blocks and looks for any Linears

It uses named_modules which will find any descendants, either immediate children or subchildren, But then it sets the replacement LoraInjectedLinear on the CrossAttention block directly

CrossAttention has a ModuleList for to_out that contains a Linear.

Because of the above, the to_out Linear is not replaced correctly. Instead, an (unused) LoraInjectedLinear model with the name of to_out.0 is set on the CrossAttention block.

You can tell by looking at the module names on the CrossAttention block after patching.

Before patching:

to_q
to_k
to_v
to_out

After patching:

to_q
to_k
to_v
to_out
to_out.0

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