(text_encoder, lora_scale: float = 1.0)
| 67 | |
| 68 | |
| 69 | def adjust_lora_scale_text_encoder(text_encoder, lora_scale: float = 1.0): |
| 70 | for _, attn_module in text_encoder_attn_modules(text_encoder): |
| 71 | if isinstance(attn_module.q_proj, PatchedLoraProjection): |
| 72 | attn_module.q_proj.lora_scale = lora_scale |
| 73 | attn_module.k_proj.lora_scale = lora_scale |
| 74 | attn_module.v_proj.lora_scale = lora_scale |
| 75 | attn_module.out_proj.lora_scale = lora_scale |
| 76 | |
| 77 | for _, mlp_module in text_encoder_mlp_modules(text_encoder): |
| 78 | if isinstance(mlp_module.fc1, PatchedLoraProjection): |
| 79 | mlp_module.fc1.lora_scale = lora_scale |
| 80 | mlp_module.fc2.lora_scale = lora_scale |
| 81 | |
| 82 | |
| 83 | class PatchedLoraProjection(torch.nn.Module): |
no test coverage detected