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

monkeypatch_lora does not correctly replace to_out Linear #64

Closed
hafriedlander opened this issue Dec 19, 2022 · 2 comments
Closed

monkeypatch_lora does not correctly replace to_out Linear #64

hafriedlander opened this issue Dec 19, 2022 · 2 comments

Comments

@hafriedlander
Copy link
Collaborator

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
@brian6091
Copy link
Collaborator

Potentially related?: #39

@hafriedlander
Copy link
Collaborator Author

Ah, yes, same thing. Didn't check develop branch. I'm working on a cleaner fix. I'll leave comments in that issue.

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