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

Function get_replacement_module_grad

utils/initialization_utils.py:25–34  ·  view source on GitHub ↗
(weight, type, reconstruct_config)

Source from the content-addressed store, hash-verified

23 return final_enc, final_dec
24
25def get_replacement_module_grad(weight, type, reconstruct_config):
26 cfg = reconstruct_config[type]
27 if type == 'svd':
28 Ur, Sr, Vrt = get_svd_grad(weight.detach(), cfg['rank'])
29 final_enc = torch.tensor(Ur, dtype=weight.dtype, device=weight.device)
30 final_dec = torch.tensor(Vrt, dtype=weight.dtype, device=weight.device)
31 Sr = torch.tensor(Sr, dtype=weight.dtype, device=weight.device)
32 else:
33 raise NotImplementedError(f"{type} is currently not supported.")
34 return final_enc, final_dec, Sr
35
36
37

Callers 1

find_and_initialize_gradFunction · 0.85

Calls 1

get_svd_gradFunction · 0.85

Tested by

no test coverage detected