Skip to content

Commit b599fdb

Browse files
committed
Only rearrange weight if it exists
1 parent c1f3f56 commit b599fdb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bitsandbytes/nn/modules.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,10 @@ def to(self, *args, **kwargs):
307307

308308

309309
def maybe_rearrange_weight(state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs):
310-
weight = state_dict[f"{prefix}weight"]
310+
weight = state_dict.get(f"{prefix}weight")
311+
if weight is None:
312+
# if the state dict has no weights for this layer (e.g., LoRA finetuning), do nothing
313+
return
311314
weight_format = state_dict.pop(f"{prefix}weight_format", "row")
312315

313316
if weight_format != "row":

0 commit comments

Comments
 (0)