The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore(local-runtime): keep comments technical and device-neutral
emozilla082211b71a96
diff --git a/apps/desktop/src/app/shell/system-resources-statusbar.tsx b/apps/desktop/src/app/shell/system-resources-statusbar.tsxindex e89a111e3b8..c9134a2bff0 100644--- a/apps/desktop/src/app/shell/system-resources-statusbar.tsx+++ b/apps/desktop/src/app/shell/system-resources-statusbar.tsx@@ -125,10 +125,10 @@ export function useSystemResourcesStatusbarItem(): StatusbarItem {data-slot="system-resources-panel">{/* min-w-0 everywhere a flex/grid child must shrink: grid items- default min-width:auto, so the long GPU name's nowrap min-content- (263px on the RTX Spark prototype) props the track open past the- w-64 box and overflow-x:hidden shears off every right-aligned- value. With the track clamped, `truncate` can finally act. */}+ default min-width:auto, so a long GPU name's nowrap min-content+ props the track open past the w-64 box and overflow-x:hidden+ shears off every right-aligned value. With the track clamped,+ `truncate` can finally act. */}<div className="flex min-w-0 items-baseline justify-between gap-2"><p className="shrink-0 font-medium text-foreground">{copy.title}</p>diff --git a/hermes_cli/local_runtime/binaries.py b/hermes_cli/local_runtime/binaries.pyindex d442ef80b60..3e8b5dc6a65 100644--- a/hermes_cli/local_runtime/binaries.py+++ b/hermes_cli/local_runtime/binaries.py@@ -144,8 +144,8 @@ def resolve_assets(tag: str, backend: str, os_name: str | None = None,"""Compose the asset list for (tag, backend, platform).Raises BinaryResolutionError for combinations the release does not ship- (e.g. win-cuda-arm64 — a known gap, in the NVIDIA asks). Callers fall- back down the backend ladder: cuda -> vulkan -> cpu.+ (a platform/backend pair upstream publishes no artifact for). Callers+ fall back down the backend ladder: cuda -> vulkan -> cpu."""host_os, host_arch = _host_os_arch()os_name = os_name or host_osdiff --git a/hermes_cli/local_runtime/catalog.py b/hermes_cli/local_runtime/catalog.pyindex 9b98b07f052..1b4d80a7c6f 100644--- a/hermes_cli/local_runtime/catalog.py+++ b/hermes_cli/local_runtime/catalog.py@@ -8,10 +8,10 @@ whose base config is gated upstream carry a same-family conservativeprior (commented) — the GGUF header corrects it at load time.Each model ships ONE build, Q4-class (UD-Q4_K_M where the repo has it,-per NVIDIA's recommended catalog — their llama.cpp optimizations target-Q4-class quants; UD-Q4_K_XL elsewhere). No quant ladder: headroom buys a-bigger context window, never a bigger quant, so every machine runs the-same build the vendor recipes were measured on. Below Q4 the quality+UD-Q4_K_XL elsewhere). Q4 is the quant class current engines optimize+for and the sweet spot of the size/quality curve, so there is no quant+ladder: headroom buys a bigger context window, never a bigger quant,+and every machine runs the same well-tested build. Below Q4 the qualityloss is too severe to ship as someone's first local-AI experience; thefit policy prices the build honestly (zero-spill, spilled, or refused bythe physics check).@@ -29,7 +29,7 @@ only when the launch decision spills, where its speedup is largest.File sizes come from HF LFS metadata and feed the estimator, the fitpills, and download progress. There is no download-time integrity check-(product decision): a corrupt or truncated file surfaces as a llama.cpp+by design: a corrupt or truncated file surfaces as a llama.cppload error at first use, and the reachability test catches upstreamre-uploads by size drift before users do.@@ -97,11 +97,10 @@ class AssetFile:@dataclass(frozen=True)class QuantVariant:- """One downloadable build of a model. Ordered best-quality-first in- CatalogEntry.variants. Split GGUFs list every part in files; the model- loads from the first part."""+ """One downloadable build of a model. Split GGUFs list every part in+ files; the model loads from the first part."""- quant: str # e.g. "UD-Q8_K_XL"+ quant: str # e.g. "UD-Q4_K_M"files: tuple # AssetFile, first = the load targetvalidated: bool = False # proven end-to-end on real hardware@@ -128,7 +127,7 @@ class CatalogEntry:display_name: strdescription: str # one line, plain languagerepo: str # HF repo- variants: tuple # QuantVariant, best first+ variants: tuple # QuantVariant (exactly one, Q4-class)# Estimator inputs (measured or config-derived; quant changes weights,# never KV). Entries with gated upstream configs carry a conservative# same-family prior — the GGUF header is the authority after download.@@ -140,14 +139,13 @@ class CatalogEntry:swa_window: int = 0moe: bool = Falsemtp: 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.+ # Speculative draft depth for MTP models. Per-model and measured:+ # deeper drafting pays only while draft acceptance holds, and the+ # break-even depth differs by model.mtp_draft_depth: int = 3# Vocab size prices the GPU logits buffers (ubatch x vocab x fp32,- # doubled under MTP backend sampling) — a 248K-vocab model once packed- # a card 3.9 GiB past a fit that ignored this.+ # doubled under MTP backend sampling) — a multi-GiB term at large+ # vocab sizes that a weights-only fit would miss.n_vocab: int = 0mmproj: "AssetFile | None" = None # vision projector, downloads with modeldraft: "AssetFile | None" = None # spec-decode draft model (e.g. DSpark)@@ -190,11 +188,9 @@ class VariantChoice:def select_variant(entry: CatalogEntry, budget: HardwareBudget) -> VariantChoice | None:"""Fit the entry's one build (Q4-class) to this machine.- The quant ladder is gone (NVIDIA guidance, 2026-08: their llama.cpp- optimizations target Q4-class builds, so Q4 is the best- speed-per-quality everywhere and the build the vendor recipes were- measured on). Every entry ships exactly one variant; headroom buys a- bigger window, never a bigger quant. Spill logic is unchanged:+ Every entry ships exactly one variant (see the module docstring for+ why there is no quant ladder); headroom buys a bigger window, never+ a bigger quant. The fit shapes:- "best-large-window": zero-spills at TARGET_WINDOW- "best-fits": zero-spills at the 64K floordiff --git a/hermes_cli/local_runtime/context_policy.py b/hermes_cli/local_runtime/context_policy.pyindex 650a4d126fb..82f19ff732d 100644--- a/hermes_cli/local_runtime/context_policy.py+++ b/hermes_cli/local_runtime/context_policy.py@@ -233,18 +233,18 @@ def launch_args(profile: ModelProfile, decision: WindowDecision, *,``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+ host path just forces CPU compute (measured well over 2x slower than+ letting the allocator place everything). The discrete~1.75x win the -ot pattern encodes does not transfer; a spilled UMAconfig 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- GPU, and MTP's draft context doubles it — measured 5.8 GiB of overhead- on a 248K-vocab model at -ub 2048 vs 1.9 priced, which silently packed- a 32 GiB card. So MTP models run decode-optimized (-ub 512, measured- 247 tok/s) and non-MTP models run prefill-optimized (-ub 2048,- measured +27%); ub_logits_bytes() prices whichever was chosen."""+ GPU, and MTP's draft context doubles it — at large vocab sizes and+ -ub 2048 that buffer runs multiple GiB past what a fit that ignores+ it would price. So MTP models run decode-optimized (-ub 512) and+ non-MTP models run prefill-optimized (-ub 2048, measured ~+27%+ prefill); ub_logits_bytes() prices whichever was chosen."""args = ["-c", str(decision.window)]if mtp_capable:args += ["--spec-type", "draft-mtp",diff --git a/hermes_cli/local_runtime/hardware.py b/hermes_cli/local_runtime/hardware.pyindex 907ab75d107..430721551bb 100644--- a/hermes_cli/local_runtime/hardware.py+++ b/hermes_cli/local_runtime/hardware.py@@ -6,10 +6,10 @@ physical memory minus headroom — their device queries have been observedoff by 3x in both directions. The probe classifies the device andconstructs the right HardwareBudget for the estimator.-Vendor probe quirk (RTX-Spark-class WDDM carve-out): on unified-memory-NVIDIA devices under Windows, nvidia-smi answers from the legacy-dedicated-VRAM carve-out (measured 16 GiB reported vs a 45.4 GiB pool the-allocator addresses uniformly at full bandwidth). The CUDA driver API is+Vendor probe quirk (WDDM carve-out): on unified-memory NVIDIA devices+under Windows, nvidia-smi answers from the legacy dedicated-VRAM+carve-out — a fraction of the pool the CUDA allocator actually+addresses uniformly at full bandwidth. The CUDA driver API isthe tiebreaker: cuDeviceGetAttribute(INTEGRATED) is the vendor's owndeclaration and always wins — 1 budgets unified, 0 stays discrete nomatter what any other number says. Only when the driver API is@@ -43,7 +43,7 @@ _GIB = 1 << 30# 1 GiB is regressive on 8 GB cards and generous on 24 GB ones._MARGIN_FLOOR = 512 << 20_MARGIN_FRACTION = 0.07-# UMA headroom: on unified-memory machines (Apple Silicon, Spark-class+# UMA headroom: on unified-memory machines (Apple Silicon, unified-memory# NVIDIA) the model shares physical memory with the OS and every app, so# budget from RAM minus this fraction._UMA_HEADROOM_FRACTION = 0.20@@ -51,7 +51,7 @@ _UMA_HEADROOM_FRACTION = 0.20# Engine-fallback gates for the unified-pool quirk — BOTH must hold, and# no discrete card can meet either: (1) the allocator's pool exceeds the# smi report by well past rounding/ECC slack (discrete cards agree within-# ~2%; measured Spark disagreement is 2.85x), and (2) the pool is+# ~2%; carve-out disagreement runs to whole multiples), and (2) the pool is# system-RAM-sized — a workstation card in a RAM-matched box fails (1)# because its smi and allocator AGREE, and a big discrete card in a# bigger box fails (2). The driver's INTEGRATED attribute, when@@ -68,7 +68,7 @@ _CU_DEVICE_ATTRIBUTE_INTEGRATED = 18_POOL_NEGATIVE_TTL_S = 60.0_pool_probe_cache: tuple[float, "tuple[int, bool | None] | None"] | None = None-# ' CUDA0: NVIDIA RTX Spark N1X (5120-core Blackwell RTX GPU) (46464 MiB, 46284 MiB free)'+# ' CUDA0: NVIDIA Example Device (1234-core Example GPU) (46464 MiB, 46284 MiB free)'# — greedy .* pins the LAST parenthesized group, so device names carrying# their own parentheses parse correctly._DEVICE_LINE_RE = re.compile(r"CUDA\d+:.*\((\d+)\s*MiB,\s*\d+\s*MiB free\)\s*$")@@ -168,8 +168,8 @@ def _cuda_driver_pool() -> "tuple[int, bool | None] | None":API, or None when unreachable. ctypes against the driver's own DLL/SO— no toolkit, no subprocess, ~ms. INTEGRATED is the vendor's ownunified-memory declaration; total is the pool the allocator will- actually hand out (observed 45.4 GiB where nvidia-smi says 16 on- Spark-class firmware)."""+ actually hand out (on carve-out devices, several times what+ nvidia-smi reports)."""import ctypesfor name in ("nvcuda.dll", "libcuda.so.1", "libcuda.so"):@@ -290,17 +290,16 @@ def probe_budget(*, planning: bool = False) -> HardwareBudget:ram_total, ram_avail = _ram_bytes()vram = _nvidia_vram()- # Unified-memory NVIDIA (Spark-class): the CUDA allocator pool is the- # real capacity. Classification comes from the driver API/engine — it+ # Unified-memory NVIDIA: the CUDA allocator pool is the real+ # capacity. Classification comes from the driver API/engine — it# must not require nvidia-smi (stripped-PATH sessions lose smi but- # nvcuda loads via the system loader regardless). Measured with the- # carve-out at both 16 and 32 GiB: crossing it costs nothing (effective- # bandwidth flat ~210-240 GB/s through the boundary), smi's used/total- # merely saturate at it, and the pool stays ~46 GiB regardless — the- # carve-out is an OS accounting knob, not a GPU limit. Deliberately NOT+ # nvcuda loads via the system loader regardless). Crossing the+ # carve-out costs nothing (effective bandwidth is flat through the+ # boundary; smi's used/total merely saturate at it) — the carve-out+ # is an OS accounting knob, not a GPU limit. Deliberately NOT# clamped to OS RAM: carved-out memory is invisible to- # GlobalMemoryStatusEx (32/32 mode reports 16 GiB less RAM), so a RAM- # clamp threw away exactly the carved capacity.+ # GlobalMemoryStatusEx (the OS reports correspondingly less total+ # RAM), so a RAM clamp would throw away exactly the carved capacity.unified = _unified_pool_bytes(vram[0] if vram else 0, ram_total)if unified is not None:logger.info(diff --git a/hermes_cli/local_runtime/hf_browse.py b/hermes_cli/local_runtime/hf_browse.pyindex c146c2e36da..e554ee1fc4a 100644--- a/hermes_cli/local_runtime/hf_browse.py+++ b/hermes_cli/local_runtime/hf_browse.py@@ -1,7 +1,7 @@"""Browse Hugging Face for GGUF models the user can run.The curated catalog is the front page; this module is the firehose behind-it — day-0 models NVIDIA or we haven't blessed yet, community quants,+it — day-0 models not yet in the catalog, community quants,anything. Three rules keep it safe and honest:1. Acquisition only. Nothing here serves a model: a browsed download@@ -13,7 +13,7 @@ anything. Three rules keep it safe and honest:After download the GGUF header is the authority, as everywhere.3. HF is queried directly with short timeouts and a small in-processcache. No third-party proxy service; if HF rate limits ever bite at- fleet scale, a proxy is a product decision to make then.+ fleet scale, revisit with a caching proxy then."""from __future__ import annotationsdiff --git a/hermes_cli/web_routers/local_models.py b/hermes_cli/web_routers/local_models.pyindex b4a1b44de66..be9965b8a8d 100644--- a/hermes_cli/web_routers/local_models.py+++ b/hermes_cli/web_routers/local_models.py@@ -127,8 +127,8 @@ def download_file(url: str, dest: Path, job: Dict[str, Any],"""Download url -> dest with byte progress on ``job``.Ranged-parallel when the server supports it, single-stream fallback- otherwise. There is no integrity check against the CATALOG by design- (product decision): catalog sizes may lag an upstream re-upload, and a+ otherwise. There is no integrity check against the CATALOG by+ design: catalog sizes may lag an upstream re-upload, and anewer file than we know about must download fine. Completeness ischecked only against what the SERVER declared for this transfer(range-probe total / Content-Length) — self-consistent and alwaysdiff --git a/tests/hermes_cli/test_catalog_variants.py b/tests/hermes_cli/test_catalog_variants.pyindex 38a26c397ba..af89b2d2cc9 100644--- a/tests/hermes_cli/test_catalog_variants.py+++ b/tests/hermes_cli/test_catalog_variants.py@@ -1,7 +1,6 @@-"""Variant-selection contracts: the quant ladder picks the best build for-the hardware, per the design's 'offer a smaller quant' remedy run-proactively, bounded by the Q4 quality floor. Pure decision-table tests-over synthetic budgets."""+"""Variant-selection contracts: fit the catalog's single Q4-class build+to a machine and price it honestly. Pure decision-table tests over+synthetic budgets."""from __future__ import annotations@@ -25,15 +24,14 @@ def budget(vram_gib: float, ram_gib: float = 64) -> HardwareBudget:def test_every_entry_ships_exactly_one_q4_build():- """No quant ladder: one Q4-class build per entry (NVIDIA guidance —- their llama.cpp optimizations target Q4-class quants; K_M where the- repo ships it, XL elsewhere). No Q3/Q2 ever ships (product decision,- 2026-08-09). Validation status is explicit per variant in- catalog.json; unvalidated builds are permitted (day-0 entries) and- surface as unbadged rows in the pane."""+ """No quant ladder: one Q4-class build per entry (K_M where the repo+ ships it, XL elsewhere) — the quant class current engines optimize+ for. Nothing below Q4 ever ships. Validation status is explicit per+ variant in catalog.json; unvalidated builds are permitted (day-0+ entries) and surface as unbadged rows in the pane."""for entry in CATALOG:assert len(entry.variants) == 1, (- f"{entry.id}: {len(entry.variants)} variants — the ladder is gone")+ f"{entry.id}: {len(entry.variants)} variants — expected exactly one")build = entry.variants[0]assert build.quant.startswith(("UD-Q4", "Q4")), (f"{entry.id}: ships {build.quant}, not a Q4-class build")@@ -53,8 +51,7 @@ def test_split_variants_have_coherent_parts():def test_selection_is_the_q4_build_even_with_headroom():- """NVIDIA guidance (2026-08): llama.cpp optimizations target Q4-class- builds, so the selector picks the Q4 rung even when bigger quants fit+ """The selector picks the Q4 build even when bigger quants would fitwith room to spare — headroom buys window, not quant. Larger buildsstay one tile click away in the pane."""entry = catalog_by_id()["muse-glimmer-30b"]diff --git a/tests/hermes_cli/test_context_policy.py b/tests/hermes_cli/test_context_policy.pyindex 49a31d822fa..ad225cae7f8 100644--- a/tests/hermes_cli/test_context_policy.py+++ b/tests/hermes_cli/test_context_policy.py@@ -341,10 +341,10 @@ def test_launch_args_contract():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."""+ the host compute path measures far slower than letting the+ allocator place everything. 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)diff --git a/tests/hermes_cli/test_unified_pool_quirk.py b/tests/hermes_cli/test_unified_pool_quirk.pyindex bf80e1e8ba3..39c7c23ed7e 100644--- a/tests/hermes_cli/test_unified_pool_quirk.py+++ b/tests/hermes_cli/test_unified_pool_quirk.py@@ -1,11 +1,10 @@"""The unified-pool vendor quirk must never misclassify a discrete card.-Spark-class devices (RTX Spark N1X, measured): nvidia-smi answers from a-16 GiB WDDM carve-out while the CUDA allocator addresses the whole-45.4 GiB unified pool at full bandwidth — decode stays ~200 GB/s-effective 8 GiB past the carve-out. Budgeting from smi there produces-false "larger than your GPU memory" rows and -ot CPU pinning measured-2.3x SLOWER than letting the allocator place everything.+On unified-memory NVIDIA devices under Windows, nvidia-smi answers from+a WDDM carve-out while the CUDA allocator addresses the whole pool at+full bandwidth. Budgeting from smi there produces false "larger than+your GPU memory" rows and -ot CPU pinning that measures far slower than+letting the allocator place everything.The other direction is the regression this file guards: a workstationcard must never be budgeted as UMA. The driver's INTEGRATED attribute@@ -19,10 +18,11 @@ import hermes_cli.local_runtime.hardware as hwGIB = 1 << 30-# Measured Spark N1X shape.-SPARK_SMI_TOTAL = 16320 << 20-SPARK_POOL = 46464 << 20-SPARK_RAM = 48 * GIB+# Representative unified-memory device shape: a 48 GiB box whose smi+# reports only the 16 GiB carve-out while the allocator sees the pool.+UMA_SMI_TOTAL = 16320 << 20+UMA_POOL = 46464 << 20+UMA_RAM = 48 * GIBdef _no_cache(monkeypatch):@@ -34,22 +34,22 @@ def _no_cache(monkeypatch):def test_integrated_attribute_wins_positive(monkeypatch):"""Driver says integrated=True -> unified, no numeric gates needed."""- monkeypatch.setattr(hw, "_device_pool_view", lambda: (SPARK_POOL, True))- assert hw._unified_pool_bytes(SPARK_SMI_TOTAL, SPARK_RAM) == SPARK_POOL+ monkeypatch.setattr(hw, "_device_pool_view", lambda: (UMA_POOL, True))+ assert hw._unified_pool_bytes(UMA_SMI_TOTAL, UMA_RAM) == UMA_POOLdef test_integrated_attribute_wins_negative(monkeypatch):"""Driver says integrated=False -> discrete, even when the numberswould pass both fallback gates (attribute outranks arithmetic)."""- monkeypatch.setattr(hw, "_device_pool_view", lambda: (SPARK_POOL, False))- assert hw._unified_pool_bytes(SPARK_SMI_TOTAL, SPARK_RAM) is None+ monkeypatch.setattr(hw, "_device_pool_view", lambda: (UMA_POOL, False))+ assert hw._unified_pool_bytes(UMA_SMI_TOTAL, UMA_RAM) is None-def test_engine_fallback_spark_shape_passes(monkeypatch):- """Attribute unreadable (engine fallback): the measured Spark shape- passes both gates — 2.85x disagreement, pool ~= RAM."""- monkeypatch.setattr(hw, "_device_pool_view", lambda: (SPARK_POOL, None))- assert hw._unified_pool_bytes(SPARK_SMI_TOTAL, SPARK_RAM) == SPARK_POOL+def test_engine_fallback_uma_shape_passes(monkeypatch):+ """Attribute unreadable (engine fallback): the carve-out shape passes+ both gates — pool several times the smi report, pool ~= RAM."""+ monkeypatch.setattr(hw, "_device_pool_view", lambda: (UMA_POOL, None))+ assert hw._unified_pool_bytes(UMA_SMI_TOTAL, UMA_RAM) == UMA_POOLdef test_discrete_card_agreeing_within_rounding_stays_discrete(monkeypatch):@@ -63,9 +63,9 @@ def test_discrete_card_agreeing_within_rounding_stays_discrete(monkeypatch):def test_ram_matched_workstation_card_stays_discrete(monkeypatch):- """THE case commit 6f5ccf16d7 feared: a 48 GB card in a 48 GB box.- smi and the allocator AGREE (both say 48), so the disagreement gate- fails even though pool == RAM would pass the size gate."""+ """The nastiest lookalike: a 48 GB card in a 48 GB box. smi and the+ allocator AGREE (both say 48), so the disagreement gate fails even+ though pool == RAM would pass the size gate."""monkeypatch.setattr(hw, "_device_pool_view", lambda: (48 * GIB, None))assert hw._unified_pool_bytes(48 * GIB, 48 * GIB) is None@@ -81,46 +81,46 @@ def test_pool_smaller_than_ram_fraction_stays_discrete(monkeypatch):def test_no_probe_available_stays_discrete(monkeypatch):"""No driver API, no engine binary -> exactly today's behavior."""monkeypatch.setattr(hw, "_device_pool_view", lambda: None)- assert hw._unified_pool_bytes(SPARK_SMI_TOTAL, SPARK_RAM) is None+ assert hw._unified_pool_bytes(UMA_SMI_TOTAL, UMA_RAM) is None# ── probe_budget wiring ──────────────────────────────────────-def _spark_machine(monkeypatch, *, view):+def _uma_machine(monkeypatch, *, view):_no_cache(monkeypatch)monkeypatch.setattr(hw, "_nvidia_vram",- lambda: (SPARK_SMI_TOTAL, 14848 << 20))+ lambda: (UMA_SMI_TOTAL, 14848 << 20))monkeypatch.setattr(hw, "_ram_bytes",- lambda: (SPARK_RAM, 32 * GIB))+ lambda: (UMA_RAM, 32 * GIB))monkeypatch.setattr(hw, "_device_pool_view", lambda: view)def test_budget_unified_pool_planning(monkeypatch):- """Planning budget on Spark: the allocator pool itself minus headroom,- uma=True, ram_available=0 — host memory must not double-count as- spill room. NO OS-RAM clamp: in 32/32 carve mode the carved half- vanishes from GlobalMemoryStatusEx, so clamping to OS RAM threw away- exactly the carved capacity (measured: pool ~46.3 GiB constant across- carve settings while OS RAM read 46.2 then 30.2)."""- _spark_machine(monkeypatch, view=(SPARK_POOL, True))+ """Planning budget on unified memory: the allocator pool itself minus+ headroom, uma=True, ram_available=0 — host memory must not+ double-count as spill room. NO OS-RAM clamp: carved-out memory is+ invisible to GlobalMemoryStatusEx (a larger carve shrinks reported+ OS RAM while the pool stays constant), so clamping to OS RAM would+ throw away exactly the carved capacity."""+ _uma_machine(monkeypatch, view=(UMA_POOL, True))b = hw.probe_budget(planning=True)assert b.uma is Trueassert b.ram_available_bytes == 0- assert b.total_device_bytes == SPARK_POOL- assert b.usable_vram_bytes == int(SPARK_POOL * (1 - hw._UMA_HEADROOM_FRACTION))+ assert b.total_device_bytes == UMA_POOL+ assert b.usable_vram_bytes == int(UMA_POOL * (1 - hw._UMA_HEADROOM_FRACTION))# The whole point: the budget must dwarf the carve-out.- assert b.usable_vram_bytes > 2 * SPARK_SMI_TOTAL+ assert b.usable_vram_bytes > 2 * UMA_SMI_TOTALdef test_budget_unified_pool_live_counts_dedicated_free_plus_os_available(monkeypatch):"""Live budget = smi-free + OS-available (each side alone under-counts:smi free saturates at the carve-out, OS-available can't see it)."""- _spark_machine(monkeypatch, view=(SPARK_POOL, True))+ _uma_machine(monkeypatch, view=(UMA_POOL, True))b = hw.probe_budget(planning=False)assert b.uma is Truelive = (14848 << 20) + 32 * GIB- assert b.usable_vram_bytes == int(min(SPARK_POOL, live)+ assert b.usable_vram_bytes == int(min(UMA_POOL, live)* (1 - hw._UMA_HEADROOM_FRACTION))@@ -130,33 +130,33 @@ def test_budget_unified_no_smi_still_classifies(monkeypatch):still budgets the full pool, and live falls back to OS-available."""_no_cache(monkeypatch)monkeypatch.setattr(hw, "_nvidia_vram", lambda: None)- monkeypatch.setattr(hw, "_ram_bytes", lambda: (SPARK_RAM, 32 * GIB))- monkeypatch.setattr(hw, "_device_pool_view", lambda: (SPARK_POOL, True))+ monkeypatch.setattr(hw, "_ram_bytes", lambda: (UMA_RAM, 32 * GIB))+ monkeypatch.setattr(hw, "_device_pool_view", lambda: (UMA_POOL, True))planning = hw.probe_budget(planning=True)assert planning.uma is True- assert planning.total_device_bytes == SPARK_POOL+ assert planning.total_device_bytes == UMA_POOLassert planning.usable_vram_bytes == int(- SPARK_POOL * (1 - hw._UMA_HEADROOM_FRACTION))+ UMA_POOL * (1 - hw._UMA_HEADROOM_FRACTION))live = hw.probe_budget(planning=False)assert live.usable_vram_bytes == int(32 * GIB * (1 - hw._UMA_HEADROOM_FRACTION))def test_budget_discrete_unchanged_when_probe_says_discrete(monkeypatch):"""integrated=False keeps the existing discrete path bit-for-bit."""- _spark_machine(monkeypatch, view=(SPARK_POOL, False))+ _uma_machine(monkeypatch, view=(UMA_POOL, False))b = hw.probe_budget(planning=True)assert b.uma is False- assert b.total_device_bytes == SPARK_SMI_TOTAL- margin = max(hw._MARGIN_FLOOR, int(SPARK_SMI_TOTAL * hw._MARGIN_FRACTION))- assert b.usable_vram_bytes == SPARK_SMI_TOTAL - margin- assert b.ram_available_bytes == SPARK_RAM+ assert b.total_device_bytes == UMA_SMI_TOTAL+ margin = max(hw._MARGIN_FLOOR, int(UMA_SMI_TOTAL * hw._MARGIN_FRACTION))+ assert b.usable_vram_bytes == UMA_SMI_TOTAL - margin+ assert b.ram_available_bytes == UMA_RAMdef test_budget_discrete_unchanged_when_probe_unavailable(monkeypatch):- _spark_machine(monkeypatch, view=None)+ _uma_machine(monkeypatch, view=None)b = hw.probe_budget(planning=True)assert b.uma is False- assert b.ram_available_bytes == SPARK_RAM+ assert b.ram_available_bytes == UMA_RAMdef test_engine_fallback_without_smi_stays_conservative(monkeypatch):@@ -166,11 +166,11 @@ def test_engine_fallback_without_smi_stays_conservative(monkeypatch):attribute-less pool claim alone must never flip the verdict."""_no_cache(monkeypatch)monkeypatch.setattr(hw, "_nvidia_vram", lambda: None)- monkeypatch.setattr(hw, "_ram_bytes", lambda: (SPARK_RAM, 32 * GIB))- monkeypatch.setattr(hw, "_device_pool_view", lambda: (SPARK_POOL, None))+ monkeypatch.setattr(hw, "_ram_bytes", lambda: (UMA_RAM, 32 * GIB))+ monkeypatch.setattr(hw, "_device_pool_view", lambda: (UMA_POOL, None))b = hw.probe_budget(planning=True)assert b.uma is True- assert b.total_device_bytes == SPARK_RAM # RAM path, not the pool+ assert b.total_device_bytes == UMA_RAM # RAM path, not the pooldef test_smi_resolver_caches_and_survives_empty_path(monkeypatch):@@ -194,12 +194,12 @@ def test_pool_probe_hit_is_cached_for_process(monkeypatch):def probe():calls.append(1)- return (SPARK_POOL, True)+ return (UMA_POOL, True)monkeypatch.setattr(hw, "_cuda_driver_pool", probe)monkeypatch.setattr(hw, "_engine_device_pool", lambda: None)- assert hw._device_pool_view() == (SPARK_POOL, True)- assert hw._device_pool_view() == (SPARK_POOL, True)+ assert hw._device_pool_view() == (UMA_POOL, True)+ assert hw._device_pool_view() == (UMA_POOL, True)assert len(calls) == 1@@ -208,7 +208,7 @@ def test_pool_probe_miss_retries_after_ttl(monkeypatch):mid-session via the pane's runtime install."""_no_cache(monkeypatch)monkeypatch.setattr(hw, "_cuda_driver_pool", lambda: None)- answers = [None, (SPARK_POOL, None)]+ answers = [None, (UMA_POOL, None)]monkeypatch.setattr(hw, "_engine_device_pool", lambda: answers.pop(0))now = [1000.0]@@ -217,7 +217,7 @@ def test_pool_probe_miss_retries_after_ttl(monkeypatch):now[0] += 1.0 # inside TTL: cached miss, no re-probeassert hw._device_pool_view() is Nonenow[0] += hw._POOL_NEGATIVE_TTL_S + 1.0- assert hw._device_pool_view() == (SPARK_POOL, None)+ assert hw._device_pool_view() == (UMA_POOL, None)assert not answers@@ -225,9 +225,9 @@ def test_pool_probe_miss_retries_after_ttl(monkeypatch):def test_device_line_regex_handles_parenthesized_names():- """Real Spark line: the device name itself contains parentheses —- the LAST group must win."""- line = (" CUDA0: NVIDIA RTX Spark N1X (5120-core Blackwell RTX GPU) "+ """Device names may contain their own parentheses — the LAST+ parenthesized group must win."""+ line = (" CUDA0: NVIDIA Example Device (1234-core Example GPU) ""(46464 MiB, 46284 MiB free)")m = hw._DEVICE_LINE_RE.search(line)assert m and int(m.group(1)) == 46464