Compare commits

...

3 Commits

Author SHA1 Message Date
f3d6d7e93f Merge branch 'main' into fix-quantizer 2025-03-31 14:48:34 +02:00
85b20d4208 bnb 4bitz 2025-03-31 12:14:28 +02:00
00c6e5fea3 hqq 2025-03-31 12:08:30 +02:00
2 changed files with 6 additions and 2 deletions

View File

@ -216,7 +216,9 @@ class Bnb4BitHfQuantizer(HfQuantizer):
quantized_stats = {}
for k, v in state_dict.items():
if param_name + "." in k:
quantized_stats[k] = v
# the state dict may be loaded on meta -> move back to cpu in this case
param = torch.empty_like(v, device="cpu") if v.device.type == "meta" else v
quantized_stats[k] = param
if unexpected_keys is not None and k in unexpected_keys:
unexpected_keys.remove(k)

View File

@ -214,7 +214,9 @@ class HqqHfQuantizer(HfQuantizer):
module_state_dict = {}
for k, v in state_dict.items():
if layer_name + "." in k:
module_state_dict[k.split(".")[-1]] = v
# the state dict may be loaded on meta -> move back to cpu in this case
param = torch.empty_like(v, device="cpu") if v.device.type == "meta" else v
module_state_dict[k.split(".")[-1]] = param
if unexpected_keys is not None and k in unexpected_keys:
unexpected_keys.remove(k)