Skip to content

ltm: cross-dimensional partial-reduce link scores ignore Pinned axes in the co-reduced slice (inflated divisor + garbage unread-row scores) #765

Closed

Description

@bpowers

Summary

try_cross_dimensional_link_scores (src/simlin-engine/src/db/ltm/link_scores.rs, fn at ~line 220 at b20f4637) derives the co-reduced slice for per-(row, slot) partial-reduce link scores from the FULL cartesian product of the source's dimensions, ignoring Pinned axes. For a pinned-mixed partial reduce inside a feedback loop, this produces:

  1. Wrong divisor / wrong link- and loop-score VALUES -- the divisor is inflated by the pinned axis's extent.
  2. Garbage scores for unread rows -- source elements on the non-pinned values of the pinned axis are never read by the reducer, yet get per-row link-score equations emitted (delta-ratio garbage of roughly +/-1), now unreferenced.

Repro fixture

D1 = {a, b}, D2 = {x, y}, D3 = {p, q}
cube[D1,D2,D3] = ...           ; fed by a stock over D1
outf[D1] = MEAN(cube[D1,x,*])  ; D1 iterated, D2 PINNED to literal x, D3 reduced

closed into a feedback loop through the D1 stock. The read slice per result row outf[a] is {cube[a,x,p], cube[a,x,q]} -- 2 cells. But the emitter builds source_elements as the full D1 x D2 x D3 cartesian product (all_elements construction, ~lines 298-304) and groups co-reduced slices by projecting that full product onto the result axes (~lines 372-378), so each slot's co-reduced slice has 4 members (cube[a,x,*] AND cube[a,y,*]). The MEAN partial divides by 4 where the true ceteris-paribus partial divides by 2: the emitted link and loop scores read 0.25 where the correct value is 0.5. Additionally cube[a,y,*] -> outf[a] link scores are emitted for rows the reducer never reads.

Root cause

The correct slice is exactly what read_slice_rows (src/simlin-engine/src/db/ltm/loops.rs) already computes per row: Pinned axes fixed to their literal element, Iterated axes fixed to the row, Reduced axes enumerated. The link-score emitter independently re-derives the slice from from_dims' full element lists and a result-axis projection, which is only correct when every non-result axis is Reduced. A Pinned axis is collapsed by the projection like a Reduced one instead of being fixed to its element, so all of its elements land in the same co-reduced bucket.

Why it matters

Medium severity. Wrong link/loop-score VALUES (not zeros, not warnings -- silently wrong numbers) for the pinned-mixed partial-reduce shape, e.g. MEAN(matrix[NYC,*]) / SUM(cube[D1,x,*])-style slices in feedback loops. The divisor inflation factor is the pinned axis's extent, so the error grows with model size. Plus spurious unread-row score series.

Status at b20f4637 (branch ltm-fix-batch-2)

Pre-existing on main: the pre-#752 conservative cross-product path had the same wrong divisor on its surviving diagonal loop (alongside fragment warnings). The #752 round-2 fix deliberately excludes Pinned-bearing slices from the new ltm_agg::variable_backed_partial_reduce_agg gate, so this subset stays on the loud (fragment-warned) conservative path rather than becoming silently wrong. This issue is the underlying value fix that would let the gate re-admit Pinned-mixed slices.

Components affected

  • src/simlin-engine/src/db/ltm/link_scores.rs -- try_cross_dimensional_link_scores: the full-cartesian source_elements construction (~298-304) and the co-reduced slice grouping (~372-378)
  • src/simlin-engine/src/ltm_agg.rs -- variable_backed_partial_reduce_agg gate's Pinned exclusion (removable once the values are right)

Possible approach

Derive the per-row source elements and co-reduced slices from the agg's read_slice (AxisRead per axis) instead of the full from_dims cartesian product -- i.e. reuse or mirror read_slice_rows from db/ltm/loops.rs: enumerate only Iterated x Reduced combinations with Pinned axes substituted by their literal element. This fixes the divisor (slice cardinality becomes the true read count), stops emitting unread-row scores, and lets the variable_backed_partial_reduce_agg gate re-admit Pinned-bearing slices.

Related

Discovery context

Demonstrated by an adversarial reviewer during GH #752 round-2 work on branch ltm-fix-batch-2 (commit b20f4637).

Activity

  1. added
    ltm
    on Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions