From 33192d6dc8096135afa9ffc6d03ea0dfaba44f33 Mon Sep 17 00:00:00 2001 From: Daniel Han-Chen Date: Mon, 5 Feb 2024 18:05:25 +1100 Subject: [PATCH] Update save.py --- unsloth/save.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/unsloth/save.py b/unsloth/save.py index 30eaac92ff..70242eaa7b 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -102,8 +102,12 @@ def _merge_lora(layer, name, max_vram): pass W.addmm_(A.t().to(torch.float32), B.t().to(torch.float32), alpha = s) # if not torch.isfinite(W).all(): - if not torch.isfinite(torch.max(W.min().abs(), W.max())).item(): - raise ValueError(f"Unsloth: Merge failed.\n{name} has some elements = infinity.") + maximum_element = torch.max(W.min().abs(), W.max()) + if not torch.isfinite(maximum_element).item(): + raise ValueError( + f"Unsloth: Merge failed.\n{name} has some elements = infinity.\n"\ + f"For example the element {maximum_element.item()}" + ) pass W = W.t().to(dtype) else: