Repository navigation
uorc: ncm v2, 3.9% smaller on Canterbury (--best 355,559 B vs xz -9e 493,080) - #119
Merged
Merged
Conversation
Throughput (#105): crates/uorc now carries native Rust ports of the model's hot paths, byte-identical to it: - ulz.rs: the LZ + range coder of Uorc.Codec.LzEncode/LzDecode. - archive.rs: the archive layout, kernel prefix/suffix and the UORC-SHA256-CHAIN-v1 seal (sha2), mirroring Uorc.Codec.Archive. compress writes exactly the archive the exported model writes (tested against it). The native decoder only accepts payloads on which every reading agrees (code < range throughout, match sources inside the output, no overrun, payload consumed exactly) and so needs no canonical re-encode check; anything else goes to the exported reference decoder, and a differential test checks agreement on damaged payloads. Streaming (#106): a uorc stream is standard self-contained archives laid end to end, one per 8 MiB frame; a one-frame stream is the model's archive byte for byte. compress_stream/decompress_stream keep memory bounded by frames in flight, frames run in parallel (--threads), and the native paths need no large stack (the 1 GiB reservation now applies only to the exported reference code). The wasm page streams files through frames too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
…P, export pending) The ncm coder (client/gen/ncm_model.py, one IR compiled to LexLean, to the UORC kernel graph and ported natively) and the standard kernel basis: the ulz and ncm decoder libraries bound by one UORC-BASIS-V1 identity, named by linked (scope 1) archives so small files carry no kernel. Compress gains a level (--best tries ncm). The exported client is not regenerated yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
Throughput (#105): crates/uorc now carries native Rust ports of the model's hot paths, byte-identical to it: - ulz.rs: the LZ + range coder of Uorc.Codec.LzEncode/LzDecode. - archive.rs: the archive layout, kernel prefix/suffix and the UORC-SHA256-CHAIN-v1 seal (sha2), mirroring Uorc.Codec.Archive. compress writes exactly the archive the exported model writes (tested against it). The native decoder only accepts payloads on which every reading agrees (code < range throughout, match sources inside the output, no overrun, payload consumed exactly) and so needs no canonical re-encode check; anything else goes to the exported reference decoder, and a differential test checks agreement on damaged payloads. Streaming (#106): a uorc stream is standard self-contained archives laid end to end, one per 8 MiB frame; a one-frame stream is the model's archive byte for byte. compress_stream/decompress_stream keep memory bounded by frames in flight, frames run in parallel (--threads), and the native paths need no large stack (the 1 GiB reservation now applies only to the exported reference code). The wasm page streams files through frames too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
…ntial tests, ulz history window Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
Scalars live in a small table instead of a rebuilt record, long statement lists are split into functions, literals go first in additions, and literal loop counts name the state, so the preservation certificate does not unroll the model's setup. Output is byte-identical to before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
A frame can name the outputs of the K preceding frames (K = 1 or 2) as basis roots 1..K after the kernel library (root 0), so its ulz payload is coded against that window and matches reach across frame boundaries. - LzDecode.decodeWith / LzEncode.encodeWith: the codec against a history window (decode/encode are the empty-history case, byte for byte as before). - ulz library block runWith(payload, history); window entries apply it to basisGet 1 (++ basisGet 2). Graph mirror gains basisGet; gen_basis --check decodes K=1 and K=2 window frames on the mirror. - Archive: windowIdentity (UORC-BASIS-V1 chain over [library, window..]), windowArchive, ulzWindowArchive, windowDecode, fastDecodeWith, windowMaterialize (keeps scope 1 and the identity; inlines the library). - Client: compress(input, window, steps, level); decompress(archive, window, work) passes scope conditional + basis [library, window..] to the reference trial for window frames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
The differential tests run the exported decoder graph; unoptimized, the uorc unit tests took 30 min of the 60 min acceptance leg (main is over budget too). At opt-level 1 they take 4.5 min for about 6 min more compile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
ncm, a context-mixing coder extrapolated from the neuromorphic model, is written once as an IR and compiled to LexLean, to a UORC kernel graph and natively. The ulz and ncm decoder libraries form root 0 of a UORC-BASIS-V1 basis; archives are linked to it by identity, so small files no longer carry a 2.6 KB kernel. Level::Best (--best) also tries ncm and keeps the smaller archive; on Canterbury it is smaller than xz -9e on every file. inspect names linked archives' representation (ulz or ncm). Closes #62. Closes #107. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
…to claude/project-thread-84bxra
…to claude/project-thread-84bxra
…-84bxra # Conflicts: # crates/uorc-wasm/src/lib.rs # crates/uorc/src/archive.rs # crates/uorc/src/bin/uorc.rs # crates/uorc/src/lib.rs
The context-mixing coder gains: - two adaptive probability maps (selected by the partial byte and by an order-3 hash) that refine the mixed probability; - a third mixer, selected by the byte before the previous one and the bit position; - a plasticity that decays from 128/65536 to 24/65536 per unit of x * err as the input is seen; - a check byte in each 16-slot bucket's unused slot 0, with a neighbour pair and recycling by use, so colliding contexts stop sharing counts. Model IR, LexLean, kernel graph and the native port are byte-identical to the C spec on Canterbury. The ncm library grows, so the basis identity and the linked templates are regenerated, and generated/rust is re-exported. No released archive uses the previous identity. Canterbury, uorc --best: 355,559 B (was 369,878; xz -9e 493,080). bench.mjs passes --force, since the client refuses to overwrite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
…-84bxra # Conflicts: # scripts/bench.mjs
afflom
pushed a commit
that referenced
this pull request
Nov 10, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
afflom
pushed a commit
that referenced
this pull request
Nov 10, 2026
… arrived through the branch history) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Asa3NpWuTWFrL9kYU72Rv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Alex · project thread
A follow-up to #116, aimed at the highest ratio. This must land before the v0.2.0 tag, because it replaces the standard basis identity. No released archive uses the old one: v0.1.0 predates the basis.
Result (Canterbury, release binary,
scripts/bench.mjs --steps 0)--bestis 3.9% smaller than before and 27.9% smaller thanxz -9e. The default mode is unchanged.What changes in the model (
client/gen/ncm_model.py)Tried and left out because they gained too little or nothing:
Larger tables (2^25 or 2^26 slots) would take another 0.4 to 0.5% at 2x to 4x memory, so they are not in this PR.
Checks
grammar.lspandfields.c), the kernel graph (reference-semantics mirror,gen_basis.py --check) andcrates/uorc/src/ncm.rs(all 11 Canterbury files) are each byte-identical to the C spec.gen_basis.pyregeneratesbasis-id.hex,basis-library.hexand the linked ulz, ulz1 and ulz2 suffix templates (block indices move).generated/rustis re-exported (node scripts/client-export.mjs). The encoder's rust-std certificate passes, and the exact axiom lists are unchanged.native_archives_are_the_model_archives(both levels) passes against the new export.cargo test --release -p uorc,cargo clippy -p uorc -p uorc-wasm --all-targets -D warningsandcargo fmt --checkpass locally on top of uorc: window frames, so matches cross 8 MiB frame boundaries #117.scripts/bench.mjsnow passes--force. Since uorc client: inspect, verify, safe writes, multi-file archives #110 the client refuses to overwrite, and every uorc row came out as an error.Generated by Claude Code