Skip to content

Named u8↔i8 bit reinterpret; Codec9 runtime scale and batch encode - #397

Merged
AdaWorldAPI merged 2 commits into
masterfrom
ccr-45a41fb4-0j3i0l
Oct 30, 2026
Merged

AdaWorldAPI merged 2 commits into
masterfrom
ccr-45a41fb4-0j3i0l

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

What

This PR implements two operator rulings from 2026-10-30.

1. u8→i8, only through an explicit intent parameter.

  • ReinterpretBits is a zero-sized marker type.
  • U8x64::reinterpret_as_i8(ReinterpretBits) and I8x64::reinterpret_as_u8(ReinterpretBits) live in src/simd.rs and work on every backend.
  • The operation reinterprets bits and converts nothing: 0x80 becomes -128 and 0xFF becomes -1, with no saturation.
  • FACET STRIDE rule 3 in CLAUDE.md now names this as the single allowed crossing; a plain as i8 stays forbidden.
  • This closes the facade gap that U6 recorded (the head-to-head probe's bits_as_i8 store/load stand-in).

2. Codec9 runtime scale and batch encoder, so the same codewords serve exact LUT[a,b] work and learning.

  • Codec9Runtime<R> takes the scale as a value, checked once (it must be positive and finite).
  • It calls the same encoder and decoder as Codec9<R, C>, so equal scales produce identical codewords.
  • Rounding stays a type parameter limited to nearest rounding. Storage, polarity, Sym and NaN handling stay fixed.
  • encode_touched_batch and decode_batch read and write the magnitude lane plus the presence plane:
    • A non-finite value is refused before anything is written.
    • Presence bits past the last lane are cleared.
    • A never-touched lane decodes to NaN.
  • The DR512 law doc records which form to use where:
    • Compile-time Codec9 for codeword tables.
    • Codec9Runtime for learned scales.
    • A table built under one scale must be rebuilt when the scale changes.
  • The batch loops are scalar for now. They have not been measured.

Tests

  • New tests:
    • 8 in hpc::codec9, 12 in that module in total. One pairs Codec9Runtime against Codec9 over a 6,000-value sweep and all 512 codewords.
    • 4 in simd::reinterpret_bits_parity, one of which feeds 0x80 into dot4_u8_i8_add and expects −512 per lane.
  • Disable runs, each turns its test red:
    • the runtime encoder ignores the scale;
    • tail presence bits are not cleared;
    • the batch writes before the finiteness check;
    • the reinterpret saturates;
    • the scale check is removed.
  • Suites:
    • The lib suite passes: 2,676 tests.
    • The reinterpret tests pass on the AVX2 tier (config-v3).
    • The aarch64 lib build passes.
    • wasm-parity.sh and neon-parity.sh pass.
  • Checks: clippy -D warnings and fmt are clean, and the facet-stride guard reports nothing on the diff.

Generated by Claude Code

…batch encode

Operator ruling 2026-10-30. The u8/i8 crossing is allowed only through
an explicit intent parameter: U8x64::reinterpret_as_i8(ReinterpretBits)
and I8x64::reinterpret_as_u8(ReinterpretBits), a bit reinterpret with
no conversion. Codec9Runtime takes the scale as a checked value and
shares one encoder and decoder with the compile-time Codec9, so equal
scales give identical codewords; it adds encode_touched_batch and
decode_batch over the magnitude lane plus the presence plane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMPh2Seh2WLccCksAdY
FACET STRIDE rule 3 names the one sanctioned crossing; the DR512 law
doc records Codec9Runtime and when to use which scale form; synergy map
R4 marks V1, V10, N4 and N14 decided and lists what stays open.

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

coderabbitai Bot commented Oct 30, 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: d0f36181-3d93-4d56-98ca-b76b97ce7eda
  • 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 30, 2026 02:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-30T02:08:37.140625Z 7e6dd25 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
AdaWorldAPI merged commit 6ccaf46 into master Oct 30, 2026
30 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