The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(local-runtime): adopt receipt-backed tuning from NVIDIA's recipe catalog
emozilla96c514ff102b
diff --git a/hermes_cli/local_runtime/catalog.py b/hermes_cli/local_runtime/catalog.pyindex 724224a1eaa..8f25ecdb85f 100644--- a/hermes_cli/local_runtime/catalog.py+++ b/hermes_cli/local_runtime/catalog.py@@ -125,7 +125,12 @@ class CatalogEntry:swa_layers: int = 0swa_window: int = 0moe: bool = False- mtp: bool = False # ships MTP heads (spec decode iff spilled)+ mtp: bool = False # ships MTP heads (spec decode when loaded)+ # Speculative draft depth for MTP models. Per-model, measured: deeper+ # drafting only pays while acceptance holds (Qwen3.6-35B: 76% at 2 ->+ # 243.8 tok/s, 59% at 3 -> 221.6; Nemotron holds at 3). NVIDIA's+ # per-SKU recipes seeded these; our receipts confirmed them.+ mtp_draft_depth: int = 3mmproj: "AssetFile | None" = None # vision projector, downloads with modeldraft: "AssetFile | None" = None # spec-decode draft model (e.g. DSpark)sampling: dict = field(default_factory=dict) # INI long-form launch defaults@@ -273,7 +278,7 @@ CATALOG: tuple[CatalogEntry, ...] = (# Config-derived (Qwen/Qwen3.6-35B-A3B): 40 layers, 10 full-attn# (interval 4) + 30 linear; KV heads 2 x head_dim 256.full_layers=10, recurrent_layers=30, per_layer_f16=2048,- moe=True, mtp=True,+ moe=True, mtp=True, mtp_draft_depth=2,mmproj=AssetFile("mmproj-BF16.gguf", 902822528,"da63cb47a76763c712393f8a017070188a304fa39f8aeea6edc629ed7b975cfa",local="mmproj-Qwen3.6-35B-A3B-BF16.gguf"),diff --git a/hermes_cli/local_runtime/context_policy.py b/hermes_cli/local_runtime/context_policy.pyindex b7e26011480..4d23e19b88f 100644--- a/hermes_cli/local_runtime/context_policy.py+++ b/hermes_cli/local_runtime/context_policy.py@@ -62,9 +62,12 @@ TARGET_WINDOW = 144 * 1024# buffers. Measured on a 32 GiB card: a model estimated at 29.3 GiB# (weights+KV) loaded at ~31.2 GiB resident and the server's own fit still# shaved a layer to CPU — ~1.5 GiB of runtime overhead plus the vision-# projector when present. A fit that ignores this passes on paper and-# spills in practice. Callers add mmproj bytes on top.-RUNTIME_OVERHEAD_BYTES = int(1.5 * (1 << 30))+# projector when present. The -ub 2048 microbatch adds ~0.4 GiB of compute+# buffer over the 512 default (measured: +367 MiB on the 35B) — the prefill+# hint and this constant move together or the fit lies. A fit that ignores+# this passes on paper and spills in practice. Callers add mmproj bytes on+# top.+RUNTIME_OVERHEAD_BYTES = int(1.9 * (1 << 30))def ladder(native: int) -> list[int]:@@ -222,15 +225,20 @@ def spill_overrides(profile: ModelProfile) -> list[str]:def launch_args(profile: ModelProfile, decision: WindowDecision, *,flash_attention: bool = True,- mtp_capable: bool = False) -> list[str]:+ mtp_capable: bool = False,+ mtp_draft_depth: int = 3) -> list[str]:"""Per-model launch flags from a window decision. Explicit -c puts fitinto spill-weights-and-hold-ctx; q8 KV cache wherever flash attention- exists; -ot placement and MTP spec decode on spilled configs."""- args = ["-c", str(decision.window)]+ exists; -ot placement on spilled configs; MTP spec decode wherever the+ model ships it (resident decode measured +16% at depth 2 on the 35B —+ the old spilled-only gate left that on the table); large microbatch+ for prefill (+27% measured at -ub 2048, priced in RUNTIME_OVERHEAD)."""+ args = ["-c", str(decision.window), "-b", "2048", "-ub", "2048"]if flash_attention:args += ["-ctk", "q8_0", "-ctv", "q8_0", "-fa", "on"]if decision.spilled:args += spill_overrides(profile)- if mtp_capable:- args += ["--spec-type", "draft-mtp"]+ if mtp_capable:+ args += ["--spec-type", "draft-mtp",+ "--spec-draft-n-max", str(mtp_draft_depth)]return argsdiff --git a/hermes_cli/local_runtime/presets.py b/hermes_cli/local_runtime/presets.pyindex 55f83d82f20..49ab4f92f55 100644--- a/hermes_cli/local_runtime/presets.py+++ b/hermes_cli/local_runtime/presets.py@@ -31,11 +31,14 @@ logger = logging.getLogger(__name__)# of the preset (recipe sampling defaults merge in a later pass)._FLAG_TO_KEY = {"-c": "ctx-size",+ "-b": "batch-size",+ "-ub": "ubatch-size","-ctk": "cache-type-k","-ctv": "cache-type-v","-fa": "flash-attn","-ot": "override-tensor","--spec-type": "spec-type",+ "--spec-draft-n-max": "spec-draft-n-max",}@@ -128,13 +131,23 @@ def generate_presets(models_dir: Path, budget: HardwareBudget,except Exception as exc: # noqa: BLE001 — overrides are advisorylogger.debug("window override skipped for %s: %s", model_id, exc)- args = launch_args(profile, decision,- mtp_capable=model_id in (mtp_capable or set()))+ hit = find_entry_for_model(model_id)+ entry = hit[0] if hit is not None else None++ # MTP: catalog knowledge wins (per-model measured draft depth);+ # the caller's mtp_capable set covers non-catalog GGUFs.+ is_mtp = (entry.mtp if entry is not None+ else model_id in (mtp_capable or set()))+ args = launch_args(profile, decision, mtp_capable=is_mtp,+ mtp_draft_depth=(entry.mtp_draft_depth+ if entry is not None else 3))keys = _args_to_keys(args)- hit = find_entry_for_model(model_id)- if hit is not None:- entry, _variant = hit+ if entry is not None:+ if is_mtp:+ # Integrated-MTP targets sample on the backend (their+ # measured pairing; draft sampling stays default).+ keys["backend-sampling"] = "on"# Sampling defaults under the policy keys (policy wins on clash).for k, v in (entry.sampling or {}).items():keys.setdefault(k, v)diff --git a/hermes_cli/local_runtime/supervisor.py b/hermes_cli/local_runtime/supervisor.pyindex a85b23c2ca4..395d5cda08f 100644--- a/hermes_cli/local_runtime/supervisor.py+++ b/hermes_cli/local_runtime/supervisor.py@@ -174,6 +174,11 @@ class LlamaServerSupervisor:"--slots", # /slots endpoint is also opt-in; is_idle reads it"--no-webui","--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 loads on NVMe, and our router bounces (download/+ # delete/activate) reload models often enough to care.+ "-dio",]if self.preset_path and self.preset_path.exists():cmd += ["--models-preset", str(self.preset_path)]diff --git a/tests/hermes_cli/test_context_policy.py b/tests/hermes_cli/test_context_policy.pyindex b3c2cbed6e4..cb330a2245b 100644--- a/tests/hermes_cli/test_context_policy.py+++ b/tests/hermes_cli/test_context_policy.py@@ -311,16 +311,22 @@ def test_launch_args_contract():resident = WindowDecision(window=131072, spill_bytes=0, kv_on_gpu=True)a = launch_args(p, spilled, mtp_capable=True)- assert a[:2] == ["-c", str(FLOOR)] # explicit -c: A3 semantics- assert "q8_0" in a # B6 dtype behavior- assert "-ot" in a # D2 placement- assert "--spec-type" in a # D5: MTP on iff spilled-- b = launch_args(p, resident, mtp_capable=True)- assert "-ot" not in b and "--spec-type" not in b+ assert a[:2] == ["-c", str(FLOOR)] # explicit window, always+ assert "-ub" in a and a[a.index("-ub") + 1] == "2048" # prefill hint+ assert "q8_0" in a # q8 KV under flash attn+ assert "-ot" in a # spill placement+ assert "--spec-type" in a # MTP on spilled++ # MTP is no longer gated on spill: resident decode measured +16% at+ # depth 2 — spec decode runs wherever the model ships MTP heads.+ b = launch_args(p, resident, mtp_capable=True, mtp_draft_depth=2)+ assert "-ot" not in b, "placement is spill-only"+ assert "--spec-type" in b, "MTP must run on resident configs too"+ assert b[b.index("--spec-draft-n-max") + 1] == "2"c = launch_args(p, spilled, flash_attention=False, mtp_capable=False)assert "q8_0" not in c # f16 on non-FA fallback+ assert "--spec-type" not in cdef test_no_refusal_branch_past_physics():