feat(ml): Engram hash port — the portable address contract - #79
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The TypeScript side of the Engram export contract (TODO.impl/10): the byte-n-gram hash that computes graph addresses per runtime.
ngramAddressesin 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:*loses FNV low bits once products exceed 2^53 —Math.imulrequired%keeps sign where Python's modulo doesn't —id - 3must be masked (& 0xff); without it, EOS-addressed rows silently divergeExports
ngramAddresses+DEFAULT_ORDERSfrominterscript/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.