MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / HackLinearNF4

Class HackLinearNF4

SwissArmyTransformer/sat/model/finetune/lora2.py:46–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 else:
45 dst[i] = src[i]
46 class HackLinearNF4(LinearNF4):
47 def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs):
48 if prefix + 'weight' in state_dict:
49 self.weight.data.copy_(state_dict[prefix+'weight'])
50 if self.weight.data.dtype == torch.uint8:
51 copy_nested_list(state_dict[prefix+'quant_state'], self.weight.quant_state)
52 if prefix + 'bias' in state_dict:
53 self.bias.data.copy_(state_dict[prefix+'bias'])
54 def _save_to_state_dict(self, destination, prefix, keep_vars):
55 super()._save_to_state_dict(destination, prefix, keep_vars)
56 destination[prefix+'quant_state'] = self.weight.quant_state
57except Exception as exception:
58 print_all("Failed to load bitsandbytes:" + str(exception), level='WARNING')
59

Callers 3

__init__Method · 0.85
merge_linear_loraFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected