MCPcopy
hub / github.com/huggingface/diffusers / scale_lora_layers

Function scale_lora_layers

src/diffusers/utils/peft_utils.py:106–123  ·  view source on GitHub ↗

Adjust the weightage given to the LoRA layers of the model. Args: model (`torch.nn.Module`): The model to scale. weight (`float`): The weight to be given to the LoRA layers.

(model, weight)

Source from the content-addressed store, hash-verified

104
105
106def scale_lora_layers(model, weight):
107 """
108 Adjust the weightage given to the LoRA layers of the model.
109
110 Args:
111 model (`torch.nn.Module`):
112 The model to scale.
113 weight (`float`):
114 The weight to be given to the LoRA layers.
115 """
116 from peft.tuners.tuners_utils import BaseTunerLayer
117
118 if weight == 1.0:
119 return
120
121 for module in model.modules():
122 if isinstance(module, BaseTunerLayer):
123 module.scale_layer(weight)
124
125
126def unscale_lora_layers(model, weight: float | None = None):

Callers 15

encode_promptMethod · 0.90
encode_promptMethod · 0.90
encode_promptMethod · 0.90
encode_promptMethod · 0.90
encode_promptMethod · 0.90
forwardMethod · 0.90
encode_promptMethod · 0.90
encode_promptMethod · 0.90
encode_promptMethod · 0.90
forwardMethod · 0.90
forwardMethod · 0.90
encode_promptMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…