Skip to content

The agent that grows with you

feat(local-runtime): prefer llama.cpp b10964

emozillae9e363c85645
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.py
index a28d2789969..d3793035250 100644
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@ -2406,7 +2406,7 @@ DEFAULT_CONFIG = {
# Off = detection-only (Hermes still finds an external llama-server you run).
"enabled": False,
# Pinned llama.cpp release tag; bumped by Hermes releases after validation.
- "tag": "b10679",
+ "tag": "b10964",
# auto = CUDA on NVIDIA, Metal on macOS, Vulkan on other GPUs, else CPU. Explicit:
# cuda|metal|vulkan|hip|cpu.
"backend": "auto",
diff --git a/hermes_cli/local_runtime/binaries.py b/hermes_cli/local_runtime/binaries.py
index f7a4714fdb7..d18985646c2 100644
--- a/hermes_cli/local_runtime/binaries.py
+++ b/hermes_cli/local_runtime/binaries.py
@@ -156,6 +156,17 @@ def resolve_assets(tag: str, backend: str, os_name: str | None = None,
label, templates = _ASSET_TEMPLATES[os_name]
if backend not in templates:
raise BinaryResolutionError(f"unsupported {label} backend {backend}")
+ # release.yml switched both HIP names at b10356 (0666ad2b2b), then
+ # ROCm 7.14 -> 10.0 at b10767 (cff184438e). Keep older explicit pins.
+ if backend == "hip" and tag.startswith("b") and tag[1:].isascii() and tag[1:].isdigit():
+ build = int(tag[1:])
+ if build >= 10356:
+ if arch != "x64":
+ raise BinaryResolutionError(f"no {label} HIP {arch} asset at {tag}")
+ rocm_ver = "10.0" if build >= 10767 else "7.14"
+ extension = "zip" if os_name == "win" else "tar.gz"
+ return AssetPlan(tag, backend, [
+ f"llama-{tag}-bin-{os_name}-rocm-{rocm_ver}-{arch}.{extension}"])
cuda_ver = _WIN_CUDA_VERSION_ARM64 if arch == "arm64" else _WIN_CUDA_VERSION
return AssetPlan(tag, backend, [t.format(tag=tag, arch=arch, cuda_ver=cuda_ver)
for t in templates[backend]])
diff --git a/hermes_cli/local_runtime/supervisor.py b/hermes_cli/local_runtime/supervisor.py
index 1f20d1ac9bf..bbae27e6841 100644
--- a/hermes_cli/local_runtime/supervisor.py
+++ b/hermes_cli/local_runtime/supervisor.py
@@ -10,6 +10,7 @@ token, generous budget, reasoning_content scanned); always dial 127.0.0.1 — re
from __future__ import annotations
from contextlib import suppress
+from functools import lru_cache
import json
import logging
import secrets
@@ -92,6 +93,18 @@ def _stable_api_key() -> str:
return key
+@lru_cache(maxsize=16)
+def _direct_io_args(executable: Path) -> tuple[str, ...]:
+ """Select the loading option supported by this engine, including older pinned builds."""
+ result = subprocess.run([str(executable), "--help"], capture_output=True,
+ text=True, encoding="utf-8", errors="replace", check=True,
+ timeout=15, cwd=str(executable.parent))
+ help_text = result.stdout + result.stderr
+ if "--load-mode" in help_text:
+ return ("--load-mode", "dio")
+ return ("-dio",) if "--direct-io" in help_text else ()
+
+
class LlamaServerSupervisor:
"""Own one llama-server router process for the life of a Hermes session."""
@@ -168,7 +181,7 @@ class LlamaServerSupervisor:
"--jinja",
# Direct I/O on model load bypasses the page cache so a multi-GB load doesn't evict
# half the OS cache — measured faster on NVMe, and our router bounces reload often.
- "-dio",
+ *_direct_io_args(exe),
]
if self.preset_path and self.preset_path.exists():
cmd += ["--models-preset", str(self.preset_path)]
diff --git a/tests/hermes_cli/test_local_preset_admission.py b/tests/hermes_cli/test_local_preset_admission.py
index ce4757d6871..9728fd47170 100644
--- a/tests/hermes_cli/test_local_preset_admission.py
+++ b/tests/hermes_cli/test_local_preset_admission.py
@@ -76,6 +76,8 @@ def test_supervisor_with_presets_does_not_scan_unadmitted_files(tmp_path, monkey
ini.write_text("[allowed]\nmodel = allowed.gguf\nctx-size = 65536\n")
calls = []
monkeypatch.setattr(supervisor, "server_binary", lambda p: Path("llama-server"))
+ monkeypatch.setattr(supervisor.subprocess, "run", lambda *a, **kw:
+ SimpleNamespace(stdout="--load-mode MODE", stderr=""))
monkeypatch.setattr(supervisor, "spawn_server", lambda cmd, **kw: (calls.append(cmd) or SimpleNamespace(pid=123), None))
monkeypatch.setattr(supervisor.LlamaServerSupervisor, "_write_state", lambda self: None)
sup = supervisor.LlamaServerSupervisor(tmp_path, tmp_path, port=1234, preset_path=ini)
diff --git a/tests/hermes_cli/test_local_runtime_hip_assets.py b/tests/hermes_cli/test_local_runtime_hip_assets.py
new file mode 100644
index 00000000000..c92c07740f2
--- /dev/null
+++ b/tests/hermes_cli/test_local_runtime_hip_assets.py
@@ -0,0 +1,33 @@
+"""Offline contracts against published llama.cpp release asset names.
+
+Upstream release.yml changes 0666ad2b2b (b10356) and cff184438e (b10767),
+verified against GitHub release assets on both sides of each transition.
+"""
+
+import pytest
+
+from hermes_cli.local_runtime.binaries import BinaryResolutionError, resolve_assets
+
+
[email protected]("tag,linux_suffix,windows_suffix", [
+ ("b10290", "rocm-7.2-x64.tar.gz", "hip-radeon-x64.zip"),
+ ("b10355", "rocm-7.2-x64.tar.gz", "hip-radeon-x64.zip"),
+ ("b10356", "rocm-7.14-x64.tar.gz", "rocm-7.14-x64.zip"),
+ ("b10679", "rocm-7.14-x64.tar.gz", "rocm-7.14-x64.zip"),
+ ("b10766", "rocm-7.14-x64.tar.gz", "rocm-7.14-x64.zip"),
+ ("b10767", "rocm-10.0-x64.tar.gz", "rocm-10.0-x64.zip"),
+ ("b10964", "rocm-10.0-x64.tar.gz", "rocm-10.0-x64.zip"),
+])
[email protected]("os_name", ["ubuntu", "win"])
+def test_hip_pin_resolves_published_release_archive(tag, linux_suffix, windows_suffix, os_name):
+ suffix = linux_suffix if os_name == "ubuntu" else windows_suffix
+ plan = resolve_assets(tag, "hip", os_name=os_name, arch="x64")
+ assert plan.tag == tag
+ assert plan.backend == "hip"
+ assert plan.assets == [f"llama-{tag}-bin-{os_name}-{suffix}"]
+
+
[email protected]("os_name", ["ubuntu", "win"])
+def test_hip_rejects_unpublished_arm64_archive(os_name):
+ with pytest.raises(BinaryResolutionError, match="no .*HIP.*arm64"):
+ resolve_assets("b10964", "hip", os_name=os_name, arch="arm64")
diff --git a/tests/hermes_cli/test_local_runtime_load_mode.py b/tests/hermes_cli/test_local_runtime_load_mode.py
new file mode 100644
index 00000000000..b6d04466c65
--- /dev/null
+++ b/tests/hermes_cli/test_local_runtime_load_mode.py
@@ -0,0 +1,75 @@
+"""Managed launch preserves direct I/O across engine command-line versions."""
+from __future__ import annotations
+
+import subprocess
+from types import SimpleNamespace
+
+import pytest
+
+from hermes_cli.local_runtime import supervisor
+
+
[email protected]("help_text, expected", [
+ ("-lm, --load-mode MODE\n dio: use DirectIO if available", ["--load-mode", "dio"]),
+ ("-dio, --direct-io use DirectIO if available", ["-dio"]),
+])
+def test_spawn_selects_supported_direct_io_option(tmp_path, monkeypatch, help_text, expected):
+ monkeypatch.setattr(supervisor, "runtimes_root", lambda: tmp_path / "runtime")
+ executable = tmp_path / "engine" / "llama-server"
+ monkeypatch.setattr(supervisor, "server_binary", lambda _: executable)
+ probes = []
+
+ def run(argv, **kwargs):
+ probes.append(argv)
+ return subprocess.CompletedProcess(argv, 0, help_text, "")
+
+ monkeypatch.setattr(supervisor.subprocess, "run", run)
+ commands = []
+ monkeypatch.setattr(supervisor, "spawn_server", lambda argv, **kwargs: (
+ commands.append(argv) or SimpleNamespace(pid=123, poll=lambda: 0), None,
+ ))
+ sup = supervisor.LlamaServerSupervisor(tmp_path / "engine", tmp_path / "models", port=19001)
+ monkeypatch.setattr(sup, "_write_state", lambda: None)
+ try:
+ sup._spawn()
+ index = commands[0].index(expected[0])
+ assert commands[0][index:index + len(expected)] == expected
+ if expected[0] == "--load-mode":
+ assert "-dio" not in commands[0]
+ assert probes == [[str(executable), "--help"]]
+ finally:
+ sup.stop()
+
+
+def test_direct_io_probe_is_reused_for_the_same_engine(tmp_path, monkeypatch):
+ calls = []
+
+ def run(argv, **kwargs):
+ calls.append(argv)
+ return subprocess.CompletedProcess(argv, 0, "--load-mode MODE", "")
+
+ monkeypatch.setattr(supervisor.subprocess, "run", run)
+ executable = tmp_path / "llama-server"
+ assert supervisor._direct_io_args(executable) == ("--load-mode", "dio")
+ assert supervisor._direct_io_args(executable) == ("--load-mode", "dio")
+ assert len(calls) == 1
+
+
+def test_failed_engine_probe_can_be_retried(tmp_path, monkeypatch):
+ executable = tmp_path / "llama-server"
+
+ def fail(argv, **kwargs):
+ raise subprocess.TimeoutExpired(argv, 15)
+
+ monkeypatch.setattr(supervisor.subprocess, "run", fail)
+ with pytest.raises(subprocess.TimeoutExpired):
+ supervisor._direct_io_args(executable)
+ monkeypatch.setattr(supervisor.subprocess, "run", lambda argv, **kwargs:
+ subprocess.CompletedProcess(argv, 0, "--load-mode MODE", ""))
+ assert supervisor._direct_io_args(executable) == ("--load-mode", "dio")
+
+
+def test_engine_without_direct_io_uses_its_supported_defaults(tmp_path, monkeypatch):
+ monkeypatch.setattr(supervisor.subprocess, "run", lambda argv, **kwargs:
+ subprocess.CompletedProcess(argv, 0, "--model FILE", ""))
+ assert supervisor._direct_io_args(tmp_path / "llama-server") == ()
diff --git a/tests/hermes_cli/test_local_runtime_updates.py b/tests/hermes_cli/test_local_runtime_updates.py
index f6f4d43ea22..8408968775a 100644
--- a/tests/hermes_cli/test_local_runtime_updates.py
+++ b/tests/hermes_cli/test_local_runtime_updates.py
@@ -54,6 +54,33 @@ def test_default_tag_flows_from_default_config(hermes_home):
assert load_config()["local_runtime"]["tag"] == default_tag
[email protected]("pin", [None, "b10679", "b10412"])
+def test_preferred_b10964_update_offer_respects_explicit_pins(hermes_home, pin):
+ """Existing unpinned installs get the shipped upgrade; user pins win."""
+ from fastapi.testclient import TestClient
+
+ from hermes_cli import web_server
+ from hermes_cli.config import load_config
+
+ runtime = {"enabled": True}
+ if pin is not None:
+ runtime["tag"] = pin
+ (hermes_home / "config.yaml").write_text(
+ json.dumps({"local_runtime": runtime}), encoding="utf-8")
+ _install_fake_tag(hermes_home, "b10679")
+
+ client = TestClient(web_server.app)
+ client.headers[web_server._SESSION_HEADER_NAME] = web_server._SESSION_TOKEN
+ response = client.get("/api/local-models/status")
+ assert response.status_code == 200, response.text
+ status = response.json()
+ expected_tag = pin or "b10964"
+ assert load_config()["local_runtime"]["tag"] == expected_tag
+ assert status["configured_tag"] == expected_tag
+ assert status["tag"] == "b10679" # An offer must not replace the installed engine.
+ assert status["update_available"] is (expected_tag != "b10679")
+
+
def test_update_available_requires_enabled_and_installed(hermes_home, monkeypatch):
"""The flag's truth table: enabled+installed+configured-missing only."""
from fastapi.testclient import TestClient