MCPcopy Index your code
hub / github.com/huggingface/diffusers / text_encoder_lora_state_dict

Function text_encoder_lora_state_dict

src/diffusers/loaders/__init__.py:7–28  ·  view source on GitHub ↗
(text_encoder)

Source from the content-addressed store, hash-verified

5
6
7def 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
31if is_transformers_available():

Callers

nothing calls this directly

Calls 3

deprecateFunction · 0.85
state_dictMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…