Skip to content

D1.2 rotation primitives + taxonomy/ladder/shader-vs-engine epiphanies (95/95 tests)#234

Merged
AdaWorldAPI merged 2 commits into
mainfrom
claude/teleport-session-setup-wMZfb
Apr 20, 2026
Merged

D1.2 rotation primitives + taxonomy/ladder/shader-vs-engine epiphanies (95/95 tests)#234
AdaWorldAPI merged 2 commits into
mainfrom
claude/teleport-session-setup-wMZfb

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

Second Phase 1 kernel deliverable + three strategic epiphanies from this session's "codec IS thinking" thread.

95/95 cognitive-shader-driver --features serve tests pass (+15 new D1.2 tests).

D1.2 — Rotation primitives (5c37f0c)

crates/cognitive-shader-driver/src/rotation_kernel.rs — ~330 LOC, 15 tests.

pub trait RotationKernel: Send + Sync + Debug {
    fn apply(&self, vec: &mut [f32]) -> Result<(), RotationError>;
    fn dim(&self) -> u32;
    fn signature(&self) -> u64;     // feeds CodecParams::kernel_signature
    fn backend(&self) -> &'static str;  // never "scalar" — iron rule
}

pub struct IdentityRotation { dim }              // no-op
pub struct HadamardRotation { dim }              // REAL Sylvester butterfly, O(N log N)
pub struct OpqRotationStub { matrix_blob_id, dim } // stub pending D1.1b matrix loader

pub fn build(rotation: &Rotation, dim: u32) -> Result<Box<dyn RotationKernel>>;

Key detail — Hadamard is pure Rust, not JIT-necessary. The Sylvester butterfly is a fixed-shape add/sub pattern; rustc under target-cpu=x86-64-v4 already emits AVX-512 from the straight-line loop. Per Rule C (polyfill hierarchy), add/sub stays at Tier 3 F32x16 — AMX gives no benefit here. This narrows D1.1b Cranelift scope by 30-40%: only OPQ (matmul) needs JIT emission; Identity and Hadamard stay as plain Rust.

Tests verify:

  • Identity no-op + dim-mismatch error
  • Hadamard orthogonality H_4 · [1,0,0,0] == [1,1,1,1] (first column)
  • Hadamard H · H = n · I at N=8 (applying twice scales by n)
  • Hadamard norm² preservation up to n× at N=16
  • Hadamard rejects non-pow2 (N=6)
  • OPQ stub returns typed OpqMatrixNotLoaded
  • build() routes correctly for all three variants
  • Kernel signatures distinct across variants, stable for same shape, blob-id-sensitive for OPQ

Three forward-looking epiphanies (aad6e6a)

APPEND-ONLY on EPIPHANIES.mdnot current work items, forward-looking deposits for Phase 5+.

1. Thinking styles ARE codecs over the semantic field

The codec infrastructure IS the template for production-grade thinking tissue. Mapping:

Codec (shipped D0.1–D1.2) Thinking-style analog (future)
CodecParams ThinkingStyleParams
kernel_signature() style_signature()
CodecKernelCache<H> ThinkingStyleKernelCache<H>
token agreement conclusion agreement

Generalisation isn't porting — it's recognising thinking styles as a special case of the codec pattern.

2. Resolution ladder: 64×64 > 256×257 >> 4096×4096 > 16k (user-named)

The 5-layer stack is a resolution ladder, not a layer cake:

Size Role HHTL stage
64×64 p64 topology (p64_bridge::cognitive_shader::CognitiveShader) HEEL
256×257 bgz17 palette distance (O(1) semiring.distance) HIP
4096×4096 cross-vocab / cross-context (ndarray ScanParams JIT) BRANCH/TWIG
16 K Fingerprint<256> bit identity (codec decoder) LEAF

The >> between 256×257 and 4096×4096 is the big jump (~64×) — where palette-level meets vocabulary-level. Each JIT targets its own resolution; no overlap.

p64 double-check conclusion: p64_bridge::cognitive_shader::CognitiveShader at 64×64 is architecturally clean; my D1.x codec work at 16K is at a different layer of the ladder; they compose in cognitive_shader_driver::ShaderDriver.

3. Shader vs engine: statelessness is the boundary

Cognitive shader = stateless atomic compute (eye — reports current frame, no memory).
Thinking engine = stateful orchestrator (mind — assembles frames, carries persona/qualia/world_model).

engine_bridge.rs is the seam. Codec-flexibility-as-thinking lands at the engine level, not shader level — D5/Phase 5+ drops into thinking-engine mid-layer.

Board hygiene (same commit per Mandatory rule)

  • STATUS_BOARD.md: D1.2 Queued → In PR
  • EPIPHANIES.md: 3 PREPEND entries (taxonomy + ladder + shader/engine)

Test Plan

  • cargo test --manifest-path crates/cognitive-shader-driver/Cargo.toml --features serve --lib — 95/95 pass (+15 new)
  • cargo test -p lance-graph-contract --lib — 147/147 pass (unchanged)
  • cargo test --manifest-path crates/jc/Cargo.toml — 6/6 pass (JC substrate proof unchanged)
  • Rules A-F honored: A (in-place slice), B (rustc compiles to ndarray::simd-compatible AVX-512), C (Hadamard correctly stays at Tier 3, OPQ stub routes to Tier 1 when wired), D (Rotation variants come from YAML via WireRotation), E (trait methods expose signature + backend), F (no serialization)

https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh

claude added 2 commits April 20, 2026 23:22
First real kernel deliverable of Phase 1: RotationKernel trait + three
impls (Identity / Hadamard / OPQ-stub) with typed RotationError.
95/95 cognitive-shader-driver tests pass under --features serve
(+15 new D1.2 tests).

crates/cognitive-shader-driver/src/rotation_kernel.rs (~330 LOC):

  RotationKernel trait — object-safe, Send+Sync+Debug:
    apply(&self, &mut [f32]) -> Result<(), RotationError>
    dim() -> u32
    signature() -> u64              # feeds CodecParams::kernel_signature
    backend() -> &'static str       # "avx512" | "stub" (never "scalar")

  IdentityRotation { dim }
    — zero-overhead pass-through; apply() is a no-op

  HadamardRotation { dim }
    — REAL in-place Sylvester butterfly, O(N log N) add/sub,
      no allocations
    — validates dim is power-of-two (Sylvester requirement)
    — Rule C compliance: stays at Tier-3 F32x16 (add/sub, not matmul;
      AMX adds no value per plan appendix §12 C)
    — rustc + target-cpu=x86-64-v4 already emits AVX-512 add/sub
      from the straight-line loop → no JIT compilation needed

  OpqRotationStub { matrix_blob_id, dim }
    — real impl plugs into D1.1b CodecKernelEngine adapter +
      ndarray::hpc::jitson_cranelift::JitEngine + tile_dpbf16ps AMX
      matmul when amx_available()
    — apply() returns OpqMatrixNotLoaded (typed error) until the
      matrix-blob loader lands

  build(&Rotation, dim) -> Result<Box<dyn RotationKernel>> factory
    — dispatches on WireCodecParams.pre_rotation variant
    — returns typed errors on dim mismatch or non-pow2 Hadamard

Tests (15 new):
  Identity: noop + dim-mismatch error
  Hadamard:
    - orthogonality: H_4 · [1,0,0,0] == [1,1,1,1] (first column)
    - H · H = n · I (applying twice scales by n, verified at N=8)
    - norm² preservation up to n× scale (verified at N=16)
    - rejects non-pow2 dim (N=6)
  OPQ stub: returns OpqMatrixNotLoaded with blob_id preserved
  build(): identity / hadamard / hadamard-dim-mismatch / hadamard-
          non-pow2 / opq-stub
  Signatures: distinct across variants, stable for same shape,
             blob-id-sensitive for OPQ

Board hygiene (CLAUDE.md Mandatory rule):
  STATUS_BOARD.md:
    D1.2 Queued → In PR

  EPIPHANIES.md PREPEND (two entries):

    1. "Thinking styles ARE codecs over the semantic field"
       (north-star forward-looking deposit, not a work item)
       — codec infrastructure IS the template for production-grade
       thinking tissue. Mapping table documents the codec→thinking
       correspondence: CodecParams↔ThinkingStyleParams,
       kernel_signature↔style_signature, token_agreement↔
       conclusion_agreement, etc. Phase 5+ drops in
       WireThinkCalibrate + ThinkingStyleKernelCache using the
       same scaffolding. Generalisation isn't porting — it's
       recognising thinking styles as a SPECIAL CASE of the
       codec pattern.

    2. "D1.2 Hadamard is pure-Rust, not a JIT-necessary primitive"
       — narrows D1.1b scope by 30-40%. Only OPQ (matmul) needs
       Cranelift JIT emission; Identity (no-op) and Hadamard
       (butterfly) stay as plain-Rust Tier-3 F32x16 paths. Rustc's
       AVX-512 codegen under target-cpu=x86-64-v4 is already
       optimal for add/sub-structured kernels.

Rules honored:
  Rule A — in-place &mut [f32] slice, no allocations in apply()
  Rule B — ndarray::simd::* not needed for these shapes; compiler
           emits AVX-512 from straight-line loops
  Rule C — Hadamard stays at Tier 3 (add/sub, no AMX benefit);
           OPQ stub will route to Tier 1 AMX when matrix loaded
  Rule D — Rotation variants come from YAML via WireRotation (D0.1)
  Rule E — kernel signature() + backend() are object-methods per
           the Wire-surface-IS-SIMD-surface pattern
  Rule F — no serialization anywhere; in-memory f32 buffer only

https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
…sue taxonomy

Three related forward-looking deposits from this session's strategic
thread (codec IS thinking at scale → thinking-styles are codecs over
the semantic field → cognitive shader vs thinking engine boundary):

1. Thinking styles ARE codecs over the semantic field (north star).
   The codec infrastructure IS the template for production-grade
   thinking tissue. Codec → thinking-style mapping:
     CodecParams ↔ ThinkingStyleParams
     kernel_signature ↔ style_signature
     CodecKernelCache<H> ↔ ThinkingStyleKernelCache<H>
     token_agreement ↔ conclusion_agreement
   Generalisation isn't porting — it's recognising thinking styles
   as a SPECIAL CASE of the codec pattern.

2. Resolution ladder 64×64 > 256×257 >> 4096×4096 > 16k (user-named).
   The 5-layer stack is a resolution ladder, not a layer cake:
     64×64   — p64 topology mask (HEEL)
     256×257 — bgz17 palette distance (HIP)
     4096×4096 — cross-vocab / cross-context (BRANCH/TWIG)
     16 K    — Fingerprint<256> identity (LEAF)
   The `>>` between 256×257 and 4096×4096 is the big jump — where
   palette-level meets vocabulary-level. Each JIT targets its own
   resolution, no overlap. p64::CognitiveShader operates at
   coarsest (64×64); codec-sweep D1.x at finest (16k); they compose
   in cognitive-shader-driver::ShaderDriver. p64 double-check:
   architecturally clean, no reimplementation in my work.

3. Shader vs engine: statelessness is the boundary.
   Cognitive shader = stateless atomic compute (eye — reports
   current frame, no memory).
   Thinking engine = stateful orchestrator (mind — assembles frames
   into narrative, carries persona/qualia/world_model across cycles).
   engine_bridge.rs is the seam. Codec-flexibility-as-thinking lands
   at the ENGINE level, not shader level — D5/Phase 5+ drops into
   thinking-engine mid-layer.

All three epiphanies are forward-looking deposits (not current work
items). They clarify where future work lands when codec-sweep Phase 1
completes and Phase 5+ generalises.

Cross-references:
  - I10 HEEL/HIP/BRANCH/TWIG/LEAF (LATEST_STATE.md)
  - I5 thinking IS AdjacencyStore
  - p64_bridge::cognitive_shader::CognitiveShader (64×64 cascade)
  - thinking-engine crate structure (CLAUDE.md)

https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
@AdaWorldAPI AdaWorldAPI merged commit a3529ff into main Apr 20, 2026
0 of 6 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