Review — PR #590 "helios,ignition: fix Engram reader bugs and add PLE lookahead publish"
Lens: conventions and duplication. Head reviewed: 6fe7bed. Merged, 5 files, +464/−103. CI on head passed. No human reviews.
Key findings
- Nothing blocking and nothing should-fix. The PR is net de-duplicating: it removes two hand-maintained copies of the Engram
GraphKindlist and one of two divergent lane-dispatch implementations, and it adds an interface that follows an existing one rather than inventing a new one. - I withdraw the one should-fix finding from my own 2026-11-28 review of this PR. I reported
PreparedPLELookup.publish_lookahead's per-call GPU allocation as a violation of AGENTS.md:177 / :417-419 on the grounds that the Engram twin reuses prepared buffers. At 6fe7bed that premise is false:PreparedEngram.publish_lookahead(ignition/components/engram.py:280-283) passes neitherargs=nordest=to_hash_window, whose default path (engram.py:241-254) allocatesmask,slots,compressed,requestsandfull_hasheson every call — five tensors, more than the PLE method's two. The buffer reuse I attributed to the twin lives in__call__(engram.py:273-277), not inpublish_lookahead. The PLE method therefore follows #566's merged precedent; the finding drops from should-fix to nit (nit 5 below). - Both should-fix findings from my previous review are fixed in 6fe7bed and are not re-raised: Windows
Readers::gathernow calls the sharedlane_fanout(helios/src/engram/reader/windows.rs:9,91, helper atreader.rs:40, Unix use at:810), and the/proc/self/fdreopen failure is carried into theEPERMdiagnostic instead of being dropped via.ok().WaitBackoffwas removed from the tree entirely. - Five nits, all duplication/consistency, none behavioural. Details below.
Findings
Should fix
None.
Nits
Nit 1 — ignition/components/ngram_delivery.py:78-95: _advisory_requests is _requests (:59-75) with two Triton constexpr flags flipped.
The bodies are identical apart from _copy_requests(..., HAS_LIMIT=True) at :88 vs False at :68, and _publish(..., HAS_COUNT=True) at :89 vs False at :69. The kernels already parameterize on those flags (_copy_requests :17-25, _publish :29-33), so nothing is duplicated at the kernel layer — the duplication is one whole custom op, its signature (live_rows vs the mailbox passed twice) and its register_fake stub (:92-95).
It also departs from the decomposition this same PR series established: PreparedEngram shares hashing in _hash_window (engram.py:241-271) and keeps publication as a separate mailbox op, publish_requests (ngram_delivery.py:36-39) or publish_advisory_requests (:47-51), chosen at the call site (engram.py:273-283). The PLE path instead has two full hash+copy+publish ops, and because the new one is registered as flare::ple_advisory_requests it now sits directly beside the pre-existing publish_advisory_requests (:47) — "advisory requests" names two different layers.
Fix, cheap: one parameterized Python body for both ops (live_rows=None), or rename the new op so it does not read as a sibling of publish_advisory_requests.
Why nit and not should-fix: AGENTS.md:192-193 ("Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost") argues against demanding that the shipped _requests be split apart just to remove this copy, and the two-op shape keeps each captured op's mutates_args exact.
Nit 2 — helios/src/engram.rs:552-554: warm_batch is a fourth spelling of the staged-row bound.
WARM_BATCH_ROWS.min(max_tokens.saturating_mul(table.heads)).max(1) recomputes a product the same file already derives three other ways: max_tokens.checked_mul(table.heads) at :484-486 (which is exactly the CachedReader::max_rows the new warm chunks by), and the unchecked self.max_tokens * self.index.tables[table].heads at :663 and :686. It is computed once more in runtime_core/engram.rs:242-244 and engram/prepared.rs:228-230.
The .max(1) cannot fire in practice: with_readers rejects max_tokens == 0 (engram.rs:521), heads == 0 is rejected at prepared.rs:66-68, and runtime_core already errors when max_staged_rows overflows (:242-244).
Fix: a Table::capacity_rows(max_tokens) -> Result<usize> beside the existing Table::staging_payload_bytes (engram.rs:193-200), which is this codebase's established shape for per-table bounded geometry, so Shared::new, warm_batch, validate_start and start share one definition. Minimally, a comment tying warm_batch to CachedReader::max_rows: the two must agree, or warm re-chunks and the advisory warming does redundant disk reads.
Note: saturating is strictly safer than the plain * at :663/:686, so this is a consistency cost, not a defect.
Nit 3 — helios/src/engram/reader.rs:1097-1156: CachedReader::warm repeats gather's tail (:1017-1095).
Both build and filter miss_ids, filter by cache presence (pin_if_present vs the cache.get loop), call self.disk.gather(planes, &self.miss_ids, &mut self.miss_output[..]), and split each miss into its w/s slices using the same count * weights + index * scales arithmetic. The differences are insert_advisory vs insert, copying into the output, and the new per-chunk prefetch_rows_loaded bump.
warm already duplicated gather before this PR; the chunk loop deepens the copy by roughly 40 lines. Defensible under AGENTS.md:192-193, flagged only because the duplicated miss_output indexing is where a future row-width change would silently desynchronize the two. Factoring the "miss → disk gather → split into w/s" tail into one helper taking an insert closure would remove it.
Nit 4 — helios/src/engram.rs:785-811: Transfers::new restates validate_mailbox's capacity arithmetic (helios/src/runtime_core/engram.rs:287 shape[0].checked_mul(8), and :303-322 max_staged_rows + 1 / + 2).
The two layers legitimately differ in scope — runtime_core checks the declared shape against the max staged rows across all cores, engram.rs checks the mapped buffer's byte length against max_tokens * heads from the shared index, and Transfers::new is the layer that actually holds the address — so having the check there is correct and closes the real address + nbytes - 8 gap. Recorded only because, if the two drift, the symptom is a startup error whose message points at the wrong layer ("smaller than staged capacity" vs "invalid mapped n-gram request mailbox"). A one-line comment naming the twin removes the cost.
Nit 5 — ignition/components/ngram_delivery.py:157-164: publish_lookahead allocates two token-shaped tensors per call, where its same-class sibling publish (:148-155) reuses self.requests prepared in __init__ (:122) and allocates only for the functional() case (:151-152).
This is the corrected, downgraded version of my earlier should-fix (see Key finding 2). Two tensors per lookahead publish is less than the Engram precedent's five (engram.py:241-254), so there is no rule violation to report and no inconsistency with #566. What remains is in-class inconsistency: two methods on one class with two different buffer policies.
Fix if the author wants it: hoist ids/requests beside self.ids/self.requests, keeping publish's None fallback shape.
What would settle it: whether publish_lookahead runs once at capture or per step. A tree-wide search finds publish_lookahead in exactly two places (engram.py:280, ngram_delivery.py:157), and no test in this repository exercises it — its only caller is the companion recipe local-inference-lab/hyperflare-recipes#87, outside this repo. So this cannot be settled here.
Checked and found consistent (do not chase these)
GraphKindfilters — the PR adopts an existing precedent.runtime_core/engram.rs:224and:333now both use.filter(|g| GraphKind::try_from(g.kind.as_str()).is_ok_and(crate::engram::consumes)), which is the expression already present atruntime_core/model.rs:480-481. Two hard-coded five-kind lists are gone;consumes(engram.rs:948-958) is now the single definition and includesScoredPrefill(:953), matching its six call sites inexecution/transport.rs(not opened) and two inengram/prepared.rs.runtime_core/selection.rs:318(not opened)'s"init"|"restore"|"snapshot"|"resume"list is a different set (lifecycle kinds) and is correctly left alone.validate_mailboxallocation bounds follow precedent.runtime_core/engram.rs:289-296(offset.checked_add(nbytes) <= a.nbytes) matches the existing shape atruntime_core/protobuf.rs:314-322.checked_mul(8)mirrors the same file'sexpected_nbytescomputation (:246-248) andformat.rs:343-345.- The
/proc/self/fdreopen is not a duplicate of an existing helper.eos/src/unix.rs:60-65direct_reopenaddsO_DIRECT(:43) and cannot back anmmap;eos::map_host(:85-103) is anonymousMAP_PRIVATE|MAP_ANONYMOUS, a different job frommap_fd'sMAP_SHAREDon an fd. The newopen_readonly_view(reader.rs:123-126, plain read-onlyFile::open) has no counterpart to reuse. It introducescfg(target_os = "linux")into a file that otherwise usesunix/windows— unavoidable, and thecfg(not(target_os = "linux"))arm keeps macOS building. - Windows/Unix lane gather bodies remain separate but are not newly duplicated —
windows.rs:122-205(ReadRing::read_all) vsUnixLane::gather(reader.rs:486) were already distinct and differ materially. Only the planner was duplicated, and the PR removed that. ReaderAction::Warmclamp (engram.rs:614) keeps the pre-existing(cursor + n).min(len)form; only the increment constant changed.- Counter relocation is clean.
prefetch_rows_loadedmoved fromReader::warminto per-chunk bumps inCachedReader::warm(reader.rs:1149-1152), so it still counts rows once and no longer double-counts. The metric names indocs/cli-design.md:816(not opened) andhelios/README.md:671(not opened) remain accurate. - Test conventions. New Rust tests reuse the files' existing temp-file/
Plane/Statsshapes. A pure-table test of the shared helper (reader.rs:2236-2248, covering 1/2/4/8 workers,lane_fanout(0,1) == None,(128,4) == Some((4,32)),(80,8) == Some((5,16))) is the right place, since both backends call it. - Backward compatibility (AGENTS.md:432-437). The new load-time rejections in
Transfers::newandruntime_core::engram::decodecan only fire when a mapped mailbox is genuinely shorter thanmax_tokens * heads (+1/+2)slots or whenshape[0] * 8overflowsu64. In-repo fixtures build mailboxes at exactlymax_staged_rows + 1/2(runtime_core/engram.rs:590,680), so no existing exported core requires re-export and no reader was removed.
Open questions
- Is
PreparedPLELookup.publish_lookaheadcalled once at graph capture or per decoding step? Nothing in this repo answers it (no test, two call-site-free definitions);hyperflare-recipes#87does. If per step, nit 5 becomes worth fixing as a real steady-state allocation. - Nit 2's suggested
Table::capacity_rowsis a mild refactor of shipped code — worth it only if the team expects the staged-row bound to keep spreading; AGENTS.md:192-193 cuts both ways here.
Coverage
All five changed files read at head 6fe7bed in context, with callers followed for the behaviour changes: helios/src/engram/reader.rs (lane_fanout, ResidentMapping/map_fd/open_readonly_view, UnixLane/DiskReader::gather, CachedReader::gather/warm, Reader::warm/from_files, Resident::initialize), helios/src/engram/reader/windows.rs (whole), helios/src/engram.rs (AdvisoryMailbox, Requests, Shared::new/with_readers/warm loop/validate_start/start, Transfers::new/enqueue, consumes, staging and prefetch budgets), helios/src/runtime_core/engram.rs (both graph filters, validate_mailbox, tests), and ignition/components/ngram_delivery.py (whole file) against ignition/components/engram.py:170-284. Rules read: the charter in full and AGENTS.md. Cross-checked precedents: runtime_core/protobuf.rs bounds checks, runtime_core/model.rs:478-500, runtime_core/selection.rs:318 (not opened), engram/prepared.rs, eos/src/unix.rs.
Verdict: clean — no blocking, no should-fix; 5 nits.