From b599fdb197c6b80d3be334899b9e9620492656b9 Mon Sep 17 00:00:00 2001 From: Max Ryabinin Date: Wed, 14 Jun 2023 19:27:13 +0200 Subject: [PATCH] Only rearrange weight if it exists --- bitsandbytes/nn/modules.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bitsandbytes/nn/modules.py b/bitsandbytes/nn/modules.py index b806e94..b10d45a 100644 --- a/bitsandbytes/nn/modules.py +++ b/bitsandbytes/nn/modules.py @@ -307,7 +307,10 @@ class Int8Params(torch.nn.Parameter): def maybe_rearrange_weight(state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs): - weight = state_dict[f"{prefix}weight"] + weight = state_dict.get(f"{prefix}weight") + if weight is None: + # if the state dict has no weights for this layer (e.g., LoRA finetuning), do nothing + return weight_format = state_dict.pop(f"{prefix}weight_format", "row") if weight_format != "row":