Skip to content

ADR-0010: device binding interface, schemas and conformance kit - #76

Draft
gspark-etri wants to merge 2 commits into
mainfrom
feat/75-binding-contract
Draft

gspark-etri wants to merge 2 commits into
mainfrom
feat/75-binding-contract

Conversation

@gspark-etri

@gspark-etri gspark-etri commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Background

For onggi to work with any accelerator, the runtime side needs one public, versioned interface. In the design only
two parts are vendor-specific: the publisher-declared variant coordinate and the runtime's device binding, which
maps byte ranges to device memory. onggi diff --ranges --json was already what runtime experiments read (#46,
rngd-pd resident delta), but it had no schema or version, did not say which runs the base holds elsewhere or where,
and no document said what a runtime may assume or must guarantee.

Changes

  • docs/adr/0010-device-binding-contract.md (status proposed), "Device binding interface":
    • five operations, JSON in and out, process-boundary friendly (BINDING <op>, stdin/stdout): describe(artifact) -> onggi.profile.v1, resident() -> onggi.resident.v1, plan(switchplan) -> updateplan | reload (pure),
      apply(updateplan, target) -> verification (staged, drained boundary, per-unit digests), rollback();
    • what onggi guarantees and what a binding must do (plan purely, map or refuse, read verified bytes, stage/drain/
      verify, roll back, public vendor APIs only, ADR-0009);
    • conformance levels B0 (no binding: files only), B1 (describe + resident + plan that always reloads),
      B2 (all five: resident row-level updates) and what onggi does at each.
  • docs/schemas/: JSON Schema 2020-12 for onggi.switchplan.v1, onggi.updateplan.v1,
    onggi.verification.v1, onggi.resident.v1, with examples (onggi.profile.v1 is feat: select and prepare artifacts by exact compatibility profile #71/Integrate verified delta comparison and compatible artifact preparation #72's store.Profile).
  • pkg/store/diff.go: the diff JSON carries schema: "onggi.switchplan.v1", base_manifest, manifest; with
    --ranges each file gains ranges[] = {offset, length, kind: same|elsewhere|new, source_file, source_offset}
    covering the file in order. All earlier fields unchanged.
  • conformance/binding/ (Python 3.6+, stdlib, Apache-2.0): golden switch plans for four synthetic switches
    (identical, in place, shifted by 17,952 B, rearranged), their byte generator, a reference fake binding on a
    simulated device of 4 KiB rows, and conformance.py (plan purity, refusal for a non-resident base, coverage of
    every changed byte, apply digests = target, identity after apply, rollback digests = base, B1 always reloads).
  • CI: runs the kit against the fake binding at B2 and B1.

Verification

  • TestRangePlan: runs cover each file in order, sums equal same/moved/new, every same run equals the base at
    that offset, every elsewhere run equals the base bytes at its source; without --ranges the plan is absent.
  • TestGoldenSwitchPlans: onggi diff --ranges --json output equals the checked-in golden plans (manifest digests
    aside, which carry creation times).
  • python3 conformance/binding/conformance.py (B2) and --level B1: 0 failed locally.
  • All examples and golden plans validate against the schemas (jsonschema 2020-12, command in docs/schemas/README.md).
  • go test -race ./..., go vet ./..., gofmt -l . clean locally (Go 1.24.13 in golang:1.24-bookworm).
  • Real-data plan on the ATOM B2 → B8 and B2 → prefill switches: posted as a comment once measured.

Compatibility and limits

Related Issue

Closes #75

🤖 Generated with Claude Code

gspark-etri and others added 2 commits October 30, 2026 15:56
onggi diff --ranges --json now carries schema onggi.rangeplan.v1, the
base and target manifest digests, and per file a range plan that covers
the file with same / elsewhere / new runs; elsewhere runs name a base
file and offset holding the same bytes. Existing fields are unchanged.
ADR-0010 (proposed) defines the plan as the only interface to a
runtime's device binding and the binding's obligations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Expands ADR-0010 from the range schema to the public interface a runtime
implements: describe / resident / plan / apply / rollback as JSON in and
out, levels B0-B2 and what onggi does at each, binding obligations.
The diff schema is now onggi.switchplan.v1. JSON Schemas with examples
under docs/schemas/; conformance/binding/ holds golden switch plans
(kept equal to onggi diff by a Go test), a stdlib-only reference fake
binding and conformance.py, run in CI at B1 and B2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gspark-etri gspark-etri changed the title ADR-0010: versioned range plan as the device-binding contract ADR-0010: device binding interface, schemas and conformance kit Oct 30, 2026
@gspark-etri

Copy link
Copy Markdown
Contributor Author

Real-data check of onggi.switchplan.v1 (binary from this branch at 2d84ac3, lab node, ATOM Llama-3.1-8B build set, stores created with the default policy of that binary):

switch same elsewhere new ranges plan JSON onggi diff --ranges --json wall / RSS
decode B2_lm → B8_lm (15.2 GB) 15.01 GB (2 runs) 0 218.2 MB (3 runs) 5 1.4 KB —
decode B2 → B8_lm 0 13.96 GB (82 runs) 1.27 GB (7 runs) 89 17.7 KB 11.1 s / 2.1 GB
decode B2 → prefill C128 (14.0 GB) 0 11.13 GB (226,894 runs) 2.89 GB (226,845 runs) 453,739 68.2 MB 11.0 s / 2.0 GB

The decode switch is the expected binding case: two same runs and three new runs, the largest 218 MB at the end. Decode → prefill, rearranged in short runs, produces ~454k runs and a 68 MB plan. A binding answers reload there, as ADR-0010 expects, and the plan is printed only with --ranges. Raw summaries are in onggi#78's docs/data/sub-chunk-policy-20261030.json (switch_plans).

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.

Device binding contract: versioned range plan from onggi diff (ADR-0010)

1 participant