Skip to content

Type manifold frames: vector writes, covector reads (DiM push, LEACE ablation) - #77

Merged
a9lim merged 4 commits into
mainfrom
fix/vector-typed-basis
Nov 10, 2026
Merged

a9lim merged 4 commits into
mainfrom
fix/vector-typed-basis

Conversation

@a9lim

@a9lim a9lim commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What

Manifold frames were mistyped. The whitened fit computed the Fisher directions Σ⁻¹Xᵀa (LDA read covectors), QR'd them into a Euclidean-orthonormal basis, and both read and wrote along it. So:

  • a 2-node push wrote along Σ⁻¹δ instead of the difference of means δ (cosine 0.26–0.83 on the cached SmolLM2, Qwen3.5-4B and Gemma-3-4B fits);
  • ! projected Euclidean-orthogonally off Σ⁻¹δ, leaving 18–46% of the concept's Mahalanobis norm in the class-mean gap (LEACE leaves 0);
  • the monitor read with Σ⁻²δ (correlation ≈ 0.8 with the LDA read).

Commit 1: typed frames

LayerSubspace carries basis (write vectors, Mahalanobis-orthonormal) and read (their Σ⁻¹ images, exactly dual). The whitened fit is PCA in whitened space mapped back with the right types: rows Xᵀa/√μ, reads aᵀ(Σ⁻¹X)/√μ. A 2-node fit writes δ and reads Σ⁻¹δ (PCA@2 ≡ DiM holds again), and a full ! is LEACE against neutral. Reduced coordinates are whitened coordinates, so the foot solve, σ tube and share are Mahalanobis. The kernel, AffineOp, synthesis, curved-overlap lowering, fold, DLS, node stats, the monitor's curved reads, topology scoring and transfer all follow the typing.

Commit 2: lens atoms are reads

jlens//slens/ atoms are covectors. They register their raised vector Σu, so !jlens/x zeroes the token's own reading. The token dictionaries of decompose whiten by Σ^{+1/2}. Opening a scope now makes the neutral baseline resident before resolving.

Breaking

  • MANIFOLD_FIT_POLICY_VERSION 1 → 2: every fitted tensor refits. Tensors gain layer_<L>.read.
  • Browser seam (drowse.ai follow-up): affine-fisher-fit and affine-ablation-lowering move to -v2 (new read field). The slens and unit-reads units goldens regenerate. drowse.ai's Fisher fit, affine lowering, ablation, S atoms and archive reader need porting before its pin moves.
  • Transfer no longer refuses non-isometric curved maps: the scalar tube becomes the volume-preserving isotropic approximation.

Calibration

The δ write disrupts more per whitened unit, and curved surfaces now pass through the true centroids, so both gains were re-fit. Each new gain was chosen to match the old code's neutral-text NLL cost at the old operating points, keeping the documented α bands. Measured teacher-forced, main (old fits) vs this branch:

  • _SUBSPACE_GAIN 16 → 8. Six bipolar concepts on SmolLM2-360M, gemma-3-4b, Llama-3.1-8B and gemma-4-12b at old α ∈ {0.25, 0.5, 1}. The equal-cost α was 0.47–0.48× the old one, stable across α (per model 0.44–0.55). At matched cost the δ write moves pole preference more for most concepts.
  • _MANIFOLD_ALONG_GAIN 4 → 2. Spectral emotions%{happy,angry,calm} on SmolLM2-360M and gemma-4-12b. The equal-cost along was 0.35–0.80×, geometric mean about 0.55.
  • jlens atoms (no per-term gain). On gemma-3-4b the old α ≈ 0.3 sweet spot maps to α ≈ 0.1; the lens doc now says so.

Checks

CPU suite 6031 passed; ruff clean; pyright 0 errors; GPU suite (SmolLM2, MPS) passes; perf gates passed before the gain change (gains don't touch the hot path).

…vectors

The whitened fit took the Fisher directions Σ⁻¹Xᵀa, QR'd them into a
Euclidean-orthonormal basis and both read and wrote along it.  Σ⁻¹δ is the
LDA read covector, not a write: a 2-node push went along Σ⁻¹δ instead of the
difference of means (cos 0.26–0.83 on cached SmolLM2, Qwen3.5-4B and
Gemma-3-4B fits), the `!` ablation left 18–46% of the concept's Mahalanobis
norm in the class-mean gap, and the monitor read with Σ⁻²δ.

A LayerSubspace now carries `basis` (write rows, Mahalanobis-orthonormal) and
`read` (their Σ⁻¹ images, exactly dual).  The whitened fit is PCA in the
whitened space mapped back with the right types: rows Xᵀa/√μ, reads
aᵀ(Σ⁻¹X)/√μ.  A 2-node fit writes δ and reads Σ⁻¹δ (PCA@2 ≡ DiM holds again),
a full `!` is LEACE against neutral, and reduced coordinates are whitened
coordinates, so the foot solve, σ tube and share are Mahalanobis.  The kernel,
AffineOp, synthesis (Gram-Schmidt on write/read pairs), the curved-overlap
lowering, fold, DLS, node statistics, the monitor's curved reads and topology
scoring read through `read` and write through `basis`.  Transfer
re-orthonormalizes in the target metric (Cholesky), and a non-isometric map
rescales a curved fit's scalar tube to the volume-preserving isotropic value
instead of refusing.

Fitted tensors gain `layer_<L>.read`; MANIFOLD_FIT_POLICY_VERSION 1 → 2, so
every fit refits.  Browser seam: affine-fisher-fit and affine-ablation-lowering
move to -v2 (new `read` field) with a regenerator in the parity module.
…m in the dual metric

A `jlens/` atom (W_U[v] J_l) and an `slens/` atom (K_l ẽ_v) score a residual
by a dot product: they are covectors.  Registered as plain profiles under
typed frames, `!jlens/<word>` would pin the Σ⁻¹u reading rather than the
token's own.  The resolvers now register the raised vector Σu
(LayerWhitener.apply), the write that moves the reading furthest per unit of
Mahalanobis displacement; folded, it reads with u again, so a push raises the
token's reading and `!` zeroes exactly that reading (LEACE).  On real models
Σu is mostly u restricted to the neutral span (cos about 0.15 with u; no
concentration in the rogue channels), so jlens/slens push calibration moves.

The token dictionaries of `decompose` take the same typing: atoms whiten by
Σ^{+1/2} (LayerWhitener.whiten_dual) while targets and neuron writes whiten
by Σ^{-1/2}, so a token's score is its reading of the residual over that
reading's neutral spread, and a raised atom decomposes to its own token.  Read
atoms are nearly collinear in that metric, so the pursuit's k×k solve runs in
fp64 and selection stops once the residual is negligible.

Raising needs the whitener while resolving, so opening a steering scope now
makes the neutral baseline resident first (through the composer's unguarded
ensure); a cold session's generate(steering="... jlens/x") used to refuse.

Browser seam: the slens and unit-reads units goldens regenerate (the S atom
profile and `unit find` of a jlens atom).
…ed along 4 → 2

Typed frames write along δ, which moves a concept's reading furthest per
whitened unit and disrupts more per unit, and curved surfaces now pass
through the true centroids rather than their projections onto the covector
span.  Both gains were re-fit to keep the documented α bands by matching the
old code's neutral-text NLL cost (teacher-forced):

- affine: six bipolar concepts on SmolLM2-360M, gemma-3-4b, Llama-3.1-8B and
  gemma-4-12b at old α ∈ {0.25, 0.5, 1}; equal-cost α was 0.47–0.48× the old
  one, stable across α (per model 0.44–0.55), so 16 → 8.  At matched cost the
  δ write moves pole preference more for most concepts.
- curved: spectral emotions%{happy,angry,calm} on SmolLM2-360M and
  gemma-4-12b; equal-cost along 0.35–0.80× (geo-mean ~0.55), so 4 → 2.
- jlens atoms (no per-term gain): on gemma-3-4b the old α ≈ 0.3 sweet spot
  maps to α ≈ 0.1; the note says so.

The lowering goldens regenerate (only their gain-dependent fields), with
regenerators for the rank-one and composed lowerings added to the parity
module; the units goldens and the term-layers golden's curved groups follow.
@a9lim
a9lim marked this pull request as ready for review November 10, 2026 20:09
@a9lim
a9lim merged commit 2969520 into main Nov 10, 2026
8 checks passed
@a9lim a9lim mentioned this pull request Nov 10, 2026
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.

1 participant