Files
ai-agent/sidecar/test_local_room.py
Gabriel VidalandClaude Opus 5.5 33835edae1 feat(models): Inkling 2 Mini, the default local model, on its own EVOX2 server
Inkling 2 Mini (Thinking Machines, looped MoE 26.4B-A3.4B, vision) runs on
llm-inkling (:8091, pi provider evox2-inkling): a llama.cpp build of unmerged
upstream branches that beats Qwen 3.8 27B 1.45-1.7x prefill / 1.3-1.7x decode
with the same graded coding score (homelab data/log/2026-11-23-inkling-*).
Gabriel's calls (form inkling-2-mini-local-chip_zdzwvf): own server, thinking
medium by default, the new default local model, own chip family, opencode twin.

- catalog: inkling-2-mini first (default), family inkling, chip "inkling
  local"; a chip may name its serving pi provider (`server`), so the
  opencode twin is <server>/<id> (evox2-inkling/inkling-2-mini) with
  reasoning-level variants (`twinEfforts`); local_twin_base() folds any
  evox2* twin onto its pi id (presets key, pricing watts)
- pricing: anything the catalogue calls local is free, whatever its id —
  inkling-2-mini was priced as Opus (backend and frontend)
- sidecar local_room.py: before a local run (pi/opencode launch, the cron
  /local-ready probe) unload the *other* local server's idle model — one big
  model in VRAM at a time across llm-server and llm-inkling
- router /slots reads with autoload=false (local_room, gen_progress): asking a
  model that just unloaded would load it again
- opencode local_providers: effort-scaled templates (reasoning_effort) get
  none/low/medium/high variants and their pi defaultThinking as default
- runner: default model inkling-2-mini; a local run with no level takes the
  model's models.json defaultThinking (Inkling: medium), else off
- defaults: SIDECAR_PI_MODEL, SIDECAR_OPENCODE_LOCAL_MODEL, guest jobs'
  local model (key stays "qwen", labels say Inkling 2 Mini)
- frontend: inkling family (cyan, Infinity icon, chart hue), label, harness
  fallback, local pricing and twin keys
- tests: twin ids/efforts, local pricing, make-room (busy, race, asleep),
  autoload=false, effort variants; docs in CLAUDE.md and runner/README.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 15:14:05 +01:00

135 lines
6.2 KiB
Python

"""One big model in VRAM at a time across the EVOX2's local servers
(local_room.py): a run on one unloads the *other* server's idle model, never a
busy one, never its own server's, never a model it would load by asking; and
the opencode twin of an effort-scaled model (Inkling) gets reasoning levels."""
import urllib.error
import gen_progress as gp
import local_room
import opencode_cli
REG = {
"evox2": {"baseUrl": "http://box:8090/v1", "apiKey": "k", "models": [
{"id": "ggml-org/qwen3.8-27b"}, {"id": "qwen3.6-35b-a3b"}]},
"evox2-inkling": {"baseUrl": "http://box:8091/v1", "apiKey": "k2", "models": [
{"id": "inkling-2-mini"}]},
"openrouter": {"baseUrl": "https://or/v1", "models": [{"id": "qwen/qwen3.8-27b"}]},
}
class Box:
"""Fake routers: ``state[root][model]`` = status; ``busy`` = models mid-request."""
def __init__(self, state, busy=(), down=()):
self.state, self.busy, self.down, self.calls = state, set(busy), set(down), []
def req(self, root, path, key, body=None):
self.calls.append((root, path, body))
if root in self.down:
raise urllib.error.URLError("asleep")
models = self.state[root]
if path == "/models":
return {"data": [{"id": m, "status": {"value": s}} for m, s in models.items()]}
if path.startswith("/slots"):
mid = path.split("model=", 1)[1].split("&", 1)[0].replace("%2F", "/")
assert "autoload=false" in path # never load what it asks about
if models.get(mid) != "loaded":
raise urllib.error.HTTPError(root + path, 400, "not running", {}, None)
return [{"id": 0, "is_processing": mid in self.busy}]
if path == "/models/unload":
models[body["model"]] = "unloaded"
return {"success": True}
raise AssertionError(path)
def test_the_other_servers_only_one_root_each():
t = gp.local_target("pi", "inkling-2-mini", REG)
assert t["root"] == "http://box:8091"
assert local_room.others(t, REG) == {"http://box:8090": "k"}
t = gp.local_target("opencode", "evox2/ggml-org/qwen3.8-27b", REG)
assert local_room.others(t, REG) == {"http://box:8091": "k2"}
def test_an_inkling_run_unloads_the_idle_qwen(monkeypatch):
box = Box({"http://box:8090": {"ggml-org/qwen3.8-27b": "loaded", "qwen3.6-35b-a3b": "unloaded"},
"http://box:8091": {"inkling-2-mini": "unloaded"}})
monkeypatch.setattr(local_room, "_req", box.req)
assert local_room.make_room("pi", "inkling-2-mini", reg=REG) == \
["http://box:8090 ggml-org/qwen3.8-27b"]
assert box.state["http://box:8090"]["ggml-org/qwen3.8-27b"] == "unloaded"
# its own server is never asked: its router swaps models itself
assert all(root == "http://box:8090" for root, _, _ in box.calls)
def test_a_busy_model_is_left_alone(monkeypatch):
box = Box({"http://box:8090": {"ggml-org/qwen3.8-27b": "loaded"},
"http://box:8091": {"inkling-2-mini": "loaded"}},
busy={"ggml-org/qwen3.8-27b"})
monkeypatch.setattr(local_room, "_req", box.req)
assert local_room.make_room("opencode", "evox2-inkling/inkling-2-mini", reg=REG) == []
assert box.state["http://box:8090"]["ggml-org/qwen3.8-27b"] == "loaded"
def test_a_model_that_went_meanwhile_is_skipped_not_reloaded(monkeypatch):
# /models still says loaded, but it is gone by the time /slots is asked
box = Box({"http://box:8090": {"ggml-org/qwen3.8-27b": "loaded"}, "http://box:8091": {}})
real = box.req
def racing(root, path, key, body=None):
out = real(root, path, key, body)
if path == "/models":
box.state[root]["ggml-org/qwen3.8-27b"] = "unloaded"
return out
monkeypatch.setattr(local_room, "_req", racing)
assert local_room.make_room("pi", "inkling-2-mini", reg=REG) == []
assert not any(p == "/models/unload" for _, p, _ in box.calls)
def test_not_local_or_box_asleep_does_nothing(monkeypatch):
box = Box({"http://box:8090": {}, "http://box:8091": {}}, down={"http://box:8090"})
monkeypatch.setattr(local_room, "_req", box.req)
assert local_room.make_room("pi", "qwen/qwen3.8-27b", reg=REG) == []
assert local_room.make_room("claude", "opus", reg=REG) == []
assert box.calls == []
assert local_room.make_room("pi", "inkling-2-mini", reg=REG) == [] # asleep: no answer
def test_a_slot_poll_never_loads_a_model(monkeypatch):
urls = []
def fake_get(url, key):
urls.append(url)
if url.endswith("/models"):
return {"data": [{"id": "m", "status": {"value": "loaded"}}]}
raise urllib.error.HTTPError(url, 400, "not running", {}, None)
monkeypatch.setattr(gp, "_get", fake_get)
# gone between the two calls: idle, and asked with autoload=false
assert gp.server_reading("http://box:8091", "k", "m", {}) == {"phase": "idle"}
assert urls[-1].endswith("/slots?model=m&autoload=false")
# ── the opencode twin's reasoning ────────────────────────────────────────────
INKLING = {"id": "inkling-2-mini", "reasoning": True, "defaultThinking": "medium",
"thinkingLevelMap": {"off": "none"},
"compat": {"thinkingFormat": "chat-template",
"chatTemplateKwargs": {"reasoning_effort": {"$var": "thinking.effort"}}}}
QWEN = {"id": "ggml-org/qwen3.8-27b", "reasoning": True,
"compat": {"thinkingFormat": "qwen-chat-template"}}
def test_an_effort_scaled_model_gets_levels_and_its_default():
opts, variants = opencode_cli._reasoning(INKLING)
assert opts == {"chat_template_kwargs": {"reasoning_effort": "medium"}}
assert list(variants) == ["none", "low", "medium", "high"]
assert variants["none"] == {"chat_template_kwargs": {"reasoning_effort": "none"}}
# no default of its own ⇒ its map's off value
opts, _ = opencode_cli._reasoning({**INKLING, "defaultThinking": None})
assert opts == {"chat_template_kwargs": {"reasoning_effort": "none"}}
def test_a_qwen_still_thinks_only_when_asked():
opts, variants = opencode_cli._reasoning(QWEN)
assert opts == {"chat_template_kwargs": {"enable_thinking": False}}
assert set(variants) == {"none", "think"}