PR #664 correctness / contracts / system-consequences review (head fd6dad6, 23 files, +1711/−550)
Method caveat, stated up front: pr_diff failed on every call (fatal: bad revision 'cc0a49d2…fd6dad6'), so every head-vs-main statement below comes from paired read_file reads at the PR head and at ref: main, and every citation names the lines I opened at this head during this review.
Key findings
- Major — the schema and the decoder both accept
Encoding.BF16withMethod.XOR_MODULO, i.e. raw 2-byte-wide rows indexed by 24 lookup heads. Nothing constrains hashing by encoding, so a signed core can allocate ~3.28 GiB of pinned host staging at 4,096 tokens instead of the ~140 MiB the shipped IDENTITY layout needs — 24× amplification on the exact bottleneck this PR exists to relieve, rejected only by the generic memory-budget check. - Minor — the PR's new "exporter cannot sign what Helios refuses to load" property holds for shard contiguity only, not for per-encoding geometry. Schema never cross-checks encoding against
embedding_width256/160,scale_block32/16, or Nvfp4global_scale > 0, nor the hash geometry, all of whichruntime_core/engram.rsrejects. - Minor — docs document BF16 and IDENTITY separately and never the combination the code accepts (
helios/manifest.md:457-463), so an operator or producer reading the spec cannot learn that the 24-head mode is legal. - Sound (verified, should not be re-litigated): the
Planes { weights, Option<scales> }propagation, delivery-group grouping viaIndex::shares_delivery_with+Table::partition, gather-ID validation including-1zero-fill, the Windows lane mirror, exporter optional-scale/null handling,flare_engram_resident_scale_bytes = 0for single-plane tables, and the Python↔Rust descriptor pairing. - The Discovery Dossier's two blockers stand unchanged (owner approval for the two appended enum values per
AGENTS.md:376-381; CI plus one legacy FP8/NVFP4 replay), and I found nothing in this lens that softens them.
1. Correctness, safety & platform parity
F1 (Major) — BF16 + 24-head XOR_MODULO is accepted end-to-end, with 24× host staging amplification
The signing validator constrains the hash method only by whether the token map is empty, never by encoding — helios/src/core/schema.rs:397-411:
if token_map_empty {
if !matches!(
method,
wire::engram_hash::Method::EosXorModulo | wire::engram_hash::Method::Identity
) || table.request_buffer.is_empty()
{
return Err(invalid(
"engram without a token map requires request delivery with EOS XOR or identity indexing",
));
}
} else if method != wire::engram_hash::Method::XorModulo {
return Err(invalid(
"engram with a token map requires XOR-modulo hashing",
));
}
The encoding checks immediately above are about scale metadata only (helios/src/core/schema.rs:372-379 rejects scale fields for single-plane tables), and the BF16 branch at :428-436 pins only the plane byte size. So encoding = BF16 + a non-empty token_map + method = XOR_MODULO signs cleanly.
The decoder then rewards that combination with 24 heads while IDENTITY gets 1 — helios/src/runtime_core/engram.rs:165-174:
let (order, heads) = match method {
wire::engram_hash::Method::XorModulo if !value.token_map.is_empty() => (Some(4usize), 24usize),
wire::engram_hash::Method::EosXorModulo if gpu && value.token_map.is_empty() => {
(Some(3usize), 16usize)
}
wire::engram_hash::Method::Identity if gpu && value.token_map.is_empty() => {
(None, 1usize)
}
_ => return Err(invalid("unsupported n-gram hash method or request source")),
};
while BF16 rows are two bytes per element — helios/src/runtime_core/engram.rs:146-154:
wire::engram_table::Encoding::Bf16
if table.embedding_width > 0 && table.global_scale.to_bits() == 0 =>
{
let row_bytes = usize::try_from(table.embedding_width)
.ok()
.and_then(|width| width.checked_mul(2))
.ok_or_else(|| invalid("BF16 embedding row width overflow"))?;
(table.embedding_width, 0, row_bytes, None)
}
Heads multiply the whole staging payload — helios/src/engram.rs:204-208:
fn staging_payload_bytes(&self, max_tokens: usize) -> Result<usize> {
self.planes.iter().try_fold(0usize, |total, plane| total.checked_add(plane.row_bytes))
.and_then(|bytes| bytes.checked_mul(self.heads))
.and_then(|bytes| bytes.checked_mul(max_tokens))
.ok_or_else(|| "embedding staging exceeds host range".into())
}
and there are two pinned frames per table — helios/src/engram.rs:348 (const STAGING_FRAMES: usize = 2;), summed at helios/src/engram.rs:212-219, with max_staged_rows = tokens * core_heads at helios/src/runtime_core/engram.rs:294-296:
let max_staged_rows = tokens
.checked_mul(core_heads as u64)
.ok_or_else(|| invalid("Engram staging row count overflow"))?;
Arithmetic at max_tokens = 4096 and the E2B PLE row width the PR quotes (17,920 B = 8,960 bf16 elements):
- XOR_MODULO: 4096 × 24 × 17,920 × 2 = 3,522,447,360 B ≈ 3.28 GiB pinned host;
- IDENTITY (shipped): 4096 × 1 × 17,920 × 2 = 146,800,640 B ≈ 140 MiB.
Impact: a second producer or a future recipe that keeps the existing two-plane token-map shape and merely flips encoding to BF16 silently costs 24× the host staging — ~3.1 GiB avoidable — which is precisely the unified-memory pressure the PR is meant to relieve. There is no producer, test, or doc line covering BF16+XOR_MODULO, so the failure would surface first as an opaque memory-budget rejection in check_memory_limit (helios/src/runtime_core/model.rs:764-770, "embedding tables, staging, and row cache exceed the memory budget"), not as a validation error naming the real mistake.
Fix: reject non-IDENTITY methods when encoding == Encoding::Bf16 in both schema::validate_engram (next to the :428-436 BF16 pin) and the decode arm at runtime_core/engram.rs:165-174, or bound heads for single-plane encodings and document the bound. Either is a few lines and keeps the two-plane tags untouched.
F2 (Minor) — publish-time parity is still incomplete for per-encoding geometry
helios/src/core/schema.rs:366-370 validates only non-zero rows/width before the BF16 size pin:
for table in &engram.tables {
let has_scales = engram_encoding_has_scales(table.encoding)?;
if table.rows == 0 || table.embedding_width == 0 {
return Err(invalid("engram table has no rows or width"));
}
The decoder requires encoding-exact geometry — helios/src/runtime_core/engram.rs:139-145:
let (width, block, row_bytes, scale_bytes) = match encoding {
wire::engram_table::Encoding::Fp8E4m3E8m0 => (256, 32, 256usize, Some(8usize)),
wire::engram_table::Encoding::Nvfp4E4m3Global
if table.global_scale.is_finite() && table.global_scale > 0.0 =>
{
(160, 16, 80usize, Some(10usize))
}
and enforces it at helios/src/runtime_core/engram.rs:177-178 (table.embedding_width != width || table.scale_block != block), plus hash-geometry checks that exist only in the decoder (:209-234, "invalid Engram hash geometry"). Impact: heliopause's verify_published (heliopause/src/export/core.rs:3017) can still sign a core that Helios refuses at load — the same defect class the PR closes for gapped shards only (heliopause/src/export/core.rs:5306-5336). The PR's claim is accurate as scoped but partial; a reviewer should not read it as full signing/loading parity. Fix: extend schema::validate_engram to call the same width/block/global-scale and hash-geometry predicates the decoder uses (or share one helper), so signing and loading cannot disagree.
F3 (Minor) — docs omit the accepted BF16+XOR_MODULO mode
helios/manifest.md:457-463:
Single-plane `BF16` tables store raw `embedding_width * 2`-byte rows without a
scale plane (`scales` absent, `scale_buffer` empty, `scale_block == 0`,
`global_scale == 0`). Tables with `EngramHash.Method.IDENTITY` use one lookup
head (`heads = 1`), empty `token_map` and hash arrays, `compressed_vocabulary == rows`,
and GPU request delivery (`request_buffer`): captured code publishes one `int64`
row ID per token in `[0, stored_rows)` (converting to partition-local indices
when sharded) or `-1` for inactive slots; out-of-range row IDs fail gathering.
docs/core-format-design.md:94 is the only other BF16 mention. Both describe BF16 and IDENTITY as separate facts and never state whether BF16 may carry a token map. Combined with F1 this is an observability/documentation gap, not just a nit: the format spec is the contract a second producer reads. Fix: one sentence either way — "single-plane BF16 tables are IDENTITY-indexed only" (with F1's validator change) or the documented head bound.
1b. Areas checked and found sound (report plainly, do not re-litigate)
- Delivery grouping fix is real and load-bearing.
helios/src/engram.rs:195-201:
consumed at/// Two ranks share one delivery group only when every table matches in /// planes, bindings, and partition ownership (`Table::partition`). pub(crate) fn shares_delivery_with(&self, other: &Self) -> bool { self == other }helios/src/runtime_core/model.rs:458-465, with the partition key set athelios/src/runtime_core/engram.rs:407. Two TP ranks holding byte-identical shard bytes no longer collapse into one mailbox group — the pre-existing hazard this PR closes correctly. - Scale upload is correctly skipped for single-plane tables (
helios/src/engram.rs:1014-1023: the upload runs only underif let (Some(scales_dst), Some(scales_plane))), so no read of an absent plane and no unintended H2D. flare_engram_resident_scale_bytes = 0for single-plane tables is genuinely enforced, not merely reported:helios/src/engram/reader.rs:1362-1370guards the resident-scale load withif let Some(scale_plane) = planes.scales, so the counter never increments. The PR's metric claim holds.--embedding-table-resident-scalesrejection is coherent —helios/src/runtime_core/selection.rs:52-76: an explicitSome(true)errors when there are no tables or no table has a scale plane, andembedding_resident_scalesgates onhas_scale_planesfor the default path, so single-plane catalogs neither error spuriously nor claim resident scales.- Gather-ID validation semantics are unchanged (
helios/src/engram/reader.rs:1416-1423:*id < -1or>= plane.nbytes / plane.row_byteserrors), so IDENTITY's-1inactive-slot zero-fill keeps the two-plane behavior, including the out-of-range failure the docs promise. - Platform parity:
helios/src/engram/reader/windows.rsmirrors the Unix lane fan-out with the samePlanesshape; I found no Unix-only assumption introduced by the refactor. (The build was still not exercised — author Limitations line, see Dossier Blocker 2.) - Python↔Rust descriptor pairing:
ignition/preparation/rank_group.py:47(expected = sum(len(table["planes"]) for table in catalog["tables"])) matches the Rust pairing inheliopause/src/embedding_tables.rs:41-62andhelios/src/engram/prepared.rs, i.e. 1 or 2 descriptors per table with the scale name present only when the plane is. Mixed-plane handoffs therefore count correctly.
2. Unintended system-level consequences
The only system-level hazard I found is F1: it is a memory-amplification bug whose blast radius is host pinned memory (shared with row cache and prefix-cache budget) and whose trigger is a legal-but-undocumented format combination. The staging path itself is unchanged in structure — two frames, one sync channel of depth STAGING_FRAMES (helios/src/engram.rs:700), one worker per table by default (helios/src/runtime_core/selection.rs:47-50) — so I found no new lock contention, head-of-line blocking, unbounded retention, or hot-path reversal introduced by the Planes refactor. The Option-plane changes are a strict widening of the same control flow: every place that used to index [Plane; 2] now guards the scale plane, and the guard is on the cold path (open/load/upload), not per-row on the gather path.
On the metric/rate span check the lens asks for: this PR changes what bytes are counted (staging_bytes now sums one plane for single-plane tables, helios/src/engram.rs:212-219) but not when or over what span it samples — it stays an end-to-end pre-open estimate feeding check_memory_limit, not a disk-thread-only or rank-0-only measure, so no threshold silently changed meaning. resident_scale_bytes remains an all-shard sum and correctly reads zero for single-plane catalogs.
3. Architecture, contracts & charter compliance
- Captured-graph operation contract (Blocker, carried from the Dossier and confirmed here).
AGENTS.md:376-381is unambiguous:- Introducing a captured-graph operation family requires prior explicit approval from project owner Luke Alonso <lalonso@gmail.com>. Shape and capacity variants of an existing family do not constitute a new type when its operation contract stays unchanged. A new operation contract requires approval even if it reuses an existing graph kind or enum value. A design acknowledgment does not grant that approval.Encoding.BF16 = 3andMethod.IDENTITY = 3change the captured-graph mailbox contract (oneint64row ID per token,-1for inactive slots), and no approval is recorded anywhere in the item. This is an owner decision, not author rework — merged precedent #539 shippedflare::staged_engram_compact(ignition/components/engram.py:67(not opened)) with approval still unrecorded, so one recorded sentence (approve as-is, or name the route) closes it. - Producer/producer-recipe link absent. The in-tree producer is still two-plane only —
ignition/components/engram.py:36-48(not opened) (256-column arange, scales atlocal_row * 8) and:58(weight.view(torch.float8_e4m3fn)), with no BF16/IDENTITY branch — and no companion recipe PR exists in this repository. Combined with F1, the value of pinning the contract is visible: the first BF16 producer to land could otherwise pick the 24-head path legally. - Wrong-layer / per-model branches: none found. The change is general (encoding + method primitives), with no model allowlist or capability flag, consistent with the charter's "no per-model special cases."
- Global behavioural defaults: the resident-scales default is unchanged in shape and correctly gated by
has_scale_planes(helios/src/runtime_core/selection.rs:72-76); enum values are appended (= 3) without disturbing existing tags; two-plane wire layout is untouched in every branch I read. - Evidence standard (Principle 12,
docs/design-review.md:106-115(not opened)). The Thor E2B AIPerf numbers are real service measurements, so the memory claim is evidenced; they have nomainbaseline and no E4B run, so no speed claim should be drawn from this PR. The 5.25 GiB E4B figure remains arithmetic (#210 applies only if a speed claim is made).
4. Tests & claim accuracy
- No test covers BF16+XOR_MODULO (F1). The negative test that should exist — "single-plane encoding rejects a token-map hash method" — is absent; the author's
engramsuite (52 passed) covers single-plane + IDENTITY and the two-plane modes only. Concrete fix: onevalidate_engramrejection test plus one decode rejection test. - No test covers the F2 parity gap — no test asserts that a core the exporter signs with a wrong
embedding_width/scale_blockfor its encoding is rejected at signing rather than at load. - Legacy-artifact obligation untested: no replay of a previously exported FP8/NVFP4 binary core (author's own Limitations line; disclosure is not a waiver per
docs/design-review.md:247-251(not opened), and the obligation is Principle 13 at:116-123). This is Dossier Blocker 2 and is a CI-unblock plus one replay, not new work. - Claim accuracy: the PR description's before/after statements I could check all hold —
resident_scale_bytes = 0, scale plane absent,heads == 1,compressed_vocabulary == rows,-1inactive slots, two-plane wire layout unchanged, appended enum tags. The one description sentence that over-reads its evidence is item 3's framing of pre-publication validation as closing the sign/load gap: it closes the shard-contiguity half (verified atheliopause/src/export/core.rs:5306-5336) but not the geometry half (F2). Test counts in Validation (helios 1,778 passed / 6 template failures; heliopause 226 / 2 ext4ctimefailures; flare-cli 239; flare 237) remain self-reported and I could not read check runs to confirm any CI result on this head.
Recommendation
- Owner: one recorded answer on
Encoding.BF16/Method.IDENTITY(AGENTS.md:376-381), plus the producer or companion recipe link. - Author: reject BF16 + non-IDENTITY hashing in schema and decoder (F1), extend signing to the decoder's width/block/global-scale and hash-geometry predicates (F2), and add the two matching negative tests plus one doc sentence (F3).
- CI: unblock the Windows build, pytest, and lifecycle workflows, and replay one pre-existing FP8/NVFP4 core without re-export.
- Do not re-litigate the
Planesrefactor, the delivery-group fix, theresident_scale_bytesgating, or the CPU test surface — those are in good shape.
Open questions / not found
- Whether the project owner approved the two enum values off-GitHub cannot be determined from the repository; no approval, issue, or comment records it.
- I cannot read GitHub check runs, so "no CI on
fd6dad6" rests on the item conversation containing no CI status plus both bot reviews asserting zero checks on their audited heads. - The external producer/recipe PR for the BF16/IDENTITY contract was not found in this repository or its recent items.
- E4B is unexercised anywhere in code; the 5.25 GiB figure has no producer, test, or benchmark behind it. Whether an E4B BF16 table would even take the IDENTITY path (and thus avoid F1) depends on a producer that does not exist yet.
pr_diffis broken for this PR (bad revision), so I could not confirm the absence of changes outside the 23 listed files.