Skip to content

feat(ml): Engram hash port — the portable address contract - #79

Merged
ronaldtse merged 1 commit into
mainfrom
feat/engram-hash-port
Sep 16, 2026
Merged

ronaldtse merged 1 commit into
mainfrom
feat/engram-hash-port

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

The TypeScript side of the Engram export contract (TODO.impl/10): the byte-n-gram hash that computes graph addresses per runtime.

ngramAddresses in TS produces IDENTICAL addresses to the Python reference — they feed the same IMF graph input, so any divergence would be a silent correctness bug in future Engram artifacts. The parity fixture is generated from the Python implementation (274 positions, including full byte-wrap coverage), and it caught both classic cross-language traps:

  • plain * loses FNV low bits once products exceed 2^53 — Math.imul required
  • JS % keeps sign where Python's modulo doesn't — id - 3 must be masked (& 0xff); without it, EOS-addressed rows silently diverge

Exports ngramAddresses + DEFAULT_ORDERS from interscript/ml. Full suite 276 passed. With this, all three pieces of the Engram artifact contract exist: the module, the exportable gather graph, and the portable hash — only the owner-gated training run remains.

ngramAddresses in TS producing IDENTICAL addresses to the Python
reference (ml-models src/gpu/engram.py): they feed the same IMF graph
input, computed per runtime. The parity fixture is generated from the
Python side (274 positions incl. full byte-wrap coverage); it caught
both cross-language traps: plain * loses FNV low bits above 2^53
(Math.imul required) and JS % keeps sign where Python's modulo does
not (id-3 must be masked with 0xff - EOS addresses differ otherwise).

Full suite 276; exports ngramAddresses + DEFAULT_ORDERS from
interscript/ml.
@ronaldtse
ronaldtse merged commit 291ff08 into main Sep 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant