Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Fix three CI failures that were not the PRs they failed on (#10896)
Daniel Hanec3dd7f976f9
diff --git a/studio/backend/hub/services/models/account_access.py b/studio/backend/hub/services/models/account_access.pyindex 184dfe07f64..2e7bd278376 100644--- a/studio/backend/hub/services/models/account_access.py+++ b/studio/backend/hub/services/models/account_access.py@@ -375,6 +375,22 @@ def hidden_chat_status_response():return JSONResponse(content = {"loaded": [], "loading": [], "yours": False})+def hidden_generate_progress_response(response_model):+ """The generate-progress shape, idle, with nothing of the resident.++ A generate-progress route declares ``active``/``fraction``/..., and a returned+ ``Response`` bypasses that model, so answering ``hidden_resident_response()``+ there hands a poller an object with no ``active`` at all. ``progress["active"]``+ then raises ``KeyError`` instead of reading "nothing is running", which is what+ the caller is entitled to learn either way. The model's own defaults ARE idle,+ so they reveal exactly as little as the loaded/yours pair and stay in step with+ the declared shape on their own.+ """+ return JSONResponse(+ content = {**response_model().model_dump(mode = "json"), "loaded": True, "yours": False}+ )++def gpu_busy_error(path: str | None = None) -> HTTPException:from core.inference import gpu_arbiterfrom state import active_generationsdiff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.pyindex 4e8c2645ba1..559dd5b3c4e 100644--- a/studio/backend/routes/inference.py+++ b/studio/backend/routes/inference.py@@ -36767,10 +36767,10 @@ async def diffusion_load_progress(current_subject: str = Depends(get_current_sub@studio_router.get("/images/generate-progress", response_model = DiffusionGenerateProgressResponse)async def diffusion_generate_progress(current_subject: str = Depends(get_current_subject)):if account_access.managed_account() and account_access.generation_is_foreign("diffusion"):- return account_access.hidden_resident_response()+ return account_access.hidden_generate_progress_response(DiffusionGenerateProgressResponse)mine = account_access.generation_is_mine("diffusion")if not mine and account_access.resident_hidden("diffusion"):- return account_access.hidden_resident_response()+ return account_access.hidden_generate_progress_response(DiffusionGenerateProgressResponse)from core.inference.diffusion_engine_router import get_active_diffusion_engineif (@@ -36780,7 +36780,7 @@ async def diffusion_generate_progress(current_subject: str = Depends(get_current"diffusion", get_active_diffusion_engine().status().get("repo_id"))):- return account_access.hidden_resident_response()+ return account_access.hidden_generate_progress_response(DiffusionGenerateProgressResponse)progress = get_active_diffusion_engine().generate_progress()log_media_generation_progress("image", progress)diff --git a/studio/backend/routes/video.py b/studio/backend/routes/video.pyindex a145d9e0bc8..fefa454d5a3 100644--- a/studio/backend/routes/video.py+++ b/studio/backend/routes/video.py@@ -636,11 +636,11 @@ async def video_generate_progress(current_subject: str = Depends(get_current_subwith _generation_lock:started_by = _generation_accountif _generation_hidden(backend, started_by):- return account_access.hidden_resident_response()+ return account_access.hidden_generate_progress_response(VideoGenerateProgressResponse)progress = _read_generate_progress(backend, reserved)if progress is None:# The reservation changed hands mid-poll; the successor's progress is not ours to see.- return account_access.hidden_resident_response()+ return account_access.hidden_generate_progress_response(VideoGenerateProgressResponse)log_media_generation_progress("video", progress)return VideoGenerateProgressResponse(**progress)diff --git a/studio/backend/tests/conftest.py b/studio/backend/tests/conftest.pyindex 9047eddde5b..ef86ae43004 100644--- a/studio/backend/tests/conftest.py+++ b/studio/backend/tests/conftest.py@@ -292,6 +292,25 @@ def _hf_cache_is_empty(_empty_hf_hub_cache, monkeypatch):monkeypatch.setattr(constants, "HF_HUB_CACHE", _empty_hf_hub_cache)[email protected](autouse = True)+def _no_leftover_generation_account(monkeypatch):+ """Clear the media-generation owner, which is a process global no route ever resets.++ ``routes.video._note_generation_account()`` records who started a generation and+ nothing writes it back to ``None``, so any test that POSTs a generate leaves the+ next test's poll looking like a foreign account's job -- the progress route then+ answers the hidden shape, and an unrelated test dies on ``KeyError: 'active'``+ somewhere else in the run. Six files already reset this by hand; doing it here+ covers the rest, and the six keep their explicit version because there it IS the+ thing under test.+ """+ # sys.modules, not an import: a module nothing imported has no global to leak.+ routes_video = sys.modules.get("routes.video")+ if routes_video is None:+ return+ monkeypatch.setattr(routes_video, "_generation_account", None, raising = False)++@pytest.fixture(autouse = True)def _assume_bare_metal(monkeypatch):"""Pin the virtualised-Metal detector off so the suite is host independent.diff --git a/studio/backend/tests/test_account_inference_isolation.py b/studio/backend/tests/test_account_inference_isolation.pyindex 419fc55e7bc..e0708497ab8 100644--- a/studio/backend/tests/test_account_inference_isolation.py+++ b/studio/backend/tests/test_account_inference_isolation.py@@ -499,9 +499,13 @@ def test_private_cpu_media_residents_hide_progress_and_refuse_generation_and_unl"org/private",)with client_for(BOB) as client:- for path in ["load-progress", "generate-progress"]:- response = client.get(f"/api/inference/{kind}/{path}")- assert response.json() == {"loaded": True, "yours": False}+ assert client.get(f"/api/inference/{kind}/load-progress").json() == {+ "loaded": True,+ "yours": False,+ }+ # Hidden, but still the declared shape: `active` reads false, not KeyError.+ hidden = client.get(f"/api/inference/{kind}/generate-progress").json()+ assert hidden["yours"] is False and hidden["active"] is False, hiddenresponse = client.post(f"/api/inference/{kind}/generate", json = {"prompt": "hello"})assert response.status_code == 404, response.textassert client.post(f"/api/inference/{kind}/unload").status_code == 404diff --git a/studio/backend/tests/test_account_media_generation_owner.py b/studio/backend/tests/test_account_media_generation_owner.pyindex 67cafe9d867..8dbc450be13 100644--- a/studio/backend/tests/test_account_media_generation_owner.py+++ b/studio/backend/tests/test_account_media_generation_owner.py@@ -121,10 +121,9 @@ def test_the_model_loader_cannot_see_or_cancel_another_accounts_generation(sharethread, result = _start_alice_generation(shared_resident)try:with client_for(BOB) as client:- assert client.get("/api/inference/images/generate-progress").json() == {- "loaded": True,- "yours": False,- }+ hidden = client.get("/api/inference/images/generate-progress").json()+ assert hidden["yours"] is False, hidden+ assert hidden["active"] is False and hidden["step"] == 0, hiddenassert client.post("/api/inference/images/generate/cancel").json() == {"cancelled": False}@@ -147,10 +146,9 @@ def test_residency_still_governs_progress_and_cancel_with_no_generation_in_flighmonkeypatch.setattr(gpu_arbiter, "_owner", "diffusion")monkeypatch.setattr(gpu_arbiter, "_owner_account", BOB.account_id)with client_for(ALICE) as client:- assert client.get("/api/inference/images/generate-progress").json() == {- "loaded": True,- "yours": False,- }+ hidden = client.get("/api/inference/images/generate-progress").json()+ assert hidden["yours"] is False, hidden+ assert hidden["active"] is False and hidden["step"] == 0, hiddenassert client.post("/api/inference/images/generate/cancel").json() == {"cancelled": False}with client_for(BOB) as client:assert client.get("/api/inference/images/generate-progress").json()["active"] is False@@ -183,10 +181,9 @@ def test_openai_image_generations_belong_to_the_account_that_started_them(sharedprogress = client.get("/api/inference/images/generate-progress").json()assert progress["active"] is True and progress["step"] == 3with client_for(BOB) as client:- assert client.get("/api/inference/images/generate-progress").json() == {- "loaded": True,- "yours": False,- }+ hidden = client.get("/api/inference/images/generate-progress").json()+ assert hidden["yours"] is False, hidden+ assert hidden["active"] is False and hidden["step"] == 0, hiddenassert client.post("/api/inference/images/generate/cancel").json() == {"cancelled": False}diff --git a/studio/backend/tests/test_account_media_generation_slot.py b/studio/backend/tests/test_account_media_generation_slot.pyindex 7210fe0598e..be1b091b2a1 100644--- a/studio/backend/tests/test_account_media_generation_slot.py+++ b/studio/backend/tests/test_account_media_generation_slot.py@@ -118,10 +118,9 @@ def test_a_queued_request_does_not_take_progress_and_cancel_from_the_active_genebob = _post_generate(BOB, engine, results, "bob")try:with client_for(BOB) as client:- assert client.get("/api/inference/images/generate-progress").json() == {- "loaded": True,- "yours": False,- }+ hidden = client.get("/api/inference/images/generate-progress").json()+ assert hidden["yours"] is False, hidden+ assert hidden["active"] is False and hidden["step"] == 0, hiddenassert client.post("/api/inference/images/generate/cancel").json() == {"cancelled": False}diff --git a/studio/backend/tests/test_account_media_resident_authorization.py b/studio/backend/tests/test_account_media_resident_authorization.pyindex f0e3b6fd711..51d08383ee2 100644--- a/studio/backend/tests/test_account_media_resident_authorization.py+++ b/studio/backend/tests/test_account_media_resident_authorization.py@@ -348,10 +348,9 @@ def test_the_gallery_persist_window_still_belongs_to_the_generating_account(monkprogress = client.get("/api/inference/images/generate-progress").json()assert progress["active"] is Truewith client_for(BOB) as client:- assert client.get("/api/inference/images/generate-progress").json() == {- "loaded": True,- "yours": False,- }+ hidden = client.get("/api/inference/images/generate-progress").json()+ assert hidden["yours"] is False, hidden+ assert hidden["active"] is False and hidden["step"] == 0, hiddenfinally:release.set()thread.join(20)diff --git a/studio/backend/tests/test_account_video_generation_owner.py b/studio/backend/tests/test_account_video_generation_owner.pyindex 988f3d53570..80a07a0cd5d 100644--- a/studio/backend/tests/test_account_video_generation_owner.py+++ b/studio/backend/tests/test_account_video_generation_owner.py@@ -114,6 +114,18 @@ def _client(account):return TestClient(app)+def _assert_reveals_no_clip(body):+ """A foreign poller gets the declared idle progress shape and nothing of the job.++ Spelled out rather than compared to a literal dict: the route answers the+ generate-progress shape here, so a poller can still read ``active`` off it, and+ what this test is actually about is that none of the clip comes back.+ """+ assert body["yours"] is False, body+ assert body["active"] is False and body["phase"] is None, body+ assert body.get("video") is None, body++def test_the_starting_account_owns_its_clip_and_the_models_loader_does_not(backend):generate = "/api/inference/video/generate"progress = "/api/inference/video/generate-progress"@@ -125,7 +137,7 @@ def test_the_starting_account_owns_its_clip_and_the_models_loader_does_not(backeassert client.get(progress).json()["video"]["prompt"] == CLIP["prompt"]with _client(ALICE) as client:- assert client.get(progress).json() == {"loaded": True, "yours": False}+ _assert_reveals_no_clip(client.get(progress).json())assert client.post(cancel).json() == {"cancelled": False}assert backend.cancelled == []@@ -153,7 +165,7 @@ def test_a_clip_started_on_the_openai_route_belongs_to_that_account_too(backend)assert client.get(progress).json()["video"]["prompt"] == CLIP["prompt"]with _client(ALICE) as client:- assert client.get(progress).json() == {"loaded": True, "yours": False}+ _assert_reveals_no_clip(client.get(progress).json())assert client.post(cancel).json() == {"cancelled": False}assert backend.cancelled == []@@ -171,6 +183,6 @@ def test_the_installation_owner_does_not_see_a_managed_accounts_clip(backend):assert client.get(progress).json()["video"]["prompt"] == CLIP["prompt"]with _client(OWNER) as client:- assert client.get(progress).json() == {"loaded": True, "yours": False}+ _assert_reveals_no_clip(client.get(progress).json())assert client.post(cancel).json() == {"cancelled": False}assert backend.cancelled == []diff --git a/studio/backend/tests/test_account_video_generation_reservation.py b/studio/backend/tests/test_account_video_generation_reservation.pyindex 2bc61f7277e..dda98defc8a 100644--- a/studio/backend/tests/test_account_video_generation_reservation.py+++ b/studio/backend/tests/test_account_video_generation_reservation.py@@ -138,7 +138,9 @@ def test_ownership_holds_from_the_reservation_not_from_the_end_of_begin_generateassert backend.reserved.wait(20)with _client(ALICE) as client:assert client.post(cancel).json() == {"cancelled": False}- assert client.get(progress).json() == {"loaded": True, "yours": False}+ hidden = client.get(progress).json()+ assert hidden["yours"] is False and hidden["active"] is False, hidden+ assert hidden.get("video") is None, hiddenassert backend.cancelled == []with _client(BOB) as client:assert client.get(progress).json()["video"]["prompt"] == CLIP["prompt"]diff --git a/studio/backend/tests/test_account_video_progress_handoff.py b/studio/backend/tests/test_account_video_progress_handoff.pyindex fc300118f25..1a1bacdf488 100644--- a/studio/backend/tests/test_account_video_progress_handoff.py+++ b/studio/backend/tests/test_account_video_progress_handoff.py@@ -150,7 +150,37 @@ def test_progress_does_not_follow_a_reservation_that_changed_hands(monkeypatch):assert backend.job_account == BOB.account_idassert body.get("video_id") != "bob-clip", "alice received bob's job progress"- assert body == {"loaded": True, "yours": False}+ assert body["yours"] is False, body+ assert body["active"] is False and body["phase"] is None, body+ assert body.get("video") is None, body+++def test_a_hidden_poll_still_answers_the_shape_the_route_declares(monkeypatch):+ """Hiding a job must not change the OBJECT the poller gets back.++ ``/video/generate-progress`` declares ``VideoGenerateProgressResponse``, but a+ returned ``Response`` bypasses that model, so answering the loaded/yours pair here+ handed callers something with no ``active`` at all. The Video page polls this on a+ timer and reads ``active`` unconditionally; so did the suite, which is how an+ unrelated test came to die on ``KeyError: 'active'`` whenever an earlier test left+ ``routes.video._generation_account`` set.+ """+ from models.inference import VideoGenerateProgressResponse++ backend = HandoffVideoBackend(hand_off = True)+ _install(monkeypatch, backend)++ with _client(ALICE) as client:+ body = client.get(PROGRESS).json()++ for field in VideoGenerateProgressResponse.model_fields:+ assert field in body, f"hidden poll dropped {field!r} from the declared shape: {body}"+ # Every declared field is at its idle default, so the shape costs no privacy.+ assert body == {+ **VideoGenerateProgressResponse().model_dump(mode = "json"),+ "loaded": True,+ "yours": False,+ }def test_progress_still_returns_the_owners_own_terminal_record(monkeypatch):diff --git a/studio/backend/tests/test_video_shape_validation.py b/studio/backend/tests/test_video_shape_validation.pyindex 1c007a70905..34c0e0fb4da 100644--- a/studio/backend/tests/test_video_shape_validation.py+++ b/studio/backend/tests/test_video_shape_validation.py@@ -356,6 +356,11 @@ def test_generate_rejects_256x256_with_422_naming_the_presets(client, backend):assert "768x512" in detail and "1216x704" in detail# Rejected AT THE BOUNDARY: no job was started, so the backend is still idle.progress = client.get("/api/inference/video/generate-progress").json()+ # Named, not subscripted: a bare KeyError names neither the gate nor the leaked global.+ assert "active" in progress, (+ f"generate-progress answered {progress}, which is not the declared shape -- the "+ "account gate hid the poll (see routes.video._generation_hidden)"+ )assert progress["active"] is False and progress.get("phase") is Nonediff --git a/tests/kaggle/test_t4_payload_assertions.py b/tests/kaggle/test_t4_payload_assertions.pyindex a2384fafb56..12eca6310f1 100644--- a/tests/kaggle/test_t4_payload_assertions.py+++ b/tests/kaggle/test_t4_payload_assertions.py@@ -399,7 +399,8 @@ def test_an_adapter_peft_would_ignore_on_reload_does_not_pass(tmp_path):assert failures, "the leg would have passed an adapter that reloads to the base model"assert "ignores them silently" in " ".join(failures)- reloaded = PeftModel.from_pretrained(_base(), str(tmp_path))+ # Explicit: PEFT's infer_device() believes tests/_zoo_aggressive_cuda_spoof.py.+ reloaded = PeftModel.from_pretrained(_base(), str(tmp_path), torch_device = "cpu")b_matrices = [p for n, p in reloaded.named_parameters() if "lora_B" in n]assert b_matrices and all(float(p.abs().sum()) == 0.0 for p in b_matrices), ("peft loaded the renamed keys after all, so this test no longer describes "diff --git a/tests/python/test_accelerator_skip_guards.py b/tests/python/test_accelerator_skip_guards.pyindex 0368a219741..e57951ca1f3 100644--- a/tests/python/test_accelerator_skip_guards.py+++ b/tests/python/test_accelerator_skip_guards.py@@ -52,6 +52,15 @@ _SPOOFED_CALLS = {("torch", "accelerator", "is_available"),}+# The other half of the hazard above: a skip guard decides whether a test RUNS, these+# decide where its tensors LAND, because the library reads the same spoofed probe itself.+# An allow-list, not a general lint: catch another instance of this, not every loader call.+_DEVICE_INFERRING_CALLS = {+ ("PeftModel", "from_pretrained"): "torch_device",+ ("PeftMixedModel", "from_pretrained"): "torch_device",+ ("load_peft_weights",): "device",+}+def _dotted(node: ast.AST) -> tuple[str, ...]:parts: list[str] = []@@ -109,6 +118,55 @@ def test_no_skip_guard_reads_a_spoofable_accelerator_probe():)+def _device_inferring_calls(tree: ast.AST):+ """Every call in the module that lets a library resolve the device from the spoof."""+ for node in ast.walk(tree):+ if not isinstance(node, ast.Call):+ continue+ name = _dotted(node.func)+ for suffix, keyword in _DEVICE_INFERRING_CALLS.items():+ if name[-len(suffix) :] == suffix:+ given = {kw.arg for kw in node.keywords if kw.arg}+ if keyword not in given:+ yield node, ".".join(name), keyword+++def test_no_test_lets_a_loader_infer_the_device_from_a_spoofed_probe():+ offenders = []+ for path in _python_test_files():+ try:+ tree = ast.parse(path.read_text(encoding = "utf-8"))+ except SyntaxError:+ continue+ for node, name, keyword in _device_inferring_calls(tree):+ offenders.append(+ f"{path.relative_to(_TESTS_ROOT)}:{node.lineno}: {name}() with no {keyword}="+ )+ assert not offenders, (+ "these calls let the library pick the device, and it picks it off a probe "+ "tests/_zoo_aggressive_cuda_spoof.py patches to True process-wide. On a CPU-only "+ "runner the load then dispatches to a CUDA backend that is not there. Pass the "+ "device: `torch_device = 'cuda' if has_real_accelerator() else 'cpu'`, or plain "+ "'cpu' when the test does not care:\n " + "\n ".join(offenders)+ )+++def test_the_device_scanner_would_catch_a_regression(tmp_path):+ """Not vacuous: the forbidden shape must trip it and the fixed shape must not."""+ bad = ast.parse(+ "from peft import PeftModel\n\n\n"+ "def test_x(base, path):\n PeftModel.from_pretrained(base, path)\n"+ )+ assert len(list(_device_inferring_calls(bad))) == 1++ good = ast.parse(+ "from peft import PeftModel\n\n\n"+ "def test_x(base, path):\n"+ " PeftModel.from_pretrained(base, path, torch_device = 'cpu')\n"+ )+ assert list(_device_inferring_calls(good)) == []++_SURVIVES_THE_SPOOF_PROBE = textwrap.dedent("""import json, sysdiff --git a/tests/python/test_rl_config_pickling.py b/tests/python/test_rl_config_pickling.pyindex 456b9b91d54..cef45ec80dc 100644--- a/tests/python/test_rl_config_pickling.py+++ b/tests/python/test_rl_config_pickling.py@@ -15,6 +15,7 @@ exists beside a compiled cache.from __future__ import annotations+import dataclassesimport jsonimport osimport pickle@@ -35,12 +36,29 @@ def patched():def _make(config_class, output_dir):- return config_class(- output_dir = str(output_dir),- bf16 = False,- fp16 = False,- use_cpu = True,+ """Build `config_class` pinned to CPU, asking only for the knobs it declares.++ The precision flags are not decoration. TRL resolves `bf16 = None` to True in+ `__post_init__`, and transformers then refuses on a machine with no accelerator:++ ValueError: Your setup doesn't support bf16/gpu. You need to assign use_cpu+ if you want to train the model on CPU.++ None of these tests are about precision or hardware, so a CPU-only runner must+ not be able to answer them. Filtered against the declared fields rather than+ passed blind, because the sweep below hands this every `trl.*Config` there is and+ they do not all take the same three.+ """+ kwargs = {"output_dir": str(output_dir)}+ declared = (+ {field.name for field in dataclasses.fields(config_class)}+ if dataclasses.is_dataclass(config_class)+ else None)+ for name, value in (("bf16", False), ("fp16", False), ("use_cpu", True)):+ if declared is None or name in declared:+ kwargs[name] = value+ return config_class(**kwargs)def test_patched_config_answers_to_the_trl_name(patched):@@ -177,8 +195,9 @@ def test_every_patched_config_pickles_portably(tmp_path):if not isinstance(config_class, type):continuetry:- args = config_class(output_dir = str(tmp_path))+ args = _make(config_class, tmp_path)except TypeError:+ # Not a config that takes an output_dir; nothing to pickle.continuepickle.dumps(args, protocol = 2)assert not config_class.__module__.startswith("Unsloth"), (@@ -189,9 +208,29 @@ def test_every_patched_config_pickles_portably(tmp_path):assert checked > 0, "no TRL configs were exercised"+def _assert_the_patch_applied(patched):+ """Fail by naming the patcher, not by naming what the patcher would have built.++ `_patch_trl_rl_trainers` (unsloth/models/rl.py) swallows a failed source anchor+ into a warning and returns, leaving `trl.SFTConfig` pristine. Every assertion+ below then reads the UNPATCHED class and reports something true but useless --+ `assert 'TrainingArguments' == 'SFTConfig'`, which is just the pristine config's+ own base. That is how zoo #1192's added `# noqa` comment (fixed in #10854) read+ from here, and the message pointed at neither repo. Same check, same reason, as+ `_fake_sft_self` in tests/utils/test_packing.py.+ """+ assert getattr(patched, "_unsloth_patched_rl_config", False), (+ f"trl.SFTConfig is {patched.__name__!r} from {patched.__module__!r} but carries "+ "no _unsloth_patched_rl_config, so Unsloth's RL patch fell back and these tests "+ "are describing TRL's own class. `import unsloth` reports the cause as a warning "+ "(_patch_trl_rl_trainers in unsloth/models/rl.py), not an error."+ )++def test_patched_config_still_subclasses_the_pristine_one(patched):"""The generated class is renamed onto TRL's name, which must not tempt alater patching pass into making it its own base."""+ _assert_the_patch_applied(patched)base = patched.__mro__[1]assert base is not patchedassert base.__name__ == "SFTConfig"diff --git a/tests/test_save_lora_without_vllm.py b/tests/test_save_lora_without_vllm.pyindex 334785f018c..7c55d14258c 100644--- a/tests/test_save_lora_without_vllm.py+++ b/tests/test_save_lora_without_vllm.py@@ -29,6 +29,9 @@ import astimport pathlibimport pytest+from real_accelerator import (+ has_real_accelerator,+) # tests/_shared, on sys.path via tests/conftest.py_UTILS = pathlib.Path(__file__).resolve().parents[1] / "unsloth" / "models" / "_utils.py"@@ -209,7 +212,13 @@ def test_the_saved_adapter_still_loads_back(tmp_path):base = transformers.AutoModelForCausalLM.from_pretrained("hf-internal-testing/tiny-random-LlamaForCausalLM", dtype = torch.float16)- reloaded = peft.PeftModel.from_pretrained(base, str(directory))+ # Say the device: peft.utils.other.infer_device() answers "cuda" off+ # torch.cuda.is_available(), which tests/_zoo_aggressive_cuda_spoof.py spoofs True.+ reloaded = peft.PeftModel.from_pretrained(+ base,+ str(directory),+ torch_device = "cuda" if has_real_accelerator() and torch.cuda.is_available() else "cpu",+ )assert reloaded is not None