MCPcopy Create free account
hub / github.com/CERT-Lab/lora-sb / replace_module_weights

Function replace_module_weights

utils/initialization_utils.py:47–54  ·  view source on GitHub ↗
(target_module, new_weight)

Source from the content-addressed store, hash-verified

45
46
47def replace_module_weights(target_module, new_weight):
48 device = target_module.weight.device
49 target_module.weight = torch.nn.Parameter(new_weight)
50
51 # dispatch to correct device
52 for name, module in target_module.named_modules():
53 if "lora_" in name:
54 module.to(device)
55
56
57def update_decoder_weights(target_module, new_weight):

Callers 2

find_and_initialize_gradFunction · 0.85
find_and_initializeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected