Skip to content

tflm oracle: independent int8 TANH reference outputs (Stage B) - #442

Merged
AdaWorldAPI merged 1 commit into
masterfrom
claude/bpe-tokenization-architecture-3xd4eh
Nov 30, 2026
Merged

AdaWorldAPI merged 1 commit into
masterfrom
claude/bpe-tokenization-architecture-3xd4eh

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

What this adds

Reference outputs for TFLite Micro's int8 TANH kernel, for a future native port to be tested against. No Rust code changes, and nothing in the crate reads these files yet.

  • tools/tflm_oracle/tanh_int8_oracle.cc: a harness that runs the real tflite::Register_TANH() (prepare in tanh.cc, eval in integer_ops/tanh.h) through tflite::micro::KernelRunner:
    • over all 256 int8 input codes;
    • for seven input calibrations;
    • with the TANH output contract (scale 1/128, zero point 0).
  • tests/data/tflm/tanh_int8_8f6596d.json: the outputs, with their provenance:
    • the TFLM commit (8f6596d, kernel tree identical to the checkout);
    • sha256 of tanh.cc, integer_ops/tanh.h, common.h, fixedpoint.h and the harness;
    • compiler and flags;
    • the third-party commits (flatbuffers, kissfft, printf).
  • tools/tflm_oracle/README.md: how to rebuild TFLM and the harness and reproduce the fixture.

Evidence

  • Two runs and a -Werror rebuild produce byte-identical output.
  • TFLM's own tanh tests pass on the same build (3 passed).
  • The fixture also records that TFLM's int8 TANH prepare accepts a non-conforming output declaration (scale 0.1, zero point 5) and produces the same bytes. The port has to decide whether to reproduce that or refuse it.

The native port is a separate stage.


Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Added reference output data for int8 TANH behavior across seven input configurations, including a check of output quantization handling.
  • Documentation
    • Added guidance on the oracle’s coverage, reference setup, dependencies, and how to reproduce the results.

Adds a harness that runs TFLite Micro's real Register_TANH() through
KernelRunner over all 256 int8 input codes for seven input calibrations
(TANH output contract: scale 1/128, zero point 0), and the resulting
fixture with provenance: TFLM 8f6596d (kernel tree identical), sha256 of
tanh.cc, integer_ops/tanh.h, common.h, fixedpoint.h and the harness,
compiler and flags, third-party commits. Two runs and a -Werror rebuild
are byte-identical; TFLM's own tanh tests pass on the same build.

The fixture also records that TFLM's int8 TANH prepare accepts a
non-conforming output declaration (scale 0.1, zp 5) and produces the
same bytes. No native code is added; the port is a separate stage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ArVbbq3DsToBM7r79zGeEf
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T00:21:04.430938Z bd86020 PR opened
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

This change adds a TFLite Micro int8 TANH oracle, a JSON fixture with results for seven input calibrations, and documentation describing the fixture’s provenance and reproduction commands. The oracle also records a nonconforming output-quantization probe.

Changes: TFLM TANH int8 oracle

Layer / File(s) Summary
Oracle execution and output generation
tools/tflm_oracle/tanh_int8_oracle.cc
The oracle runs the registered TANH kernel on all 256 int8 input codes for seven calibrations. It emits prepare and invoke status, input and prepared parameters, and output bytes.
Quantization probe and recorded fixture
tools/tflm_oracle/tanh_int8_oracle.cc, tests/data/tflm/tanh_int8_8f6596d.json, tools/tflm_oracle/README.md
The oracle records a probe with output scale 0.1 and zero point 5. The fixture records its results and provenance, and the README describes the setup and reproduction commands.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Oracle as TANH int8 oracle
  participant Kernel as TFLite Micro TANH kernel
  participant Fixture as JSON fixture
  Oracle->>Kernel: Prepare tensors for an input calibration
  Oracle->>Kernel: Invoke if preparation succeeds
  Kernel-->>Oracle: Status and output bytes
  Oracle->>Fixture: Record calibration details and output bytes
Loading
Merge Risk: Minimal · up to bd860

This adds a reference fixture and the tooling to regenerate it, with no change to runtime behavior. Nothing consumes the fixture yet, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: an independent int8 TANH reference-output fixture (Stage B) for the TFLite Micro oracle. The raw summary shows the added golden-output dataset, the oracle program, and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: an independent int8 TANH reference-output fixture (Stage B) for the TFLite Micro oracle. The raw summary shows the added golden-output dataset, the oracle program, and the README, all of which match this title. The title is specific and concise. The term "Stage B" is a project label that a teammate may not recognize, but it does not make the title misleading.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks each code in flight
Seven scales bring bytes to light
The kernel answers, status clear
A probe records what happens here
JSON keeps the outputs near

Recent review info

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: Essentials
  • Run ID: 59f88e67-4136-40df-99db-a6f4546c8b7b
Commits

Reviewing files that changed from the base of the PR and between f9c1375 and bd86020.

Files selected for processing: 3

  • tests/data/tflm/tanh_int8_8f6596d.json
  • tools/tflm_oracle/README.md
  • tools/tflm_oracle/tanh_int8_oracle.cc

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

@AdaWorldAPI
AdaWorldAPI merged commit 6751b7d into master Nov 30, 2026
22 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.

2 participants