Skip to content

The agent that grows with you

fix(local-runtime): -ot spill pinning is discrete-only — UMA machines never pin tensors to the host path

emozilla88f5dcafc896
diff --git a/hermes_cli/local_runtime/context_policy.py b/hermes_cli/local_runtime/context_policy.py
index bdc8d171f0b..650a4d126fb 100644
--- a/hermes_cli/local_runtime/context_policy.py
+++ b/hermes_cli/local_runtime/context_policy.py
@@ -225,10 +225,18 @@ def spill_overrides(profile: ModelProfile) -> list[str]:
def launch_args(profile: ModelProfile, decision: WindowDecision, *,
flash_attention: bool = True,
mtp_capable: bool = False,
- mtp_draft_depth: int = 3) -> list[str]:
+ mtp_draft_depth: int = 3,
+ uma: bool = False) -> list[str]:
"""Per-model launch flags from a window decision. Explicit -c puts fit
into spill-weights-and-hold-ctx; q8 KV cache wherever flash attention
- exists; -ot placement on spilled configs.
+ exists; -ot placement on spilled configs — DISCRETE cards only.
+
+ ``uma``: on unified memory there is no bus to protect tensors from —
+ "CPU" and "GPU" are the same silicon, and pinning FFN weights to the
+ host path just forces CPU compute (measured 2.3x slower than letting
+ the allocator place everything, RTX Spark, 27B Q4). The discrete
+ ~1.75x win the -ot pattern encodes does not transfer; a spilled UMA
+ config runs unpinned.
MTP and the large prefill microbatch are BOTH wins but must not stack:
backend sampling keeps a ubatch x vocab x fp32 logits buffer on the
@@ -246,7 +254,7 @@ def launch_args(profile: ModelProfile, decision: WindowDecision, *,
args += ["-b", "2048", "-ub", "2048"]
if flash_attention:
args += ["-ctk", "q8_0", "-ctv", "q8_0", "-fa", "on"]
- if decision.spilled:
+ if decision.spilled and not uma:
args += spill_overrides(profile)
return args
diff --git a/hermes_cli/local_runtime/presets.py b/hermes_cli/local_runtime/presets.py
index 5ab25aa6dea..8297f65f5f8 100644
--- a/hermes_cli/local_runtime/presets.py
+++ b/hermes_cli/local_runtime/presets.py
@@ -142,7 +142,8 @@ def generate_presets(models_dir: Path, budget: HardwareBudget,
# the launch flags below MUST match that pricing.)
args = launch_args(profile, decision, mtp_capable=is_mtp,
mtp_draft_depth=(entry.mtp_draft_depth
- if entry is not None else 3))
+ if entry is not None else 3),
+ uma=budget.uma)
keys = _args_to_keys(args)
if entry is not None and is_mtp:
diff --git a/tests/hermes_cli/test_context_policy.py b/tests/hermes_cli/test_context_policy.py
index f5ce333c254..49a31d822fa 100644
--- a/tests/hermes_cli/test_context_policy.py
+++ b/tests/hermes_cli/test_context_policy.py
@@ -338,6 +338,28 @@ def test_launch_args_contract():
assert "q8_0" not in d # f16 on non-FA fallback
+def test_launch_args_uma_never_pins_tensors():
+ """On unified memory, -ot pinning is off even for spilled decisions:
+ "CPU" and "GPU" are the same silicon, and forcing FFN weights down
+ the host compute path measured 2.3x SLOWER than letting the
+ allocator place everything (RTX Spark, 27B Q4: 5.5 vs 12.9 tok/s).
+ The discrete ~1.75x -ot win does not transfer. Everything else
+ about the launch shape is identical to discrete."""
+ p = moe()
+ spilled = WindowDecision(window=FLOOR, spill_bytes=4 * GIB, kv_on_gpu=True)
+
+ u = launch_args(p, spilled, mtp_capable=False, uma=True)
+ assert "-ot" not in u, "UMA must never pin tensors to the host path"
+ assert u[:2] == ["-c", str(FLOOR)] # window contract unchanged
+ assert "q8_0" in u # KV policy unchanged
+
+ # Same call on discrete keeps the pinning — the flag is the ONLY delta.
+ disc = launch_args(p, spilled, mtp_capable=False, uma=False)
+ assert "-ot" in disc
+ assert [x for x in disc if x != "-ot" and not x.startswith("blk")] == \
+ [x for x in u if x != "-ot" and not x.startswith("blk")]
+
+
def test_ub_logits_bytes_prices_the_flag_choice():
"""The logits-buffer price must match the microbatch launch_args
chooses: 2048 x vocab x 4 for non-MTP, 512 x vocab x 4 x 2 for MTP