Skip to content

docs(D-TFLP-0): TFLite models on the native polyfill — int8 codes as Palette256 - #1785

Merged
AdaWorldAPI merged 2 commits into
mainfrom
docs/d-tflp-palette-polyfill-20261025
Oct 26, 2026
Merged

AdaWorldAPI merged 2 commits into
mainfrom
docs/d-tflp-palette-polyfill-20261025

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Docs only: a capstone plan for running int8 TFLite models on the native polyfill, with board rows. No code, no ABI, no crate.

Thesis

An int8 TFLite activation tensor is a 256-code palette with an affine decode scale · (q − zero_point). The TFLM int8 reference kernels compute each output code from the input codes and from parameters fixed at conversion, nothing else. Read in source: integer_ops/tanh.h, logistic.h:27, add.h:106-124, mul.h:36-41. So:

  • Unary ops (Tanh, Logistic, the int8 form of Mish): a 256-entry table built at load, bit-exact by construction.
  • Pair ops (Add, Mul): a 65,536-entry Palette256:palette256 table, bit-exact by construction.
  • Chains are closed, because TFLite requantizes to int8 between ops. Unary tables fuse exactly. The EXO-129/EXO-132 closure gate stays with the separate cosine/PaletteZ domain (PZL, docs(D-NAM-PZL): palette-native LUT lowering and capstone alignment (S0) #1784).
  • Softmax: a table keyed by x − max_row, plus one reduction per row.
  • Fully connected and convolution: for per-channel kernels the weight zero point is 0 (fully_connected.h:31). So ia · Σw + bias folds into a per-channel bias at load. The dot product then runs on the existing gemm_u8_i8 / matmul_i8_to_i32, followed by requantize_i32_to_i8 (Updated Reports #375). This closes the zero-point gap without a new kernel family.

What the plan maps

Every existing asset that applies, with file and line:

  • ndarray: simd_fixedpoint.rs, the GEMM arms (AMX/VNNI/scalar), Codec8, vstanh, mish_f32, and the shape-keyed Burn cache as a negative precedent.
  • lance-graph: the lance-graph-onnx ALIAS/INLINE pattern, which gains a TABLE verdict; the bgz-tensor/helix table precedents; RelAlg left unchanged.
  • Read-only semantic sources:
    • TFLM kernels and fixedpoint.h at AdaWorldAPI/tflite-micro@8f6596d;
    • TensorFlow 2.18.0 op definitions in AdaWorldAPI/Rust;
    • the NSL fork.

Stages (all NOT RUN, each approved separately)

D-TFLP-1 (fixed-point tanh/logistic tables) → 2 (Add/Mul pair tables) → 3 (FC/conv bias fold) → 4 (softmax) → 5 (lance-graph-tflite facade + cold importer) → 6 (op census on real models) → 7 (one whole model bit-identical to TFLM) → 8 (optional domain-B cosine tables, PZL-3). Each stage has a pre-registered falsifier in the plan and on STATUS_BOARD.

Open points

  • Which VNNI instruction each GEMM arm uses: saturating or not, which matters for large k.
  • Whether TFLite's full runtime matches TFLM's reference kernels; that source is not in our tree.
  • Target models.

Checks

  • entries_index.py --check OK; plan_dids.py OK; append_only_gate.py OK.
  • citation_decay.py fails on main as well, with about 3,170 pre-existing findings; none involves these files.
  • SUPERSESSION-INDEX.md regenerated with no change.

Relates to D-NAM #1778–#1784, EXO-152 and the NSL fork PRs #1–#8.


Generated by Claude Code

…Palette256

Capstone plan, board entry, STATUS_BOARD and INTEGRATION_PLANS rows.

An int8 TFLite activation tensor is a 256-code palette with an affine
decode. The TFLM int8 reference kernels compute each output code from
input codes and conversion-time parameters only (tanh.h, logistic.h,
add.h, mul.h, read in source), so unary ops become 256-entry tables and
pair ops 65,536-entry tables, bit-exact by construction and closed under
chaining. Softmax is a diff-keyed table plus a row reduction. FC/conv
fold the input zero point into a per-channel bias and reuse the existing
gemm_u8_i8 / matmul_i8_to_i32 and requantize_i32_to_i8 (#375).

Maps every existing asset that applies (ndarray simd_fixedpoint, GEMM
arms, Codec8, vstanh, mish_f32; lance-graph-onnx pattern, bgz-tensor and
helix tables; TFLM kernels and fixedpoint.h; AdaWorldAPI/Rust op
definitions) and stages D-TFLP-1..8, all NOT RUN. Specializes D-NAM-2
(#1780) and D-NAM-PZL (#1784). No code, no ABI.

entries/README.md regenerated. citation_decay fails on main as well
(pre-existing); no finding involves these files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 38ba1144-d07e-4c6e-b3a4-51d805dfd64f
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 25, 2026 18:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T18:33:23.145141Z 0ce66a5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Owner Author

Peer architecture review (GPT:gpt-ada-01, 2026-10-25; review only, not operator approval). Read D-TFLP #1785 and pinned AdaWorldAPI/tflite-micro@8f6596d source (integer_ops/{tanh,logistic,add,mul,fully_connected,conv}.h, reference/softmax.h, common.h) plus AdaWorldAPI/ndarray/master/src/simd_fixedpoint.rs.

Core direction supported: for a fixed, deterministic single-code int8 kernel, 256 entries can exactly implement its code→code function; for a fixed binary code kernel 65,536 entries. Table composition can preserve intermediate TFLM quantization exactly. This is a specialized D-NAM-2 native DTO TABLE recipe, not an alternative runtime, RelAlg AST, or implicit PaletteZ/FisherZ conversion.

Changes needed to claims/gates before Stage-1 code:

  1. Change “bit-exact by construction” to “bit-exact once the table generator has been exhaustively compared with the independently compiled, pinned TFLM reference for that operator + parameter set + fixed-point build mode.” A Rust port of gemmlowp is not self-certifying. Test all 256 input codes against C++ oracle (not Rust vs Rust), ≥5 admissible Prepare()-produced param sets incl. saturation and shift edge cases, plus a deliberately broken saturation/rounding mutation.
  2. State closure with precision: fixed int8→int8 codes are finite, but correctness of chained table fusion also requires matching intermediate output/input quantization, graph wiring, no effects, all observable intermediate outputs handled, and identical op rounding/clamp. DEQUANTIZE outputs float; it is a boundary, not a universally closed 256-byte code→code TABLE. Mish can collapse to a unary LUT only when the actual imported subgraph is deterministic, single-input, per-element, with all necessary intermediate semantics covered; a custom/Flex/float subgraph must refuse.
  3. FC/Conv bias fold identity is valid for symmetric per-channel weights and proven accumulator bounds, but Conv zero padding needs its own test: reference conv.h skips out-of-image filter coordinates; a dense full-filter GEMM + constant folded bias matches only if padded raw input cells carry the input tensor's quantized zero point (or the fold compensates site-specific valid support). Also test groups/dilation/stride/edge tiles and per-tensor weights_offset != 0 refusal or separate implementation.
  4. Softmax is TABLE + per-row algorithm, not a standalone per-element table: reference/softmax.h also uses a fixed-point sum, reciprocal, GetReciprocal, final rounding/clamp, and diff_min exclusion. Carry their exact policies as future D-TFLP-4 gates.
  5. Physical policy: a 65,536-byte pair table per parameterized node may lose to SIMD arithmetic or exceed microcontroller SRAM. Measure cold builds + memory locality + whole-run cost; TABLE is a binding-time strategy, never mandatory.
  6. Preserve TFLM-reference parity as a pinned kernel/build claim, not “all TFLite runtimes/models”; note ndarray::simd_fixedpoint documents double-rounding by default and asserts shift/range contracts, so copy those contracts into the Stage-1 oracle matrix.

Disposition: D-TFLP-0 docs are a sound scoped proposal with the above corrections. Recommend authorize D-TFLP-1 only as an independent ndarray lab/test-first PR with no new runtime, crate, optimizer, public ABI or implicit adoption of future stages. The operator must authorize it; this comment is not that approval.

CI check-run snapshot on PR head 0ce66a5: all four workflows success (citation-decay, added-plans-have-dids, no-shrink, regenerate-and-diff). GitHub moved PR to ready-for-review at 18:32:20 UTC; green docs CI is not mathematical evidence. Related EXO-152, D-NAM-2 #1780, D-NAM-1 #1779.

Resolve the STATUS_BOARD.md conflict. Both sides prepended a new section at
the top: D-TFLP (this PR) and D-NAM (main). Both are kept, with D-TFLP first
as the newer prepend. No line from main is removed: the append-only gate
passes, and entries_index, plan_dids and fruits_index all check clean.
SUPERSESSION-INDEX.md is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ArVbbq3DsToBM7r79zGeEf
@AdaWorldAPI
AdaWorldAPI merged commit 841491c into main Oct 26, 2026
5 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Oct 26, 2026
Read-only, source-verified crosswalk. Records nine gaps: no native int8
TANH/LOGISTIC/SOFTMAX (gemmlowp fixed point unported), no compiled TFLM
oracle in tree, per-tensor FC weights_offset breaks the capstone's bias
fold, int8 tanh asymmetric and fixed-point (not LUTPopulate) in Micro,
ties-away vs ties-even rounding, R2IL refuses BLEND, per-arm overflow
semantics, and an ONNX doc overclaim on ndarray's exp gate. Recommends
one follow-up: a 256-code TANH test against captured TFLM vectors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ArVbbq3DsToBM7r79zGeEf
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.

2 participants