[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2026-04-16 14:43:14 +00:00
commit bf3171e567
2 changed files with 6 additions and 4 deletions

View file

@ -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

View file

@ -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()
}