MCPcopy Create free account
hub / github.com/ZinYY/TreeLoRA / only_optimize_lora_parameters

Function only_optimize_lora_parameters

utils/module/lora.py:134–141  ·  view source on GitHub ↗
(model)

Source from the content-addressed store, hash-verified

132
133
134def only_optimize_lora_parameters(model):
135 # turn off the gradient of all the parameters except the LoRA parameters
136 for name, param in model.named_parameters():
137 if "lora_right_weight" in name or "lora_left_weight" in name:
138 param.requires_grad = True
139 else:
140 param.requires_grad = False
141 return model

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected