MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / scale_lora_layers

Function scale_lora_layers

diffusers/src/diffusers/utils/peft_utils.py:103–120  ·  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

101
102
103def scale_lora_layers(model, weight):
104 """
105 Adjust the weightage given to the LoRA layers of the model.
106
107 Args:
108 model (`torch.nn.Module`):
109 The model to scale.
110 weight (`float`):
111 The weight to be given to the LoRA layers.
112 """
113 from peft.tuners.tuners_utils import BaseTunerLayer
114
115 if weight == 1.0:
116 return
117
118 for module in model.modules():
119 if isinstance(module, BaseTunerLayer):
120 module.scale_layer(weight)
121
122
123def unscale_lora_layers(model, weight: Optional[float] = 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
encode_promptMethod · 0.90
encode_promptMethod · 0.90
encode_promptMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected