Explore scratchpad · NVIDIA/hyperflare-inference #659

Raw Markdown for agents: https://autobot.eidonix.com/p/28de2a0b-5de5-42b3-aa71-ee5f6a6e8f0f.md

#1 [high] Change: what the diff actually does (3 files, +196/−33)

PR #659 (head 16e2247, base main, author lukealonso), 3 files +196/-33. No comments/reviews yet, CI passed.

Core mechanism: null continuation row 0 (for models with sizing.capacity == 0 state_pool rows) previously got its own physical VMM allocation for its whole padded span (fixed_bytes = ceil(execution*row_bytes / align)*align, cache_memory.rs:157). Now the full leading granules of row 0 are each cuMemMapped onto ONE shared alignment-sized physical handle:

Planner side (memory.rs): new row_backing_bytes(core, units) (memory.rs:383-414) = padded span minus sentinel_saved_bytes when units>0; replaces bytes(core,0,execution) at memory.rs:486 (fixed footprint check), :510 (:523) fits/minimum-footprint binary search, :1003 (minimum cache footprint), :1249 (gpu_bytes reporting in NativeModel sizing loop). Virtual-span arithmetic deliberately kept on full bytes(core,0,...): memory.rs:576-579 (mapped = bytes(core,0,execution) + borrowed, cached-rows loop).

Docs: docs/runtime-core-design.md:770-779 documents the null-row sentinel aliasing and savings formula; :829-833 updates DCP16 RM-handle example 518,232 → 518,504 handles, headroom 6,056/1.2% → 5,784/1.1%.

#2 [high] Claim support: row zero never mutated is enforced in Ignition, not in Helios

The "row zero is never written" contract the aliasing relies on is enforced outside the runtime, in Ignition and the docs:

#3 [high] Related work: change spends the mapping-handle headroom #391 established

Verified by hand from the diff: for the DCP16 fixture (row_bytes 35,122,432, alignment 2 MiB → 16 sentinel granules, handle_charge(1, &readers) so row_readers = 1), old per-rank fixed charge = 1+1 = 2; new = (1 + 16*1) + (1 + 1) = 19, i.e. +17 per rank, ×16 ranks = +272 → 518,232 + 272 = 518,504, exactly the value in helios/src/runtime_core/cache_memory.rs:819,833 and docs/runtime-core-design.md:832. The PR body's "272 extra handles" is not stated but the docs update is arithmetically consistent. Consequence: this change consumes headroom that #391 (merged) created and documented. docs/runtime-core-design.md:829-833 now reads 5,784 handles / 1.1% (was 6,056 / 1.2%). In #391 the reviewer (yatesdr) made handle margin a blocking topic (review 2026-11-19, item 2: "no margin for the other driver objects ... state the margin the estimate needs"), so the margin shrinking is a live reviewer concern. Cost scales with row readers: handle_charge charges sentinel_granules * row_readers mappings (cache_memory.rs:84-98), so a peer-read row plane costs up to 39 × readers mappings per rank (e.g. 16 readers → 624 extra mappings/rank) — this is the mechanism that makes the memory saving cost handles. Net effect on layouts near the 524,288 RM limit is negative.

#4 [high] Claims and evidence: tests added, updated, and one GPU assertion weakened

Tests changed by the PR:

#5 [high] Related work: #473, #391, #286 are the direct ancestors of the touched code

Predecessor work in the exact same mechanism, all merged on main:

#6 [high] Research summary

Case file for PR #659 (perf(helios): alias null continuation row zero onto a single zeroed VMM granule), head 16e2247, base main, 3 files +196/−33, opened and last updated 2026-12-01, no comments or reviews, CI passed on head. Findings are in scratchpad entries 1–5 (change, claims/evidence, related work, row-zero contract, handle arithmetic).

What it does (verified from the diff). Layout gains sentinel_granules = row_bytes/row_alignment when >1 (cache_memory.rs:259-267) and sentinel_saved_bytes (cache_memory.rs:68-71); allocate_shared_cache now maps row 0's leading full granules onto one shared alignment handle via N cuMemMap calls on a single cuMemCreate handle, backs the sub-granule tail separately, and zeroes one granule plus the tail instead of the whole span (cache_memory.rs:1416-1488). Planning switches from bytes(core,0,units) to a new row_backing_bytes (memory.rs:383-414) in four places — fixed/minimum footprint checks and the KV page search (memory.rs:486, 510, 523, 1003) and gpu_bytes reporting (memory.rs:1249) — while virtual-span arithmetic stays on full bytes (memory.rs:576-579). Docs get a new paragraph (runtime-core-design.md:772-780) and a re-baselined RM-handle example (518,232→518,504; 6,056/1.2%→5,784/1.1%, runtime-core-design.md:829-833). I found nothing the description omits materially, and nothing it claims that the code does not do; the one undeclared side effect is the handle cost (below).

The thing a reader cannot get from the description. The saving is paid for in mapping handles: handle_charge now charges sentinel_granules * row_readers mappings plus a handle (cache_memory.rs:82-98). For the DCP16 fixture that is +17 per rank, +272 across 16 ranks — the exact 518,232→518,504 in the updated test and docs. So this PR spends the 1.2% headroom that #391 (voipmonitor, merged 2026-11-21) created and whose margin yatesdr made a blocking review topic in #391 ("no margin for the other driver objects … state the margin the estimate needs"). Cost scales with readers, so a 16-reader row plane costs up to 39×16 = 624 extra mappings per rank; layouts already near the 524,288 RM limit move toward failure while low-reader single-rank cases win VRAM. The description says nothing about this trade-off.

Row-zero contract. The premise is verifiable in tree but enforced outside Helios: ignition/components/state.py:76-80, 190-197, 229, ignition/components/state_transfer.py:78-80, docs/core-design.md:1497-1500, docs/design-review.md:80, and Helios allocations starting at row 1 (helios/src/scheduler.rs:946-948, 1753). Helios itself has no guard rejecting a write to row 0 — helios/src/offload/transfer.rs:156-163 only bounds-checks against row_capacity — so "inactive lanes don't mutate row zero" is a cross-component assumption, not a runtime-checked invariant. The description states this as a limitation.

Evidence. Two new CPU tests (cache_memory.rs:1366-1385; memory.rs:2030-2049) pin the formula, granularity edge cases, and the 158 MiB→82 MiB / KV-page-gain claim; handle-count expectations re-baselined at cache_memory.rs:818-834. Author reports 191 passed / 0 failed / 11 ignored for runtime_core:: on a747a5a5. The GPU test cuda_aliases_preserve_rows_while_unowned_pages_are_rewritten is weakened: row 0 is excluded from the distinct-pattern upload (.skip(1), cache_memory.rs:1226) and now only checked for staying zero — and it was not run (author: all local GPUs occupied), as with #473 and #391 before it.

Related work and recent activity. The touched mechanism is a chain of merged work: #286 (multi-address cuMemMap snapshot aliasing, peer readers), #391 (handle_charge, RM_HANDLE_RANGE, plan_mapping_handles, the DCP16 fixture this PR re-baselines), #473 (original-el8 — the plane_bytes clamp and u32::MAX..0→0..0 sentinel normalization the aliasing depends on, plus the GPU test this PR edits), #504/#492/#486/#477/#436 (yatesdr, same three files). No open PR competes, and no issue asks for this specific saving; searches for row-zero/null-row VRAM returns only this PR. Adjacent but not a fix: #517 (closed, Xid 31 in _checkpoint_pages), whose root cause turned out to be int32 page arithmetic in a recipe, not row allocation.

People, community, process. Author lukealonso is a priority contributor per the charter with 35 merged PRs in 180 days and is one of the two dominant committers in helios/src and docs (234 and 389 commits); reviewers in this area are yatesdr and, historically, voipmonitor/original-el8. No engagement yet on this PR. Charter fit is good on "measured memory issue" and model-agnosticism (the change is in shared planning code, no per-model branch), and the description follows the required four-part scheme with a Discord line. Process gaps worth noting: the description explicitly discloses unrun CUDA/VMM checks, while docs/design-review.md:247-251 says disclosure of skipped runnable CPU checks blocks acceptance and GPU-layer checks are mandatory per the testing hierarchy — the author treats GPU VMM checks as unrunnable due to hardware contention, the same position accepted in #391 and #473. No Design-Signed-Off-By/Signed-off-by verification was possible for the single commit 16e22476.

#7 [high] People: author standing and who works these files

Author: lukealonso, COLLABORATOR, named in docs/design-review.md:42 (charter "Respect contributors") as a priority contributor (@voipmonitor, @original-el8, @lukealonso) whose PRs "we never close out of hand as low value".

#8 [high] Process and project fit: charter, testing hierarchy, PR state

PR state: open, "ready for review", opened 2026-12-01, last updated 2026-12-01, single commit 16e22476, CI passed on head. No reviews, no labels. Files: docs/runtime-core-design.md (+8/−3), helios/src/runtime_core/cache_memory.rs (+122/−23), helios/src/runtime_core/memory.rs (+66/−7).

Charter fit (read_charter):

Design-review rules touched:

#9 [medium] Reach: who and what the change affects, and the docs' own qualification scope

Affected population (from code + docs, not measured):

Capacity shift: because row_backing_bytes feeds capacities (memory.rs:486-531, 1003) and the KV-page search, identical hardware and flags will now plan more KV pages (and more snapshot rows) than before. sentinel_row_savings_increase_kv_page_capacity (memory.rs:2030-2049) shows 82 MiB rather than 158 MiB for 2 rows and a corresponding page gain under a 900 MiB budget. Consequence for operators: planned rows/pages (uploaded as memory_capacity at memory.rs:1318-1330) change between engine versions on the same model — documented as intended in docs/runtime-core-design.md:772-780, but it means a memory-limit that previously errored can now succeed and a previously tight budget now plans more. Also note the doc's own caveat at docs/runtime-core-design.md:840-845: prefix-compacted placement is qualified only on sixteen RTX PRO 6000 Blackwell GPUs with driver 615.71.10 (Kimi K3.1 Pro TP16 DCP8/DCP16), and wide-group compaction is CPU-unit-tested only — the DCP16 handle numbers this PR re-baselines inherit that same narrow qualification. Deployment: no effect on multi-host agreement (docs/runtime-core-design.md:835-838 — page/row counts unchanged in shape, canonical layout retained), and local_handle_limit still gates compaction to single-host Linux (cache_memory.rs:499-501).

#10 [medium] Related work: #517 is adjacent (continuation rows) but not the motivation; recent file history

#517 (jcartu, closed 2026-11-28) "Xid 31 in _checkpoint_pages … rank-0 fault addresses map to continuation rows 3,216–3,224" looks like a motivation for touching continuation-row backing, but it is not: the root cause was established as signed-32-bit page * 16,384 overflow in a recipe kernel (local-inference-lab/hyperflare-recipes#45), fixed by a tl.int64 correction plus re-export of affected Qwen3.8 cores. Row allocations were never wrong; the issue itself corrects that reading. It is relevant only as evidence that continuation-row address arithmetic has produced expensive production faults, and as prior art for the "guard the final byte range" discussion. Related closed PR #520 ("Assert snapshot slots reaching device transfer commands stay in the planned range") is in the same family. #504 (yatesdr, merged 2026-11-25) touches all three files (#659's files) with the KV-compression pipeline; #492/#486/#477/#436 (yatesdr) same files, closed/merged. These are the most recent prior changes to cache_memory.rs/memory.rs other than #473/#391/#286 and do not overlap the null-row path.

Recent commits to helios/src/runtime_core/cache_memory.rs (pr/659 history): 16e22476 (this PR), 6d74db3a "Fix Rust compiler warnings…" (Luke Alonso, 2026-11-26), 716df00f #504, 7b04dd1e #473, 110e1409 #391, b003ebf5 "Remove cache peer-access memory diagnostics" (Luke Alonso, 2026-11-14), d7a20816 #286. So the layout code has changed three times in ten days by three different authors (#473 original-el8 2026-11-25, #391 voipmonitor 2026-11-21, #504 yatesdr 2026-11-25) — a fast-moving area, and this PR re-baselines assertions those authors wrote. Default-branch commit after the PR branched that touches these files: 1da22724 (#652, Luke Alonso, docs/runtime-core-design.md) — docs only, no conflict expected with the two doc hunks at :770 and :829.