Skip to content

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.

Tests: name the encoding in the gloo export guard, and treat a bare device index as CUDA in the YaRN load check (#15351)

Daniel Hanba161f54fa24
diff --git a/tests/test_parallel_general_gloo.py b/tests/test_parallel_general_gloo.py
index 18f3b6eab69..fb7628d8293 100644
--- a/tests/test_parallel_general_gloo.py
+++ b/tests/test_parallel_general_gloo.py
@@ -729,7 +729,8 @@ def test_every_whole_model_export_is_guarded():
"""Static: every export patch_saving_functions binds, and every writer behind them, refuses TP / PP first."""
import ast
- tree = ast.parse(open(os.path.join(REPO, "unsloth", "save.py")).read())
+ with open(os.path.join(REPO, "unsloth", "save.py"), encoding = "utf-8") as f:
+ tree = ast.parse(f.read())
functions = {n.name: n for n in tree.body if isinstance(n, ast.FunctionDef)}
bound = set()
for node in ast.walk(functions["patch_saving_functions"]):
diff --git a/tests/test_yarn_rope_parameters_load.py b/tests/test_yarn_rope_parameters_load.py
index 6c63dad3767..9e0a7701e37 100644
--- a/tests/test_yarn_rope_parameters_load.py
+++ b/tests/test_yarn_rope_parameters_load.py
@@ -29,7 +29,11 @@ import _zoo_aggressive_cuda_spoof as _spoof
_spoof.apply()
import torch
import unsloth
-_is_cuda = lambda d: isinstance(d, (str, int, torch.device)) and not isinstance(d, bool) and torch.device(d).type == "cuda"
+# A bare index is a CUDA ordinal here (get_current_device() returns one). torch.device(0) resolves it
+# through the accelerator, which raises on a CPU-only torch, so it is not asked.
+_is_cuda = lambda d: (isinstance(d, int) and not isinstance(d, bool)) or (
+ isinstance(d, (str, torch.device)) and torch.device(d).type == "cuda"
+)
for _name in ("empty", "zeros", "ones", "full", "tensor", "arange", "randn", "rand", "randint",
"empty_like", "zeros_like", "ones_like"):
_orig = getattr(torch, _name)