(text_encoder)
| 5 | |
| 6 | |
| 7 | def text_encoder_lora_state_dict(text_encoder): |
| 8 | deprecate( |
| 9 | "text_encoder_load_state_dict in `models`", |
| 10 | "0.27.0", |
| 11 | "`text_encoder_lora_state_dict` is deprecated and will be removed in 0.27.0. Make sure to retrieve the weights using `get_peft_model`. See https://huggingface.co/docs/peft/v0.6.2/en/quicktour#peftmodel for more information.", |
| 12 | ) |
| 13 | state_dict = {} |
| 14 | |
| 15 | for name, module in text_encoder_attn_modules(text_encoder): |
| 16 | for k, v in module.q_proj.lora_linear_layer.state_dict().items(): |
| 17 | state_dict[f"{name}.q_proj.lora_linear_layer.{k}"] = v |
| 18 | |
| 19 | for k, v in module.k_proj.lora_linear_layer.state_dict().items(): |
| 20 | state_dict[f"{name}.k_proj.lora_linear_layer.{k}"] = v |
| 21 | |
| 22 | for k, v in module.v_proj.lora_linear_layer.state_dict().items(): |
| 23 | state_dict[f"{name}.v_proj.lora_linear_layer.{k}"] = v |
| 24 | |
| 25 | for k, v in module.out_proj.lora_linear_layer.state_dict().items(): |
| 26 | state_dict[f"{name}.out_proj.lora_linear_layer.{k}"] = v |
| 27 | |
| 28 | return state_dict |
| 29 | |
| 30 | |
| 31 | if is_transformers_available(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…