Skip to content

test(lab): Palette512 signed-magnitude9 / NaN sentinel and fused MAC oracle - #380

Merged
AdaWorldAPI merged 4 commits into
masterfrom
research/palette512-signed-magnitude9-probe-20261027
Oct 27, 2026
Merged

AdaWorldAPI merged 4 commits into
masterfrom
research/palette512-signed-magnitude9-probe-20261027

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Why

This PR probes the proposed Palette512 / sign-magnitude9 encoding: an 8-bit unsigned magnitude per lane plus a sign mask. Sign polarity is applied inside mul_add, not by decoding the whole buffer to signed values first.

Do not conflate this with a generic 512-centroid Palette256 expansion. Existing BGZ Palette256 is an arbitrary u8 archetype index; this experiment is a structured numeric code space.

NaN

NaN is -0, a cleared presence bit over a stored 0. This rule was settled in #381.

  • In this probe there is no presence plane, so "sign set, magnitude 0" is that same NaN, written as a single codeword.
  • With a presence plane, all of −255..=+255 stay values, and NaN never reaches a multiply.

Artifact boundary

  • examples/palette512_probe.rs: a standalone scalar 64-lane prototype.
    • Storage: one 64-byte magnitude plane plus one u64 sign mask (72 bytes).
    • 511 signed numeric values and 1 NaN codeword.
    • A sign-aware checked MAC, tested against independent scalar oracles.
  • .claude/knowledge/palette512-signed-magnitude9-experiment-20261027.md: semantics, physical costs, a map of which owner holds what, the falsifiers, and the separate next gate.
  • This PR changes none of the following: public API, codec8 alias, Cargo dependency, production backend, BGZ codebook or LUT, FamilyGamma envelope, ONNX/TFLite import or export, Quack binding, DT64/DR64, serialized layout, or runtime behavior.

Verification

cargo test --example palette512_probe

All 5 tests pass on rustc 1.99.0. They cover:

  • all 512 codewords;
  • all 262,144 ordered codeword pairs;
  • sign XOR in mul_add;
  • ±255;
  • +0 against −0/NaN;
  • a 64-lane dot product against an independent wide oracle;
  • NaN × zero propagation;
  • overflow kept distinct from NaN.

No benchmark or target-ISA codegen has been run; this is a scalar reference.

Falsifiers

  1. A signed-MAC result disagrees with the independently decoded oracle, NaN is read as zero, or overflow is conflated with NaN.
  2. Reusing a source bit loses the independent presence / NULL semantics.
  3. The finer 511-level domain gives no quality gain on held-out calibrated distributions.
  4. The real end-to-end cost on AVX2, VNNI, NEON or WASM erases the quality or density gain. Unsigned × unsigned dot products exist in AVX-VNNI-INT8 VPDPBUUD, NEON UDOT and wasm extmul_*_u8x16; that list is from documentation, not measured.
  5. The proposed signed palette factorization fails the distance, compose or multi-hop law tests.

Follow-up, gated separately

Build an independent SIMD lowering, then compare its performance and quality fairly against Codec8<Sym,NaNAtMin>. The comparison must count sign-mask load and extraction, correction costs, and saturation/NaN behavior. Folded pair LUTs and source-bound integration come only after that.

Existing ownership / context

🤖 Generated with Claude Code

https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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: 02bd8a1c-4705-400b-b3a3-f546ca0b5cd7
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 27, 2026 14:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T14:39:29.844563Z 30b515d 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.

AdaWorldAPI pushed a commit that referenced this pull request Oct 27, 2026
… presence plane

Follow-up to #380: NaN is a cleared presence bit, not the 'negative zero'
codeword, so all of -255..=+255 are values and the writer stores +0 for zero
and for missing rows. Masked dot splits lanes by sign_a ^ sign_b into two
unsigned u8 x u8 accumulators, NULL excluded by the presence AND, n the
popcount of the same mask. Decode applies nan_where_clear, so the float
NaN/presence bijection holds on the decoded lane.

tanh exactness vs i8 Sym (-127..=127), measured over 2,000,001 points:
output quantization alone 2.01x lower max error, 1.94x lower RMS; a
256-entry table (sign-magnitude indexed by magnitude, sign passed through)
1.92-1.99x max, 1.97-2.02x RMS for input ranges 2..8; saturation onset
3.11 -> 3.46. This is the one extra bit. Scalar reference only; SIMD cost
not measured.

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

Copy link
Copy Markdown
Owner Author

Design note from #381, plus a local run of this probe.

Local run: cargo test --example palette512_probe passes 5/5 on rustc 1.99.0, including the 262,144-pair check. The red format/stable check is rustfmt only: two if expressions in examples/palette512_probe.rs need reflowing, and cargo fmt fixes both.

NaN without a codeword. #381 ships the rule "a cleared presence bit is NaN (NULL)" for float lanes, as a bijection with the NaN payload. On an integer lane the presence plane is the only carrier, and the payload under a clear bit is never read, the same contract as Quack's validity plane. Applied to this encoding:

  • No sentinel: "sign set, magnitude 0" stops being the sentinel. All of −255..=+255 are values, and the writer stores +0 for zero and for missing rows.
  • Storage is unchanged for nullable columns: the presence plane already exists there. Only a column that needs exactly one invalid state and has no presence plane comes out cheaper with the sentinel.
  • NaN leaves the arithmetic. With sel = presence_a & presence_b & filter, lanes split by sign_a ^ sign_b into two unsigned u8 × u8 accumulators: dot = pos − neg, n = popcount(sel). NULL never reaches a multiply. fused_dot's fail-closed behaviour becomes one policy among three: refuse is popcount(filter & !presence) > 0.
  • On the VNNI concern in the note: it no longer applies, because the operands are both unsigned. NEON UDOT, wasm extmul_*_u8x16, x86 AVX-VNNI-INT8 VPDPBUUD, or zero-extend plus pmaddwd. That list is from documentation, not measured.
  • The "cannot be conflated" sentence: it holds for a codec that needs several distinguishable invalid states (NULL, unknown, denied). With one invalid state, NULL is that state.

Measured in #381 (examples/sm9_presence_probe.rs, a scalar reference):

  • Correctness: the masked dot is checked exhaustively against a decoded oracle over (value or NULL) × (value or NULL), on random blocks with a filter, and with a garbage payload under a clear bit.

  • tanh exactness against Codec8<I8, Sym, TiesEven> over 2,000,001 points. tanh is odd, so the sign-magnitude table is indexed by magnitude and the sign plane passes through untouched.

    • Output quantization alone: max error 0.003937 → 0.001961 (2.01×), RMS 1.94×.
    • 256-entry table, input range 2..8: max 1.92–1.99×, RMS 1.97–2.02×.
    • Saturation onset: 3.11 → 3.46.

    That is the one extra bit. The SIMD cost and the held-out calibration gate in this PR are still open.


Generated by Claude Code

rustfmt reflows three expressions (the red format/stable check).

The note said the five tests were not run; they pass on rustc 1.99.0.
It also said x86 has no unsigned x unsigned dot product; AVX-VNNI-INT8
VPDPBUUD, NEON UDOT and wasm extmul do (from documentation, not
measured). And it records the rule settled in #381: NaN is -0, a
cleared presence bit over a stored 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
@AdaWorldAPI
AdaWorldAPI merged commit f704a16 into master Oct 27, 2026
21 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