Repository navigation
feat: port learning ops, project_all, bf16_from_projections from rust… - #9
Merged
Merged
Conversation
…ynum Parity with rustynum-core session 1: Plane: - encounter_toward(): reinforce toward another plane's bit pattern - encounter_away(): anti-learn by inverting bits (DreamerV3 STE gradient) - reward_encounter(): dispatch based on reward sign Node: - project_all() -> [Distance; 7]: all 7 non-empty SPO mask projections BF16 Truth: - bf16_from_projections(): pack 7 band classifications + distance + causality direction into 16-bit BF16 truth value - bf16_unpack_projections(): roundtrip decode 15 new tests covering all new methods. https://claude.ai/code/session_01CLTZ1H5b51iHarkNgEdC5f
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
AdaWorldAPI
pushed a commit
that referenced
this pull request
Mar 23, 2026
Minecraft-style variable bit width encoding for palette indices (1–8 bits). Smaller palettes use fewer bits: 4-entry palette → 2 bits → 4× compression. Core API: - bits_for_palette_size(n) → minimum bits needed - pack_indices(&[u8], bits) → Vec<u64> - unpack_indices(&[u64], bits, count) → Vec<u8> - pack/unpack_indices_bytes() — serialization-friendly byte variants - transcode(packed, old_bits, new_bits, count) — in-place width change - compression_ratio(bits) → f32 PackedPaletteArray wrapper: - from_indices() — auto-selects bit width from palette size - get(i)/set(i, val) — O(1) random access into packed data - grow_palette(new_size) — widen bit width when palette grows - compression_ratio() — actual compression achieved 18 tests covering: all bit widths (1-8), non-aligned boundaries, byte roundtrip, transcode, grow, compression, empty/single edge cases. https://claude.ai/code/session_01CdqyUTUfjKZuk8YGJzv6LB
AdaWorldAPI
pushed a commit
that referenced
this pull request
Mar 30, 2026
Tactics 1-12 from the 34-tactic integration plan, adapted to ndarray: styles::rte — #1 Recursive Thought Expansion (Hofstadter) styles::htd — #2 Hierarchical Thought Decomposition (CLAM) styles::smad — #3 Structured Multi-Agent Debate (NARS revision) styles::tcp — #5 Thought Chain Pruning (Berry-Esseen) styles::irs — #9 Iterative Roleplay Synthesis (XOR binding) styles::mcp — #10 Meta-Cognition (Brier score calibration) styles::tca — #12 Temporal Context (Reichenbach tense) Plus additions to existing modules: causal_diff.rs — #4 reverse_trace() (Pearl Rung 3) bgz17_bridge.rs — #6 inject_noise() (simulated annealing) nars.rs — #7 adversarial_critique(), #11 detect_contradiction() cascade.rs — #8 adaptive_resolution() Every tactic is fn(Base17, NarsTruth) → result. No LLM prompting. 16 tests passing. API: crate::hpc::styles::rte::expand() etc. https://claude.ai/code/session_01M3at4EuHVvQ8S95mSnKgtK
3 of 6 tasks
AdaWorldAPI
pushed a commit
that referenced
this pull request
Aug 30, 2026
Adds the two operators the polyfill lacked for mask composition: set
difference, and any 3-input boolean function selected by a truth-table
immediate. No new type — U64x8 (8 x u64 = 512 bits) and U32x16 already
exist in every backend and are re-exported from all six arms of simd.rs,
so simd.rs needs no dispatch change; the methods ride along.
Why these two: FieldMask-style bitsets had AND/OR/XOR and no and-not,
which is the operator 'stack this prerequisite, exclude that one' needs,
and no three-input form at all. Stacking N prerequisite masks cost N-1
ops; with ternlog it costs ceil((N-1)/2), and on AVX-512 each of those is
one instruction over 512 positions regardless of how many bits are set.
Semantics, identical on every backend:
a.andnot(b) = a & !b -- NOTE the argument order differs from the raw
intrinsic: _mm*_andnot_si*(a, b) computes !a & b. Documented at every
definition; the AVX-512 path swaps its arguments accordingly.
a.ternlog::<IMM>(b, c): per bit, index = (a<<2)|(b<<1)|c, result bit =
(IMM >> index) & 1 (Intel VPTERNLOG convention). IMM is i32 to match
the intrinsic; 0..=255 legal, enforced at compile time by the
intrinsic's own static assert. Named immediates (AND3, AND2_ANDNOT,
OR2_AND, MAJ3, ...) in the scalar backend's ternlog module.
Total functions: no saturation, no overflow, no UB, no lane interaction.
Backends. AVX-512 uses the native intrinsics; that module compiles only
under a global target_feature = avx512f, which is the guard -- no added
CPU check, no runtime detection. AVX2/NEON/wasm/scalar share ONE portable
body: an element-wise loop over the repr(align(64)) backing array, the
same idiom this file's existing BitAnd/BitOr/BitXor use. That is not a
scalar fallback -- measured codegen below.
Measured codegen (examples/w1a9_codegen_probe.rs, black_box'd inputs,
release):
v4 (config-avx512.toml):
ternlog::<0x80> -> vpternlogq /bin/bashx80,%zmm2,%zmm1,%zmm0 (1 insn)
ternlog::<0x40> -> vpternlogq /bin/bashx40,%zmm2,%zmm1,%zmm0 (1 insn)
andnot -> vandnps %zmm0,%zmm1,%zmm0 (1 insn)
v3 default (.cargo/config.toml):
ternlog::<0x80> -> 2 x [vmovaps ymm; vandps; vandps; vmovaps]
aligned moves, 512 bits in 8 insns
The portable body auto-vectorises to real ymm work; repr(align(64)) is
what earns the aligned vmovaps. Matches the storage documented for the
HSW/ARL profiles in .claude/knowledge/agnostic-surface-cpu-matrix.md.
Tests (5, at the simd.rs facade so they exercise whichever backend the
build selected): all 256 immediates against an independent bit-by-bit
truth-table reference; andnot direction with an anti-vacuity assertion
that the self-minus-other vs not-self-and-other distinction is actually
observable on the corpus; named-immediate meanings with a pairwise
distinctness check so aliasing cannot pass; agreement with the existing
BitAnd/BitOr/BitXor operators; the 32-bit-lane sibling. Fixed-seed
SplitMix64 corpus with edge cases (0, MAX, 0x5555.., 0xAAAA..), no
dev-dependency added.
Verification: lib suite 2207 passed / 0 failed on the v3 arm; cargo check
clean on the v4 arm; fmt clean; clippy adds no finding (3 pre-existing
warnings remain in property_mask.rs / bitwise.rs / palette_codec.rs,
untouched here).
Known gap, stated rather than papered over: the v4 arm's *test* build is
broken on main independently of this change (15 errors on a clean tree,
missing I8x16/U64x8/U16x8 types in unrelated test modules), so the parity
tests could not be RUN under AVX-512 -- only compiled. The native path is
verified by the disassembly above, not by a test execution.
Consumer site: AdaWorldAPI/lance-graph crates/lance-graph-contract/src/
class_view.rs -- FieldMask/WideFieldMask carry intersect/union/is_disjoint
and lack difference/is_subset_of (D-MAR-1); and graph/blasgraph/
typed_graph.rs masked_traverse, which filters a materialised result
per-entry instead of masking during the operation.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KCGhDYoQBXs3poaR7sFuqp
AdaWorldAPI
pushed a commit
that referenced
this pull request
Aug 30, 2026
Removes every lane index from the portable backends. andnot becomes `self & !other`; ternlog composes from the BitAnd/BitOr/Not these types already carry. No `for i in 0..N`, no per-lane helper functions -- masking is a projection over the whole register, and a loop expressed it as a traversal even though LLVM undid it. The two portable backends now carry byte-identical bodies, which is the polyfill's point: one source, one geometry, per-arch lowering selected by the compile-time dispatch in simd.rs. Scope note: ternlog is bitwise, so it has no lane semantics at all -- it applies its truth table independently at every bit position. Every reading of a 12-byte cell (6x2, 4x3, 3x4, 24xi4) is therefore masked by the IDENTICAL mask; the operation never sees, and never imposes, a carving. That is why this crate ships the node only: no fold, no composition structure, no state. Composition and interning belong to the consumer. Codegen re-measured after the rewrite, unchanged: v4: vpternlogq $0x80 / $0x40, vandnps -- one instruction each v3: 2 x [vmovaps ymm; vandps; vandps; vmovaps], aligned Net -49 lines. Suite 2207 passed / 0 failed, fmt clean, clippy baseline unchanged (3 pre-existing warnings in untouched files).
AdaWorldAPI
pushed a commit
that referenced
this pull request
Aug 31, 2026
… the facade Addresses the three review findings on the W1a-#9 masking PR: - P1 (codex): andnot/ternlog now exist on every dispatched backend, not only scalar/avx2/avx512 — added to the aarch64 simd_neon U32x16 (elementwise over the fanned array, the file's oracle-blessed codegen shape), the wasm32_simd U32x16 (per-part v128_and/or/not/andnot; the wasm andnot intrinsic argument order already matches this crate's direction), and the nightly U64x8/U32x16 (core::simd whole-register ops). aarch64 compile-verified via cargo check --target; the wasm arm is blocked from a whole-crate check by the pre-existing getrandom wasm dependency gap, noted honestly. - P2 (cursor/codex/coderabbit): the named truth-table immediates moved from the scalar backend (compiled out on x86) to the always-compiled facade as crate::simd::ternlog, doc pointers in avx512/scalar updated, and the named-immediates test now routes through the public constants so they are exercised, not just documented. - coderabbit nitpick: portable/avx2/neon/wasm/nightly ternlog arms gain the same compile-time IMM domain guard the AVX-512 intrinsic enforces (inline const assert, 0..=255). All five w1a9 facade tests pass; full lib suite green (2255 passed). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KCGhDYoQBXs3poaR7sFuqp
AdaWorldAPI
added a commit
that referenced
this pull request
Aug 31, 2026
simd(W1a-#9): U64x8/U32x16 andnot + ternlog — the masking primitives
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.
Here's the summary of what's been completed on rustynum:
Session 1 Results — Rustynum Hot-Path Upgrade
Priority 1: Learning Operations (all done)
Plane: encounter_toward(), encounter_away(), reward_encounter() — DreamerV3 STE gradient in integer form
Node: project_all() → [Distance; 7] for all 7 SPO mask projections
BF16: bf16_from_projections() packs 7 band classifications + finest distance + causality direction into 16-bit truth value; bf16_unpack_projections() for roundtrip
Priority 2: Cascade Bridge (done)
PackedDatabase::cascade_query_banded() — combines stroke-aligned layout with Cascade's calibrated thresholds and Band classification
BandedHit type for results with quality band labels
kernels.rs, cam_index.rs, prefilter.rs reviewed — already well-designed, pure scalar by intent
Priority 3: Learning Dynamics (done)
fingerprint_to_evidence() — Fingerprint bits → [i8] evidence
organic_encounter() — BCM-mediated encounter with theta-dependent potentiation, maturity damping
Priority 4: Parity Verification (done)
10 deterministic integration tests in tests/parity_deterministic.rs
Covers Plane, Node, Fingerprint, Merkle, BF16, and PackedDatabase
Test Count
1587 total tests passing across workspace (468 rustynum-core + 10 parity + rest)
+596 lines of new code across 7 files