Skip to content

The agent that grows with you

fix(local-runtime): read local_runtime.backend through the config loader

teknium1889a469c975d
diff --git a/hermes_cli/local_runtime/hardware.py b/hermes_cli/local_runtime/hardware.py
index 7c19d4c59f1..675903a60a6 100644
--- a/hermes_cli/local_runtime/hardware.py
+++ b/hermes_cli/local_runtime/hardware.py
@@ -297,15 +297,21 @@ def _cuda_driver_pool() -> "tuple[int, bool | None] | None":
return None
+def _configured_engine():
+ """The installed engine for ``local_runtime.backend``; the probes below run that exact build."""
+ from hermes_cli.config import load_config_readonly
+ from hermes_cli.local_runtime.binaries import installed_engine
+
+ section = load_config_readonly().get("local_runtime") or {}
+ return installed_engine(section.get("backend") or "auto")
+
+
def _engine_device_pool() -> "tuple[int, bool | None] | None":
"""(engine_total_bytes, None) from the installed runtime's own --list-devices, or None. The
fallback when the driver API is unreachable: asks the exact binary that will do the
allocating. Carries no integrated verdict — callers must gate it."""
with suppress(Exception): # a probe miss must never block budgeting
- from hermes_cli.config import get_config_value
- from hermes_cli.local_runtime.binaries import installed_engine
-
- engine = installed_engine(get_config_value("local_runtime.backend", "auto"))
+ engine = _configured_engine()
if engine is None:
return None
exe = engine.binary
@@ -346,11 +352,9 @@ def _accelerator_device() -> "dict | None":
endpoint polls this every few seconds and each probe initializes the GPU driver.
"""
with suppress(Exception): # a probe miss must never block budgeting
- from hermes_cli.config import get_config_value
- from hermes_cli.local_runtime.binaries import installed_engine
from hermes_cli.local_runtime.devices import probe_devices
- engine = installed_engine(get_config_value("local_runtime.backend", "auto"))
+ engine = _configured_engine()
if engine is None or engine.backend not in ("vulkan", "hip"):
return None
key, now = str(engine.binary), time.monotonic()
diff --git a/tests/hermes_cli/test_unified_pool_quirk.py b/tests/hermes_cli/test_unified_pool_quirk.py
index e15890c1d18..78ac7eb7a92 100644
--- a/tests/hermes_cli/test_unified_pool_quirk.py
+++ b/tests/hermes_cli/test_unified_pool_quirk.py
@@ -183,18 +183,32 @@ def test_engine_fallback_without_smi_stays_conservative(monkeypatch):
@pytest.mark.parametrize("device_type, discrete", [(1, True), (2, False)])
-def test_vulkan_device_type_decides_discrete_vs_unified(monkeypatch, device_type, discrete):
+def test_vulkan_device_type_decides_discrete_vs_unified(monkeypatch, tmp_path, device_type, discrete):
"""A discrete AMD/Intel card behind a Vulkan engine budgets its own memory with RAM as spill;
- an integrated one (ggml IGPU) keeps the RAM-as-unified budget, never both pools."""
+ an integrated one (ggml IGPU) keeps the RAM-as-unified budget, never both pools. The engine is
+ the one config.yaml names, read through the real config loader."""
+ import hermes_cli.local_runtime.binaries as binaries
+ import hermes_cli.local_runtime.devices as devices
+
total = 16304 << 20
+ home = tmp_path / ".hermes"
+ home.mkdir()
+ (home / "config.yaml").write_text("local_runtime:\n backend: vulkan\n", encoding="utf-8")
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ requested = []
+ engine = binaries.Engine("vulkan", "b10964", tmp_path / "engine" / "llama-server")
+ monkeypatch.setattr(binaries, "installed_engine",
+ lambda backend="auto", **_: requested.append(backend) or engine)
+ monkeypatch.setattr(devices, "probe_devices", lambda directory, backend: [{
+ "description": "AMD Radeon RX 9060 XT", "type": device_type, "free": total, "total": total}])
+ monkeypatch.setattr(hw, "_accelerator_cache", {})
monkeypatch.setattr(hw, "_nvidia_vram", lambda: None)
monkeypatch.setattr(hw, "_device_pool_view", lambda: None)
monkeypatch.setattr(hw, "_ram_bytes", lambda: (32 * GIB, 20 * GIB))
- monkeypatch.setattr(hw, "_accelerator_device", lambda: {
- "description": "AMD Radeon RX 9060 XT", "type": device_type, "free": total, "total": total})
b = hw.probe_budget(planning=True)
+ assert requested == ["vulkan"]
assert b.uma is (not discrete)
if discrete:
assert b.total_device_bytes == total