From cd0aee97a022619fa23be0a5628c4b13f2af6a36 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 18 Jul 2026 03:16:18 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unsloth/save.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/unsloth/save.py b/unsloth/save.py index 353a1ce948..a6a4699eac 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -1153,9 +1153,10 @@ def unsloth_save_model( state_dict[f"model.layers.{j}.{item}.bias"] = bias _dev_budget = _device_vram_budget(W.device) - if _dev_budget is not None and ( - torch.cuda.memory_allocated(W.device) + W.nbytes - ) < _dev_budget: + if ( + _dev_budget is not None + and (torch.cuda.memory_allocated(W.device) + W.nbytes) < _dev_budget + ): # Fits on W's own GPU -> keep it there. state_dict[name] = W elif W.device.type != "cuda":