Skip to content

feat(runtime): interscript-ml — Python IMF v1 runtime (WO06) - #4

Merged
ronaldtse merged 3 commits into
mainfrom
feat/imf-python
Aug 16, 2026
Merged

feat(runtime): interscript-ml — Python IMF v1 runtime (WO06)#4
ronaldtse merged 3 commits into
mainfrom
feat/imf-python

Conversation

@ronaldtse

Copy link
Copy Markdown

Summary

Work order TODO.runtime-arch/06: interscript-ml, the Python runtime
for IMF v1 zips — the reference implementation the Ruby (secryst) and
TypeScript (@interscript/ml) runtimes are diffed against.

Stacked on #3 (feat/imf-export); retarget to main when the stack merges.

What's here

  • runtime/ — its own distribution (pip install ./runtime
    interscript-ml), depending only on onnxruntime + pyyaml + numpy.
    No torch, no training-repo coupling.
  • Model.load(zip):
    • parses the manifest, rejects non-bytes tokenizers and non-IMF formats
    • sha256-verifies every .onnx member before building sessions —
      the corrupt-download failure mode fails loudly (this is not
      theoretical: the fp32 khm zip on the checkpoint volume has a CRC
      error in encoder.onnx)
    • builds sessions from verified bytes (no temp files)
  • Greedy KV-cache decode when the zip ships decoder-kv.onnx
    (the default artifact), plain full-recompute fallback otherwise.
  • tokens.py: the canonical ByT5 table (byte b → id b+3, trailing
    EOS) — the single source of the convention documented in
    docs/imf-v1.md after the silent-garbage incident.

Verification

  • pip wheel ./runtime builds interscript_ml-0.1.0-py3-none-any.whl
  • 5 CI tests (tiny-graph zips): load + decode, sha256 tamper
    rejection, tokenizer/format rejection, missing-graph rejection
  • e2e golden test (INTERSCRIPT_ML_E2E_ZIP=...khm-latn-1.0-fp32.zip):
    100/100 golden-set outputs byte-identical
  • New CI job python-runtime

@ronaldtse
ronaldtse changed the base branch from feat/imf-export to main August 16, 2026 09:05
Ronald Tse added 3 commits August 16, 2026 17:11
The reference implementation Ruby/TS are diffed against:

- Model.load(zip): manifest parse, every .onnx sha256-verified before
  the session is built (corrupt downloads fail loudly), sessions from
  verified bytes — no temp files
- greedy KV decode when the zip ships decoder-kv.onnx, plain
  full-recompute fallback otherwise
- tokens.py: the canonical ByT5 table (byte+3, trailing EOS) as the
  single source of the convention
- own distribution (runtime/pyproject.toml -> 'interscript-ml'), no
  dependency on the training repo, torch-free
- tests: tiny-graph zips for CI (load, decode, tamper rejection,
  tokenizer/format rejection) + an e2e golden test gated on
  INTERSCRIPT_ML_E2E_ZIP; verified locally against khm-latn-1.0-fp32:
  100/100 golden outputs byte-identical
transformers 5.15 breaks T5 tracing ('multiple values for use_cache') —
the same regression seen on Modal; CI was installing unpinned latest.
The runtime tests build their tiny-graph zips with the onnx package.
The release/fetch contract shared by all three runtimes, documented in
models.yaml: resolve id -> channel URL -> download to temp -> verify
whole-file sha256 against the index -> atomic install into
~/.cache/interscript/models/<id>/. Cache hits are re-verified; file://
channels copy (mirrors, not moves). Model.load now accepts an id or a
zip path. First entry: khm-latn-1.0 fp32 (gated: 0.0pp parity on 895
samples) pointing at the pending khm-latn-1.0 GitHub release.

Verified end-to-end against the real gated zip through a local channel:
Model.load('khm-latn-1.0') -> 'rok' / 'pheasaea'.
@ronaldtse
ronaldtse merged commit 662e850 into main Aug 16, 2026
9 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