wai-rs: e2e — recover the hyper-latent z from the real codestream (byte-exact) #20

Merged
dcharlot merged 1 commit from feat/jpegai-e2e-z into main 2026-07-17 03:14:05 -04:00
Owner

First stage chained straight off the bitstream rather than a fixture: parse the container → take SOZ’s bytes → run the byte-exact mANS fac decoder with the normative per-channel CDFs → offset symbols by 31 (mid-point of the 63-symbol alphabet) → signed z.

SOZ carries both planes back to back (luma 160ch, then chroma 96ch, 16 samples/channel), decoded by one MansDecoder whose ANS state threads across the calls.

Validated on test256.bin: z[y] 2560/2560 exact (75 non-zero, range [-3,4]), z[uv] 1536/1536 exact — both equal the reference z that decode_hyper_scale consumes.

This joins the decoder’s two halves: the container/entropy path now reproduces, from raw bytes, the exact tensor the neural scale path was independently validated against.

**First stage chained straight off the bitstream** rather than a fixture: parse the container → take SOZ’s bytes → run the byte-exact mANS `fac` decoder with the normative per-channel CDFs → offset symbols by 31 (mid-point of the 63-symbol alphabet) → signed `z`. SOZ carries both planes back to back (luma 160ch, then chroma 96ch, 16 samples/channel), decoded by **one** MansDecoder whose ANS state threads across the calls. **Validated on test256.bin:** `z[y]` **2560/2560 exact** (75 non-zero, range [-3,4]), `z[uv]` **1536/1536 exact** — both equal the reference `z` that `decode_hyper_scale` consumes. This joins the decoder’s two halves: the container/entropy path now reproduces, from raw bytes, the exact tensor the neural scale path was independently validated against.
First stage chained straight off the bitstream rather than a fixture: parse the
container, take the SOZ substream's bytes, and run the byte-exact mANS `fac`
(factorized) decoder over it with the normative per-channel CDFs. Symbols are offset
by 31 (the mid-point of the 63-symbol alphabet) to give signed z.

SOZ carries both planes back to back — luma (160 ch) then chroma (96 ch), 16 samples
per channel — decoded by ONE MansDecoder whose ANS state threads across the two calls.

Validated on test256.bin: z[y] 2560/2560 exact (75 non-zero, range [-3,4]) and
z[uv] 1536/1536 exact, both equal to the reference z that decode_hyper_scale consumes.
This joins the two halves of the decoder: the container/entropy path now reproduces,
from raw bytes, the exact tensor the neural scale path was validated against.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Transaction-Science/open-standards!20
No description provided.