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.

Fix llama.cpp loading for Unicode Windows profiles (#8852)

Lee Jackson845a20087f76
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index 9b3467cd909..bba8c3433c5 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -19702,9 +19702,22 @@ class LlamaCppBackend:
# Saved KV encodes chat content; keep it from other local users.
with contextlib.suppress(OSError):
os.chmod(slot_dir, 0o700)
- cmd.extend(["--slot-save-path", str(slot_dir)])
- self._slot_save_dir = str(slot_dir)
- self._slot_save_binary = (binary, Path(binary).stat().st_mtime_ns)
+ slot_path = str(slot_dir)
+ # llama.cpp's fs_is_directory() constructs a narrow
+ # std::filesystem::path on Windows, so an existing UTF-8
+ # path such as C:\Users\Егор is rejected as missing.
+ # Slot persistence is optional; keep model loading available
+ # until the managed runtime carries the upstream UTF-8 fix.
+ if sys.platform == "win32" and not slot_path.isascii():
+ logger.warning(
+ "Disabling llama.cpp slot persistence because its "
+ "Windows path contains non-ASCII characters: %s",
+ slot_path,
+ )
+ else:
+ cmd.extend(["--slot-save-path", slot_path])
+ self._slot_save_dir = slot_path
+ self._slot_save_binary = (binary, Path(binary).stat().st_mtime_ns)
except OSError:
self._slot_save_dir = None
self._slot_save_binary = None
diff --git a/studio/backend/tests/test_llama_extra_args_platforms.py b/studio/backend/tests/test_llama_extra_args_platforms.py
index d04e538c884..3d9068efb6c 100644
--- a/studio/backend/tests/test_llama_extra_args_platforms.py
+++ b/studio/backend/tests/test_llama_extra_args_platforms.py
@@ -84,6 +84,53 @@ def _stable(cmd: list[str]) -> list[str]:
return masked
+def _launch_with_slot_dir(tmp_path, monkeypatch, platform, slot_dir: Path):
+ """Capture the real launch command with llama.cpp slot persistence advertised."""
+ _apply_platform(monkeypatch, platform)
+ from utils.paths import storage_roots
+
+ monkeypatch.setattr(storage_roots, "llama_slot_cache_root", lambda: slot_dir)
+ backend, gguf = _backend(tmp_path, vulkan = False, memory = [])
+ backend.probe_server_capabilities = lambda _binary = None: {"supports_slot_save": True}
+ return backend, _launch(backend, gguf)["cmd"]
+
+
+def _without_flag_value(cmd: list[str], flag: str) -> list[str]:
+ index = cmd.index(flag)
+ return [*cmd[:index], *cmd[index + 2 :]]
+
+
+def test_windows_unicode_slot_path_only_drops_optional_persistence(tmp_path, monkeypatch):
+ """A/B: all launch arguments survive; only the broken optional pair is absent."""
+ windows = PLATFORMS[2]
+ # Relative to tmp_path, because the predicate reads the WHOLE path: pytest's
+ # tmp_path lives under the profile, so on the very hosts this regression is about
+ # (C:\Users\Егор\AppData\Local\Temp) a tmp_path-rooted control arm is not ASCII
+ # either, both launches drop the flag, and the A/B stops comparing anything.
+ monkeypatch.chdir(tmp_path)
+ ascii_dir = Path("Egor") / "llama-slots"
+ unicode_dir = Path("Егор") / "llama-slots"
+
+ _ascii_backend, ascii_cmd = _launch_with_slot_dir(tmp_path, monkeypatch, windows, ascii_dir)
+ unicode_backend, unicode_cmd = _launch_with_slot_dir(
+ tmp_path, monkeypatch, windows, unicode_dir
+ )
+
+ assert ascii_cmd[ascii_cmd.index("--slot-save-path") + 1] == str(ascii_dir)
+ assert _stable(unicode_cmd) == _without_flag_value(_stable(ascii_cmd), "--slot-save-path")
+ assert unicode_backend._slot_save_dir is None
+ assert unicode_backend._slot_save_binary is None
+
+
[email protected]("platform", [PLATFORMS[0], PLATFORMS[1], PLATFORMS[3]])
+def test_unicode_slot_path_is_unchanged_off_native_windows(tmp_path, monkeypatch, platform):
+ slot_dir = tmp_path / "Егор" / "llama-slots"
+
+ _backend_instance, cmd = _launch_with_slot_dir(tmp_path, monkeypatch, platform, slot_dir)
+
+ assert cmd[cmd.index("--slot-save-path") + 1] == str(slot_dir)
+
+
@pytest.mark.parametrize("platform,accelerator", MATRIX)
def test_an_empty_box_changes_nothing_anywhere(tmp_path, monkeypatch, platform, accelerator):
# The acceptance bar, on every combination. None (inherit) and [] (explicitly