From bf3171e567172d7dad6a086dfa52845d01aa920f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 Apr 2026 14:43:14 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- unsloth/models/llama.py | 7 ++++--- unsloth/models/vision.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index 98f25c7dc7..0913cf9de2 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -2494,12 +2494,13 @@ class FastLlamaModel: # loads. The bnb loading path places weights on CUDA devices but # never calls dispatch_model, so no hooks are installed. from unsloth.models.vision import _attach_bnb_multidevice_hooks + _attach_bnb_multidevice_hooks( model, - load_in_4bit = load_in_4bit, - load_in_8bit = False, + load_in_4bit = load_in_4bit, + load_in_8bit = False, offload_embedding = False, - fast_inference = False, + fast_inference = False, ) model.fast_generate = make_fast_generate_wrapper(model.generate) model.fast_generate_batches = None diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py index 76a74631b1..376e00a1fa 100644 --- a/unsloth/models/vision.py +++ b/unsloth/models/vision.py @@ -236,7 +236,8 @@ def _attach_bnb_multidevice_hooks( # so torch.device("cpu") must become "cpu", not stay as an object. device_map_int = { k: (v.index if v.type == "cuda" else v.type) - if isinstance(v, torch.device) else v + if isinstance(v, torch.device) + else v for k, v in inferred_map.items() }