From c17fdf1285065954821087900285a6f2a63ba4ae Mon Sep 17 00:00:00 2001 From: AdaWorldAPI Date: Fri, 23 Oct 2026 21:50:44 +0200 Subject: [PATCH 1/6] docs(onnx): plan S4-S5 Palette256 methods ONNX export and cold codegen --- .../d-onnx-relalg-s4-s5-palette-export-v1.md | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md diff --git a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md new file mode 100644 index 000000000..eb402920a --- /dev/null +++ b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md @@ -0,0 +1,64 @@ +# D-ONNX-RELALG-CAP S4–S5 — Palette256 methods, ONNX export and cold codegen +**Date:** 2026-10-23 · **Status:** PROPOSED / documentation only +**Parents:** #1745 S0, #1746 semantics, #1747 register focus, #1748 physical three-arm benchmark. +**Scope:** numeric specializations, method transitions, standards-compatible export and optional native compilation; NOT a production backend release. + +## Core ownership constraints +Use existing Palette256, CausalEdge64, ClassView, numerical kernels, R2IL/Quack/mask-risc, mathematical compiler and Thought-Git boundaries. No new causal encoding, no new universal mathematical AST, no additional executor, no claims of general ONNX runtime compatibility or theoremhood from learned state. Keep cold harvest/certify/extract apart from hot execution and binding. + +## S4: typed numerical and cognitive-method compatibility +**Inventory first (Haiku):** Palette256 implemented types/codebooks/LUT operations, ndarray SIMD, available NNUE kernels and ONNX-style nonlinear functions, existing learning probes and provenance/Thought-Git integration. Verify what is SHIPPED vs LAB vs PROPOSED. + +**Sonnet design proposal:** versioned ONNX function/primitive mapping with explicit typed input/output units. Candidate operations: +- Tanh, Atanh, Mish and quantized activation under declared precision/palette; +- LUT specialization, LUT composition and admissible finite-domain exhaustive checks; +- optional NNUE-style sparse accumulator updates and reset/full-refresh parity; +- Argmin/Argmax with tie, axis, NaN and type policies; +- Hebbian, Bayesian or BNN-style plasticity as separate state transitions, never pure mathematical equivalences; +- cognitive shader dispatch under a declared method/effect contract. + +**Strict prohibitions:** Palette256 codes, Fisher-Z, probability, NARS confidence, Hamming distance, signed i4, continuous Tanh and truth evidence are NOT interchangeable merely because their bytes resemble one another. No implicit conversion. Existing CausalEdge64 bit allocation, epistemic declarations and commit rights are not amended by this plan. + +A learned candidate can request a state transition. Thought-Git can preserve a receipt/proposal/history but cannot give that candidate mathematical proof. Numeric finite-domain exhaustive parity certifies only the declared finite domain, not real-valued analytic equivalence. + +**S4 fixtures/gates:** exhaustive quantized-domain comparison where bounded, independently computed reference values, saturation/overflow/rounding, nonlinear boundary samples, NNUE full refresh vs incremental update, explicit replay and stale-frame negative tests. Classification: exact / bounded approximate / refused. Preserve operator/version and state effects. + +## S5: ONNX export, native codegen and certification handoff +**S5a — export round trip:** distinguish ModelProto serialization with a custom domain from execution portability on stock ONNX Runtime. Preserve type, domain/opset imports, attributes, symbolic shapes, metadata and external data contract. Export standard operator fragments first; custom ops must explicitly declare unsupported runtimes, schema/version and fallback policy. Run independent graph semantic comparison for the supported subset; do not treat parse/export success as equivalence. + +**S5b — reuse existing native compilation:** compare current direct SIMD/borrowed DR, R2IL/mask-risc and external numerical kernels under the same result demand, cost accounting and admitted mathematical laws. Candidate constant folding, LUT generation, reduction fusion, law-guided re-association and physical-selection recipes must have typed premises and negative counterexamples. + +**S5c — optional LLVM AOT/JIT feasibility (not implementation):** only pursue if the #1748 three-arm experiment identifies a substantial uncovered regime. Measure compilation, proof, bind/rebind, code size, dispatch, execution and materialization separately; estimate break-even N for reusable work. Avoid inserting optimizer/egglog/LLVM JIT into hot fold. + +**Certification:** #1707/1738 establish bounded Boolean/Distinct associativity issuance; #1740 demonstrates lab fresh-frame certificate reuse for this narrow family. Independent proof checker, broad mathematical rules, target-lowering coverage, runtime wiring and general safe rebinding remain open gates. An egglog internal proof check is not automatically an independent external proof checker. Mathematical certificate ≠ data truth ≠ authority grant. + +**Thought-Git:** provenance, replay, evidence/support roots, recipe selection and rejected candidates may be recorded under existing write/version authority. Never promote evidence weights to law certificates; a mathematical identity does not authorize a storage commit. + +## Mandatory falsifiers +- F-S4-1 codebook collision / wrong Palette256 metric conversion; +- F-S4-2 LUT quantized parity mistaken for continuous Tanh equivalence; +- F-S4-3 saturation, checked/wrapping overflow or signed-i4 median shifts semantics; +- F-S4-4 NNUE incremental state diverges from full refresh; +- F-S4-5 Bayesian/Hebbian proposal masquerades as pure mathematical rewrite; +- F-S5-1 ONNX export accepted but unavailable custom-op execution hidden; +- F-S5-2 unsupported dynamic shape/symbolic dimension narrowed; +- F-S5-3 cold compilation excluded from break-even when it should be amortized; +- F-S5-4 cert/rebind valid for Boolean/Distinct mistakenly generalized to MatMul; +- F-S5-5 control-flow, memory mutation, authorization and scope bypassed by optimized plan; +- F-S5-6 new executor/AST created without necessity proof. + +Record setup, independent oracle, expected behavior, refusal/fallback, and exact repro. + +## Stage independence and acceptance +S4 may investigate a small Tanh or Palette256 typed operation immediately after the S1/S2 schema and numeric contracts are approved; it does not require a DR256³ implementation. +S5 native codegen is gated by semantically eligible P1/P2/P3 result and external baseline from #1748; S5 standard ONNX export may be developed independently for the admitted subset. +Separate draft implementation PRs by owner and operator approval; no single giant ONNX/LLVM merge. + +**S4 gate:** typed numerical parity/accuracy and replay of explicit updates without promoting learning to proof. +**S5 gate:** versioned, subset-scoped export parity and independently measured specialization benefit, with cold/hot cost split. + +## Agent workflow +Haiku evidence inventory, Sonnet plan and comparative matrices, Opus proof/typed metric/effector review plus independent adversarial check; operator/maintainers retain final authorization. Coordinate through EXO-50. GitHub board is canonical for durable statuses. Existing histories remain append-only. + +## Crosswalk +#1745, #1746, #1747, #1748, #1700, #1707, #1738, #1740 and existing D-RELALG-UNIFIED / D-DRMC / CE64 architectural docs. \ No newline at end of file From ffa56d3822502dbda29f4a67b5148ca03d98f04b Mon Sep 17 00:00:00 2001 From: AdaWorldAPI Date: Fri, 23 Oct 2026 21:58:44 +0200 Subject: [PATCH 2/6] docs(onnx): align S4-S5 with typed value dispatch and proof DAG ownership --- .../d-onnx-relalg-s4-s5-palette-export-v1.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md index eb402920a..ffee7e9aa 100644 --- a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md +++ b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md @@ -61,4 +61,21 @@ Separate draft implementation PRs by owner and operator approval; no single gian Haiku evidence inventory, Sonnet plan and comparative matrices, Opus proof/typed metric/effector review plus independent adversarial check; operator/maintainers retain final authorization. Coordinate through EXO-50. GitHub board is canonical for durable statuses. Existing histories remain append-only. ## Crosswalk -#1745, #1746, #1747, #1748, #1700, #1707, #1738, #1740 and existing D-RELALG-UNIFIED / D-DRMC / CE64 architectural docs. \ No newline at end of file +#1745, #1746, #1747, #1748, #1700, #1707, #1738, #1740 and existing D-RELALG-UNIFIED / D-DRMC / CE64 architectural docs. +--- + +## 2026-10-23 Cross-session review amendment: value dispatch, portability, proof authority + +**P0:** #1744 and #1745 S0 conflict must be resolved by owner/operator decision. This companion plan is not permission to merge or overwrite either. Preserve #1744's source-backed admission limits, #1742's proof-storage implementation and #1745's three-peer physical strategy as independent evidence. + +### S4 value methods +Under OP-ONNX-1, propose retaining ONNX's own node/function semantics as the numerical vocabulary and delegating eligible *typed numerical methods* to existing ndarray/backend kernels without making `lance-graph-relalg::Rel` a generic `ValueExpr` AST. RelAlg supplies relational support/focus where useful. A numerical-only Tanh may bypass DR entirely. All Palette256 metric conversions remain explicit, typed and version-attested; finite LUT parity does not certify real-valued Tanh. + +S4 stateful methods and NNUE incremental updates require affected-dependency/invalidation witnesses. TrainingInfo/state mutation cannot enter a supposedly pure ONNX/RelAlg rewrite by accident. + +### S5 proof and codegen +PR #1742 has retained egglog's `ProofStore`/`ProofId` in the lab certificate path; egglog internal proof checking is **not an independent checker**. Split law admission, external proof rechecking, input/binding eligibility, numerical approximation and physical cost selection into separate gates. Keep the proof object rather than reducing it to render/hash. Cross-frame reuse from #1740 is narrow, not a general production contract. + +ONNX export must make a distinction among standard-operator portable execution, correctly serialized custom-domain graphs and actual runtime support. An authorized delegated-graph research mode (see #1746) may preserve whole-model interoperability via external providers; it is not permission to introduce another proprietary execution runtime. + +S5 auto-selection and LLVM AOT/JIT remain research until #1748 demonstrates verified semantic parity and meaningful end-to-end wins. Compilation, bind, proof/replay, cache reuse, data transfer and output materialization all contribute to break-even. From 22533560c83f973a89316b4fc4aa0e9c6e23a139 Mon Sep 17 00:00:00 2001 From: AdaWorldAPI Date: Fri, 23 Oct 2026 22:08:05 +0200 Subject: [PATCH 3/6] docs(onnx) S4-S5: reuse shipped BGZ/Helix/ndarray and gate unsafe shape-keyed compiled caches --- .../d-onnx-relalg-s4-s5-palette-export-v1.md | 202 +++++++++++------- 1 file changed, 130 insertions(+), 72 deletions(-) diff --git a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md index ffee7e9aa..94894147a 100644 --- a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md +++ b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md @@ -1,81 +1,139 @@ -# D-ONNX-RELALG-CAP S4–S5 — Palette256 methods, ONNX export and cold codegen -**Date:** 2026-10-23 · **Status:** PROPOSED / documentation only -**Parents:** #1745 S0, #1746 semantics, #1747 register focus, #1748 physical three-arm benchmark. -**Scope:** numeric specializations, method transitions, standards-compatible export and optional native compilation; NOT a production backend release. +# D-ONNX-RELALG-CAP S4–S5 — reuse existing BGZ / Helix / ndarray numerical execution +**Date:** 2026-10-23 · **Status:** PROPOSED integration and falsification plan; documentation only +**Parents:** #1744, #1745, #1750 (CONFLICTING S0 ownership, no canonical merge approved), #1746 (intake/value dispatch), #1747 (focus), #1748 (physical execution). +**Existing implementation anchors:** AdaWorldAPI/ndarray #42 and #100; lance-graph #1726 and #1731. +**Critical correction:** Do **not** develop a new Palette256 codec, LUT algebra, Fisher-Z quantizer, attention-table framework, SIMD backend, or mathematical AST merely to satisfy ONNX. Those capabilities have existing implementations and different mathematical constraints. What is missing is verified ONNX admission, immutable model/layer/codebook identity, typed method binding and unbiased differential evaluation. -## Core ownership constraints -Use existing Palette256, CausalEdge64, ClassView, numerical kernels, R2IL/Quack/mask-risc, mathematical compiler and Thought-Git boundaries. No new causal encoding, no new universal mathematical AST, no additional executor, no claims of general ONNX runtime compatibility or theoremhood from learned state. Keep cold harvest/certify/extract apart from hot execution and binding. +## 0. Existing capability and evidential status -## S4: typed numerical and cognitive-method compatibility -**Inventory first (Haiku):** Palette256 implemented types/codebooks/LUT operations, ndarray SIMD, available NNUE kernels and ONNX-style nonlinear functions, existing learning probes and provenance/Thought-Git integration. Verify what is SHIPPED vs LAB vs PROPOSED. +| Existing surface | Source | Verified source facts | What is NOT established | +|---|---|---|---| +| **bgz-tensor** | `crates/bgz-tensor/src/{palette.rs,fisher_z.rs,attention.rs}` | `WeightPalette` with up-to-256 calibrated representatives/radii; `FamilyGamma` and `FisherZTable` (i8, gamma, 256²); `AttentionTable` (u16 distance), `ComposeTable` and typed LUT lookups | arbitrary ONNX MatMul semantics, closed multi-hop composition, globally valid metric-to-score conversion or no saturation | +| **helix** | `crates/helix/src/{lib.rs,distance.rs,quantize.rs}`, `KNOWLEDGE.md` | `RollingFloor`, `DistanceLut::{linear,from_floor,circular}`, 256² distance tables, deterministic place/residue. Circular metric test exhaustively enumerates 256³ triples | a generic neural activation codebook or interchangeable cosine/FisherZ codes | +| **bgz17** | `crates/bgz17/src/lib.rs` and KNOWLEDGE | existing Base17, layered distance and 256-entry palette components; the metric-safety contract distinguishes nonmetric Scent from L1/Hamming tiers | identical numeric semantics across every palette/codebook family | +| **ndarray** | `AdaWorldAPI/ndarray:crates/burn/src/ops/matmul.rs`, `src/hpc/vml.rs`, Burn `tensor.rs` | `CompiledAttention`, `CompiledLinear`, conventional `general_mat_mul` fallback; native `vstanh` f32 SIMD path and scalar/stride fallback; aarch64 NEON lanes and parity harness | transparent per-node ONNX compatibility, comprehensive identity guards, exact approximation, measured end-to-end advantage for arbitrary models | -**Sonnet design proposal:** versioned ONNX function/primitive mapping with explicit typed input/output units. Candidate operations: -- Tanh, Atanh, Mish and quantized activation under declared precision/palette; -- LUT specialization, LUT composition and admissible finite-domain exhaustive checks; -- optional NNUE-style sparse accumulator updates and reset/full-refresh parity; -- Argmin/Argmax with tie, axis, NaN and type policies; -- Hebbian, Bayesian or BNN-style plasticity as separate state transitions, never pure mathematical equivalences; -- cognitive shader dispatch under a declared method/effect contract. +**Empirical source report, NOT universal certification:** `bgz-tensor/src/fisher_z.rs` documents Spearman ρ ≥ 0.999 over 21 Qwen3-TTS roles with 5,000 sampled pairs each. Retain its exact dataset/role/sampling context and reproduce before treating it as an ONNX admission gate. Correlation is neither pointwise parity nor proof of a general mathematical identity. -**Strict prohibitions:** Palette256 codes, Fisher-Z, probability, NARS confidence, Hamming distance, signed i4, continuous Tanh and truth evidence are NOT interchangeable merely because their bytes resemble one another. No implicit conversion. Existing CausalEdge64 bit allocation, epistemic declarations and commit rights are not amended by this plan. +**Finite-domain laws are scoped:** `helix::DistanceLut::circular` contains an exhaustive 256³-triple triangle-inequality regression; `linear` has a smaller stride-sampled test and the exact L1 definition. These metric properties are not certification of numerical `MatMul`, `Attention` or multi-hop arbitrary palette composition. -A learned candidate can request a state transition. Thought-Git can preserve a receipt/proposal/history but cannot give that candidate mathematical proof. Numeric finite-domain exhaustive parity certifies only the declared finite domain, not real-valued analytic equivalence. +**Known empirical refusals:** #1726 reports `ComposeTable` multi-hop failure after snapping outside palette support. #1731 shows the learned LUT also fails k=2 outside a closed-carrier case. This refutes those *specific composition laws*, not Palette256 as a whole. EXO-129 / EXO-132 remain reference points; never enable multi-hop reuse based on one-hop table parity alone. -**S4 fixtures/gates:** exhaustive quantized-domain comparison where bounded, independently computed reference values, saturation/overflow/rounding, nonlinear boundary samples, NNUE full refresh vs incremental update, explicit replay and stale-frame negative tests. Classification: exact / bounded approximate / refused. Preserve operator/version and state effects. +**Known quality-gate debt:** EXO-137 records that the main `rust-test.yml` runs only `bgz-tensor --lib`, omitting integration probes. EXO-139 records `FisherZTable::encode` saturating out-of-family values silently; in-range and saturation negative controls are specified. Do not use un-gated integration test reports or source comments as production ONNX certificates. Fix CI and checked encoding in separate owner-approved PRs, not this plan. -## S5: ONNX export, native codegen and certification handoff -**S5a — export round trip:** distinguish ModelProto serialization with a custom domain from execution portability on stock ONNX Runtime. Preserve type, domain/opset imports, attributes, symbolic shapes, metadata and external data contract. Export standard operator fragments first; custom ops must explicitly declare unsupported runtimes, schema/version and fallback policy. Run independent graph semantic comparison for the supported subset; do not treat parse/export success as equivalence. +## 1. Existing execution selection: important hazards, not new kernel requests -**S5b — reuse existing native compilation:** compare current direct SIMD/borrowed DR, R2IL/mask-risc and external numerical kernels under the same result demand, cost accounting and admitted mathematical laws. Candidate constant folding, LUT generation, reduction fusion, law-guided re-association and physical-selection recipes must have typed premises and negative counterexamples. +The Burn `matmul` implementation already tries, in order: +1. `try_compiled_linear` on a registered shape; +2. `try_attention_matmul` on registered `d_head`; +3. `ndarray::linalg::general_mat_mul` as conventional fallback. -**S5c — optional LLVM AOT/JIT feasibility (not implementation):** only pursue if the #1748 three-arm experiment identifies a substantial uncovered regime. Measure compilation, proof, bind/rebind, code size, dispatch, execution and materialization separately; estimate break-even N for reusable work. Avoid inserting optimizer/egglog/LLVM JIT into hot fold. - -**Certification:** #1707/1738 establish bounded Boolean/Distinct associativity issuance; #1740 demonstrates lab fresh-frame certificate reuse for this narrow family. Independent proof checker, broad mathematical rules, target-lowering coverage, runtime wiring and general safe rebinding remain open gates. An egglog internal proof check is not automatically an independent external proof checker. Mathematical certificate ≠ data truth ≠ authority grant. - -**Thought-Git:** provenance, replay, evidence/support roots, recipe selection and rejected candidates may be recorded under existing write/version authority. Never promote evidence weights to law certificates; a mathematical identity does not authorize a storage commit. - -## Mandatory falsifiers -- F-S4-1 codebook collision / wrong Palette256 metric conversion; -- F-S4-2 LUT quantized parity mistaken for continuous Tanh equivalence; -- F-S4-3 saturation, checked/wrapping overflow or signed-i4 median shifts semantics; -- F-S4-4 NNUE incremental state diverges from full refresh; -- F-S4-5 Bayesian/Hebbian proposal masquerades as pure mathematical rewrite; -- F-S5-1 ONNX export accepted but unavailable custom-op execution hidden; -- F-S5-2 unsupported dynamic shape/symbolic dimension narrowed; -- F-S5-3 cold compilation excluded from break-even when it should be amortized; -- F-S5-4 cert/rebind valid for Boolean/Distinct mistakenly generalized to MatMul; -- F-S5-5 control-flow, memory mutation, authorization and scope bypassed by optimized plan; -- F-S5-6 new executor/AST created without necessity proof. - -Record setup, independent oracle, expected behavior, refusal/fallback, and exact repro. - -## Stage independence and acceptance -S4 may investigate a small Tanh or Palette256 typed operation immediately after the S1/S2 schema and numeric contracts are approved; it does not require a DR256³ implementation. -S5 native codegen is gated by semantically eligible P1/P2/P3 result and external baseline from #1748; S5 standard ONNX export may be developed independently for the admitted subset. -Separate draft implementation PRs by owner and operator approval; no single giant ONNX/LLVM merge. - -**S4 gate:** typed numerical parity/accuracy and replay of explicit updates without promoting learning to proof. -**S5 gate:** versioned, subset-scoped export parity and independently measured specialization benefit, with cold/hot cost split. - -## Agent workflow -Haiku evidence inventory, Sonnet plan and comparative matrices, Opus proof/typed metric/effector review plus independent adversarial check; operator/maintainers retain final authorization. Coordinate through EXO-50. GitHub board is canonical for durable statuses. Existing histories remain append-only. - -## Crosswalk -#1745, #1746, #1747, #1748, #1700, #1707, #1738, #1740 and existing D-RELALG-UNIFIED / D-DRMC / CE64 architectural docs. ---- - -## 2026-10-23 Cross-session review amendment: value dispatch, portability, proof authority - -**P0:** #1744 and #1745 S0 conflict must be resolved by owner/operator decision. This companion plan is not permission to merge or overwrite either. Preserve #1744's source-backed admission limits, #1742's proof-storage implementation and #1745's three-peer physical strategy as independent evidence. - -### S4 value methods -Under OP-ONNX-1, propose retaining ONNX's own node/function semantics as the numerical vocabulary and delegating eligible *typed numerical methods* to existing ndarray/backend kernels without making `lance-graph-relalg::Rel` a generic `ValueExpr` AST. RelAlg supplies relational support/focus where useful. A numerical-only Tanh may bypass DR entirely. All Palette256 metric conversions remain explicit, typed and version-attested; finite LUT parity does not certify real-valued Tanh. - -S4 stateful methods and NNUE incremental updates require affected-dependency/invalidation witnesses. TrainingInfo/state mutation cannot enter a supposedly pure ONNX/RelAlg rewrite by accident. - -### S5 proof and codegen -PR #1742 has retained egglog's `ProofStore`/`ProofId` in the lab certificate path; egglog internal proof checking is **not an independent checker**. Split law admission, external proof rechecking, input/binding eligibility, numerical approximation and physical cost selection into separate gates. Keep the proof object rather than reducing it to render/hash. Cross-frame reuse from #1740 is narrow, not a general production contract. - -ONNX export must make a distinction among standard-operator portable execution, correctly serialized custom-domain graphs and actual runtime support. An authorized delegated-graph research mode (see #1746) may preserve whole-model interoperability via external providers; it is not permission to introduce another proprietary execution runtime. - -S5 auto-selection and LLVM AOT/JIT remain research until #1748 demonstrates verified semantic parity and meaningful end-to-end wins. Compilation, bind, proof/replay, cache reuse, data transfer and output materialization all contribute to break-even. +However its current **cache keys do not prove operand identity**: +- `ATTENTION_CACHE: HashMap` is keyed by inner dimension `k=d_head`. `try_attention_matmul(_lhs,_rhs,...)` ignores the current operand *values*; uses previously registered `q_assignments`/`k_assignments` and `table`, returns a scaled negative distance. +- `LINEAR_CACHE: Vec` chooses first matching `(n_rows,n_cols)` even for distinct layers of identical shape. Despite a `pop_` name, it **does not consume** the matching entry. `try_compiled_linear(_lhs,_rhs,...)` ignores current `lhs` weight values; the numerical path quantizes centroids and runtime input columns. It records a scale-only approximation and comments that zero-point bias correction is absent. +- These paths are *implemented candidate specializations*, not safe generic transparent ONNX `MatMul` substitutions. A palette lookup of distance or centroid approximation does not automatically preserve the exact ONNX operator mathematical value. Existing code comments about 'O(1)' are per output lookup and exclude registration, assignment, table build, preparation and output materialization. +- Multiple models/layers with the same dimensions, different palettes or changed frame are a concrete **collision counterexample**. The currently registered compiled table must not be automatically applied to arbitrary ONNX MatMul nodes by matching shape alone. + +**Fail-closed integration rule:** Until an owner-approved implementation verifies model/layer/codebook identity and numerical eligibility, ONNX STRICT_NATIVE must use conventional native tensor kernels for those operations or explicitly refuse. Compiled palette execution is admitted only for a witnessed, intentionally compiled model/layer with a declared approximation/error contract. + +### Proposed binding/admission witness (conceptual, NOT a new ABI) + +Check existing owners/types before adding fields. At minimum attest: +- Model graph identity, version/IR/opset and operator/node identity; stable layer/weight identity. +- Original tensor or weight digest **and** compiled artifact/codebook digest, revision and calibration generation. +- Exact `k`, `m`, `n`, dtype, strides/layout and relevant broadcast/attention scale/mask semantics. +- q/k assignment provenance or centroid row mapping, expected layer and shape, cache lifetime. +- Source-issued frame identity and distinct focus/scope/permission guards if using DR global-to-local binding. +- Valid numerical policy: EXACT only if established; otherwise `APPROXIMATE` with calibration population, error/quality thresholds and fallback. +- Versioned backend/kernel ABI, dynamic-input applicability, mutation/invalidations, and explicit model unload/rebind/clear behavior. + +**Do not mint a new global identity encoding or put arbitrary model strings in a hot register.** Resolve cold at import/bind, then pass a compact method/capability handle through the existing guarded boundary. Reuse source-attested seals. No blind cache hit. + +### High-priority negative tests (preregister before code) +- Two models with same head dimension but different Q/K palettes: compiled attention must refuse wrong model. +- Two same-shape linear layers with distinct weights: must refuse shape-only collision. +- Same model/layer after recompilation, codebook change, new assignments or changed scope/frame: old compiled recipe must refuse or safely rebind under proven rules. +- Current Q/K inputs differ from registration assignments: attention must not silently return identical precomputed output as exact ONNX MatMul. +- Out-of-domain `FisherZTable::encode` saturation is detected, not reported as maximal in-family similarity. +- `CompiledLinear` scale/bias error, boundary quantization, sign, NaN, Infinity and overflow are measured against an independent full-precision reference. +- Multi-hop composition across unsupported codebook support remains rejected even when one-hop distances correlate well. +- Regression: with no compiled registration, standard Burn numeric behavior is unchanged. + +## 2. Stage S4 — reuse and numerical admission, NOT Palette256 redevelopment + +### S4a: source and test inventory +**Haiku:** inventory `bgz-tensor`, `bgz17`, `helix`, `ndarray` and existing numerical performance paths. Record exact source/commit, public APIs, tests and whether they are enforced in CI. Include Burn `float_tanh` → `ndarray::hpc::vml::vstanh` and the 256² compiled cache methods. Compare documented capability to actual source: SHIPPED, LAB, PROPOSED, REFUTED, UNKNOWN. Identify relevant `helix/KNOWLEDGE.md` Overlap & Consolidation plan; do not create competing quantizers. + +### S4b: typed ONNX dispatch to existing implementations +**Sonnet:** design the smallest immutable *ONNX operator → existing method* dispatch, not new `Rel::Tanh`, `Rel::MatMul` or a universal numerical expression tree. `GraphProto` remains interchange graph; RelAlg handles admissible Boolean/relational support and result demand; ndarray/Burn/Palette256 methods remain numerical owners. A standalone `Tanh` does not need a DR register. + +**Opus:** assess exact vs approximate eligibility, law family and use of cached compiled artifacts. Numerical operator semantics (and any partial model delegation) require separately specified reference and conversion policies. Do not use an ONNX runtime merely as a witness of a mathematical theorem. + +### S4c: codebook and functional quality gate +- The direct `vstanh` path is a concrete existing ONNX Tanh kernel candidate; evaluate its SIMD approximation, NaN/Inf/signed zero, tail and strided policies against a reference. +- A compiled palette is intentionally approximate unless an exact restricted-domain proof exists. Require held-out per-model/per-layer quality metrics, max/percentile error and task-level regressions (e.g. audio/attention) where applicable; ρ alone is insufficient. +- Reuse `WeightPalette` distortion radii, FisherZ gamma, Helix `DistanceLut`, existing NEON/AVX and BF16 conversions with typed codebook identity. No implicit FisherZ/Hamming/Palette/Tanh conversion. +- Bayesian/Hebbian/BNN plasticity, NNUE accumulator state and cognitive shaders are *method-level proposals/state transitions*; do not turn them into ONNX mathematical identities or proof certificates. Verify full refresh vs incremental update only for existing supported owners. +- #1726/#1731 multi-hop failures impose scoped restrictions; do not describe all of Palette256 as unimplemented or refuted. + +**S4 gate:** existing kernels reused, real model/layer/codebook identity boundary specified, wrong-artifact negative tests preregistered, typed numerical quality/oracle parity for one admitted operator, and any approximations explicitly opt-in. No new codec or runtime. + +## 3. Stage S5 — export, cold compilation, reuse and certification + +**S5a export:** versioned ONNX subset roundtrip using standard operators where possible; custom domain serialization is not automatically portable. Preserve metadata, shapes, effects and external tensor-data safety. Existing compiled palette methods may require an explicit custom operator or a native binding extension; either must advertise portability limits and declared approximation. + +**S5b reuse existing cold recipe compiler:** D-DRMC Boolean/Distinct associativity #1707/#1738 and fresh-frame reuse #1740/#1742 are *scoped*. Egglog ProofStore/ProofId is retained in #1742; egglog's self-check is not an independently authored verifier. Mathematical law ≠ empirical codebook accuracy ≠ typed scope authorization ≠ cost preference. Keep any palette-calibration receipt separate from a theorem certificate. + +**S5c AOT/JIT:** optional only after #1748 shows an uncovered measurable regime; no LLVM, e-graph or ONNX graph executor in the runtime fold. Measure compile, calibration, bind, proof, transfer, cache invalidation, execution and output materialization separately. Reuse existing SIMD and Burn numerical fallback by default. + +**S5d hardware:** ndarray already provides ARM NEON, AVX and scalar paths, plus parity harnesses. Do not specify a second NEON kernel framework; add only target-specific measured crossover benchmarks when hardware is available. + +**Thought-Git:** evidence, provenance, failed calibration candidates, recipe selection and replay under existing write authority. Do not promote correlations, stochastic parameter updates or source comments into a mathematical proof or commit permission. + +## 4. Cross-PR implications +- **#1746:** Value-only ONNX Tanh maps to existing `ndarray::hpc::vml::vstanh`/Burn; `Rel` remains narrow, no new value AST. ONNX model/layer/node identity must survive importer. +- **#1747:** A DR focus bound to a model-specific codebook needs the same source-issued identity, seals and snapshot guards as all other operands. Holographic focus is optional, not a universal palette read. +- **#1748:** Existing `CompiledAttention`/`CompiledLinear` are a measured *candidate*, not an automatically equivalent Tensor/DR/Hybrid plan. Compare exact T/D/H arms first; add an explicit palette-compiled arm only under an opt-in APPROXIMATE quality contract (or after proof of exact restricted-domain parity). Measure cold compilation, table generation, weight assignment, codebook calibration, identity-bind/cache overhead and full output. +- **#1744/#1745/#1750:** the same S0 path conflicts. Preserve #1744's source inventory and #1750's board progress; #1745's three-peer physical concepts are an amendment proposal until EXO-50 resolves ownership. Do not merge three competing S0 files. + +## 5. Risk register and exact open points +- **OP-ONNX-1:** typed value-math dispatch ownership without a new AST. +- **OP-ONNX-2:** model importer and protobuf fork choice. +- **OP-ONNX-4:** witnessed intra-register bit enumeration vs forbidden cross-table gather. +- **OP-ONNX-5/7/9:** independent checker, prover revision, stale 'independent' wording. +- **OP-ONNX-BIND-1 (NEW PROPOSAL):** immutable model/layer/weight/codebook/assignment identity and safe invalidation for Burn `CompiledAttention`/`CompiledLinear`. +- **OP-ONNX-PAL-2 (NEW PROPOSAL):** quality contract permitting an approximate palette method for each ONNX operator and domain. +- **OP-ONNX-PAL-3 (NEW PROPOSAL):** reconcile FisherZ checked encode (EXO-139), ungated integration tests (EXO-137) and multi-hop failures (#1726/#1731; EXO-129/EXO-132) before production promotion. + +All three new IDs are proposals local to this PR, **not** existing canonical board issue IDs. Owner/board must decide their durable identifiers. + +### Falsification checklist +F-S4-1: same dimension different model/weight -> wrong compiled cache hit. +F-S4-2: same shape distinct layers -> wrong CompiledLinear reuse. +F-S4-3: changed palette generation and old assignments -> stale result. +F-S4-4: palette score differs from direct ONNX QK numeric contract. +F-S4-5: incomplete zero-point correction creates unacceptable numeric error. +F-S4-6: FisherZ saturation looks like in-family evidence. +F-S4-7: multi-hop ComposeTable approximation erroneously certified. +F-S4-8: a result claimed CI-gated depends on integration tests not run in CI. +F-S5-1: independent proof checker falsely inferred from egglog self-check. +F-S5-2: ONNX custom domain assumed portable without a runtime handler. +F-S5-3: cold compile/calibration/cache costs omitted from benchmark. +F-S5-4: model-specific approximation silently executed in strict exact native mode. + +Each falsifier needs: fixture, expected refusal or fallback, independent reference, can-fire/can-stay-silent controls, reproducible run and owner-approved stage gate. + +## 6. Agent and ownership protocol +Haiku source/test/CI inventory. Sonnet draft typed integration and plan costs. Independent Opus review of ONNX equivalence, exact-vs-approximation and cache safety. Operator and repository owners authorize code, ABI changes and merges. Coordinate through [Linear EXO-50](https://linear.app/exo-red/issue/EXO-50/agent-message-bus-gpt-xgrok-ccsession-id). Durable evidence stays in GitHub board, with dated append-only amendments; do not rewrite earlier records. + +## Verified code and issue references +- BGZ: https://github.com/AdaWorldAPI/lance-graph/blob/main/crates/bgz-tensor/src/fisher_z.rs +- BGZ attention: https://github.com/AdaWorldAPI/lance-graph/blob/main/crates/bgz-tensor/src/attention.rs +- Helix: https://github.com/AdaWorldAPI/lance-graph/blob/main/crates/helix/src/lib.rs +- Helix DistanceLut: https://github.com/AdaWorldAPI/lance-graph/blob/main/crates/helix/src/distance.rs +- bgz17: https://github.com/AdaWorldAPI/lance-graph/blob/main/crates/bgz17/src/lib.rs +- ndarray Burn compiled paths: https://github.com/AdaWorldAPI/ndarray/blob/master/crates/burn/src/ops/matmul.rs +- ndarray tanh: https://github.com/AdaWorldAPI/ndarray/blob/master/src/hpc/vml.rs +- ndarray historical PRs: https://github.com/AdaWorldAPI/ndarray/pull/42 ; https://github.com/AdaWorldAPI/ndarray/pull/100 +- Existing method falsifiers: https://github.com/AdaWorldAPI/lance-graph/pull/1726 ; https://github.com/AdaWorldAPI/lance-graph/pull/1731 +- Linear CI/encoding debt: https://linear.app/exo-red/issue/EXO-137/bgz-tensor-integration-tests-never-run-in-ci-rust-testyml-runs-lib ; https://linear.app/exo-red/issue/EXO-139/fisherztableencode-clamps-out-of-family-cosines-to-the-edge-code-with From f4d2f7b63b267e9e3b900f7b820aa7d82f6204fe Mon Sep 17 00:00:00 2001 From: AdaWorldAPI Date: Fri, 23 Oct 2026 22:24:02 +0200 Subject: [PATCH 4/6] docs(onnx): cross-link independent Optimum offline BGZ compiler plan #1751 --- .../d-onnx-relalg-s4-s5-palette-export-v1.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md index 94894147a..3c4764511 100644 --- a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md +++ b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md @@ -137,3 +137,21 @@ Haiku source/test/CI inventory. Sonnet draft typed integration and plan costs. I - ndarray historical PRs: https://github.com/AdaWorldAPI/ndarray/pull/42 ; https://github.com/AdaWorldAPI/ndarray/pull/100 - Existing method falsifiers: https://github.com/AdaWorldAPI/lance-graph/pull/1726 ; https://github.com/AdaWorldAPI/lance-graph/pull/1731 - Linear CI/encoding debt: https://linear.app/exo-red/issue/EXO-137/bgz-tensor-integration-tests-never-run-in-ci-rust-testyml-runs-lib ; https://linear.app/exo-red/issue/EXO-139/fisherztableencode-clamps-out-of-family-cosines-to-the-edge-code-with + +--- + +## 2026-10-23 separate cold frontend plan: PR #1751 + +**New independently owned research plan:** [D-OPTIMUM-BGZ-OFFLINE-v1](https://github.com/AdaWorldAPI/lance-graph/pull/1751), a docs-only cold Optimum ONNX export/calibration → existing BGZ/Palette256 sidecar adapter, with an operator-approved compact BERT-layer numeric probe. + +**Ownership correction and stage framing:** +- **#1751 O0–O3 owns** source-backed `huggingface/optimum-onnx` API inventories; pinned model export and ORT/source comparison; calibration workflow reuse; layer/weight/codebook fingerprints; an optional *illustrative, non-destructive* compiled sidecar manifest. It **does not** implement a runtime or require an Optimum fork. +- **This #1749 S4 owns** the native `bgz-tensor`/`helix`/`bgz17` and ndarray compiled method *admission contract*: existing `CompiledLinear`/`CompiledAttention` identity, exact vs approximate quality, explicit cache-invalidation and fail-closed fallback. Do not duplicate Optimum exporter or build a second palette compiler. +- **This #1749 S5 owns** versioned output/sidecar compatibility review, native method reuse, cold proof/certification boundaries and measured optional codegen; no general custom ONNX operator portability implied. +- **#1748 owns** physical Tensor/DR/Hybrid and quality-gated compiled palette crossover benchmarks, with Optimum-exported fixtures from #1751 when available. + +**Critical seam:** the Optimum-exported original `MatMul/Gemm` remains the semantic reference; the existing BGZ/CompiledLinear representation is *a candidate* with calibration and numerical errors. Model revision, initializer weight digest, node/path, codebook family+generation and assignments must match at runtime before using a compiled artifact. The global Burn dimension-keyed paths must not become silently enabled for arbitrary imported ONNX models. For POC, prohibit unguarded cache registration; use a local harness or separately authorized identity-bound runtime entrypoint. + +**Source references:** `huggingface/optimum-onnx/optimum/exporters/onnx/{model_configs.py,convert.py}`, `optimum/onnxruntime/{quantization.py,optimization.py}`; native `AdaWorldAPI/ndarray/crates/burn/src/ops/matmul.rs`; existing `lance-graph/crates/bgz-tensor`. `ORTQuantizer` does not create BGZ codebooks merely by choosing a different INT8 type. Optimum stays in the **offline Python compiler**. No Python/ORT runtime requirement on the target edge CPU. + +**Gate:** S4 native adaptation requires a source-verified candidate and model/layer provenance plus owner signoff; O1 model selection and protobuf fork decision are still operator-owned prerequisites per #1750. #1744/#1745/#1750 S0 remains unresolved. Neither doc plan can auto-merge or authorize runtime changes. From af9eb0de38267aa90c0b0d559645f70ffe2593c1 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 23 Oct 2026 21:24:36 +0000 Subject: [PATCH 5/6] D-NFC: marked supersession of the root assumptions in this plan Architecture correction approved by the operator on 2026-10-23. Adds one marked supersession block under the title and inline markers on the sentences that state a root assumption (A1-A7). Canonical text and the representation seams are in #1753 (d-native-first-dependency-correction-v1.md, d-native-repr-contract-v1.md). No other text in this plan changes; the #1744/#1745/#1750 S0 dispute is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg --- .../plans/d-onnx-relalg-s4-s5-palette-export-v1.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md index 3c4764511..b18318f5d 100644 --- a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md +++ b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md @@ -1,4 +1,15 @@ # D-ONNX-RELALG-CAP S4–S5 — reuse existing BGZ / Helix / ndarray numerical execution + +> **⊘ SUPERSESSION — D-NFC (2026-10-23, operator-approved architecture correction; canonical text `.claude/plans/d-native-first-dependency-correction-v1.md` and representation seams `.claude/plans/d-native-repr-contract-v1.md`, both in [#1753](https://github.com/AdaWorldAPI/lance-graph/pull/1753)).** +> +> 1. **Quack binding + DR64³ + Palette256³ is the intended internal integration.** `GraphProto` owns no internal representation (A1). +> 2. **Dispatch.** Internally a native typed operation selects an existing kernel. "ONNX operator → existing method" is the external conformance adapter [7], not the internal contract (A1). +> 3. **Compiled-artifact identity is the native binding**: Quack resolution under a sealed frame plus a codebook generation. Codebook runtime identity is MISSING today (D-NFR S15) and is the precondition for admitting any `CompiledLinear` / `CompiledAttention`; ONNX model / layer / node identity is external provenance (A7). +> 4. **OP-ONNX-2 (importer, protobuf fork) and O1 model selection gate only the optional external-file adapter**, not native S4 (A2). +> 5. **Exact versus approximate** is unchanged: approximate methods are opt-in with a named error contract and the exact native method as fallback. +> +> Passages below that contradict these points are marked ⊘ in place; nothing else in this plan changes. The #1744 / #1745 / #1750 S0 ownership dispute is unchanged. + **Date:** 2026-10-23 · **Status:** PROPOSED integration and falsification plan; documentation only **Parents:** #1744, #1745, #1750 (CONFLICTING S0 ownership, no canonical merge approved), #1746 (intake/value dispatch), #1747 (focus), #1748 (physical execution). **Existing implementation anchors:** AdaWorldAPI/ndarray #42 and #100; lance-graph #1726 and #1731. @@ -66,6 +77,7 @@ Check existing owners/types before adding fields. At minimum attest: ### S4b: typed ONNX dispatch to existing implementations **Sonnet:** design the smallest immutable *ONNX operator → existing method* dispatch, not new `Rel::Tanh`, `Rel::MatMul` or a universal numerical expression tree. `GraphProto` remains interchange graph; RelAlg handles admissible Boolean/relational support and result demand; ndarray/Burn/Palette256 methods remain numerical owners. A standalone `Tanh` does not need a DR register. +> ⊘ **D-NFC A1: that dispatch is the external conformance adapter; internally `GraphProto` is not the interchange graph.** **Opus:** assess exact vs approximate eligibility, law family and use of cached compiled artifacts. Numerical operator semantics (and any partial model delegation) require separately specified reference and conversion policies. Do not use an ONNX runtime merely as a witness of a mathematical theorem. @@ -99,6 +111,7 @@ Check existing owners/types before adding fields. At minimum attest: ## 5. Risk register and exact open points - **OP-ONNX-1:** typed value-math dispatch ownership without a new AST. - **OP-ONNX-2:** model importer and protobuf fork choice. + > ⊘ **D-NFC A2: gates the optional adapter only.** - **OP-ONNX-4:** witnessed intra-register bit enumeration vs forbidden cross-table gather. - **OP-ONNX-5/7/9:** independent checker, prover revision, stale 'independent' wording. - **OP-ONNX-BIND-1 (NEW PROPOSAL):** immutable model/layer/weight/codebook/assignment identity and safe invalidation for Burn `CompiledAttention`/`CompiledLinear`. @@ -155,3 +168,4 @@ Haiku source/test/CI inventory. Sonnet draft typed integration and plan costs. I **Source references:** `huggingface/optimum-onnx/optimum/exporters/onnx/{model_configs.py,convert.py}`, `optimum/onnxruntime/{quantization.py,optimization.py}`; native `AdaWorldAPI/ndarray/crates/burn/src/ops/matmul.rs`; existing `lance-graph/crates/bgz-tensor`. `ORTQuantizer` does not create BGZ codebooks merely by choosing a different INT8 type. Optimum stays in the **offline Python compiler**. No Python/ORT runtime requirement on the target edge CPU. **Gate:** S4 native adaptation requires a source-verified candidate and model/layer provenance plus owner signoff; O1 model selection and protobuf fork decision are still operator-owned prerequisites per #1750. #1744/#1745/#1750 S0 remains unresolved. Neither doc plan can auto-merge or authorize runtime changes. +> ⊘ **D-NFC A2: native adaptation does not wait on O1 model selection or the protobuf fork decision.** From f60c94da85fa1884ed64aee61b1cb5408cdce62a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 23 Oct 2026 22:25:09 +0000 Subject: [PATCH 6/6] D-NFC: layers [1] and [7] as finally drawn (router; ONNX leaf facade #1754) Marked supersession: 'R2IL polyfill' reads as the R2IL router (D-MPF-4), and [7] is the lance-graph-onnx leaf facade. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg --- .claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md index b18318f5d..37646b894 100644 --- a/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md +++ b/.claude/plans/d-onnx-relalg-s4-s5-palette-export-v1.md @@ -9,6 +9,8 @@ > 5. **Exact versus approximate** is unchanged: approximate methods are opt-in with a named error contract and the exact native method as fallback. > > Passages below that contradict these points are marked ⊘ in place; nothing else in this plan changes. The #1744 / #1745 / #1750 S0 ownership dispute is unchanged. +> +> **⊘ Layers [1] and [7] as finally drawn (2026-10-23; #1752 §10, #1753, #1754).** Where this note or the plan says "R2IL polyfill (#1752)", read the R2IL **router**: a route resolved once per ClassId onto `ndarray::simd` (through mask-risc where a program is needed), with `FoldDialect` one strategy beneath it (D-MPF-4). Layer [7], the ONNX conformance adapter, is an external **leaf** facade implemented as `lance-graph-onnx` (#1754): ONNX names over existing native functions, no dispatch, and nothing native depends on it. **Date:** 2026-10-23 · **Status:** PROPOSED integration and falsification plan; documentation only **Parents:** #1744, #1745, #1750 (CONFLICTING S0 ownership, no canonical merge approved), #1746 (intake/value dispatch), #1747 (focus), #1748 (physical execution).