Repository navigation
Description
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:
- Wrong divisor / wrong link- and loop-score VALUES -- the divisor is inflated by the pinned axis's extent.
- 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-cartesiansource_elementsconstruction (~298-304) and the co-reduced slice grouping (~372-378)src/simlin-engine/src/ltm_agg.rs--variable_backed_partial_reduce_agggate'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
- ltm: loop scores through a variable-backed partial-reduce reducer reference never-emitted link-score names, stubbing to 0 #752 -- the variable-backed partial-reduce routing fix whose round-2 work surfaced this (fix at
b20f4637onltm-fix-batch-2); this issue is the value-level sibling - ltm: variable-backed partial reducers with broadcast or permuted axes keep the conservative cross-product (loop scores stub to 0) #764 -- the broadcast/permuted residual shapes excluded from the same gate (different shape class: those stub to 0; this one reads wrong nonzero values)
- ltm: source->agg link score wrong-signed for hoisted multi-source reducer with sign-flipping coefficient (SUM linear shortcut ignores the body's coefficient) #744 -- body-aware partial coefficient bug (different defect: reducer-body coefficient, not slice derivation)
- LTM needs to support arrays #273 -- LTM array support umbrella; epic: Loops that Matter (LTM) -- open work #488 -- LTM tracking epic
Discovery context
Demonstrated by an adversarial reviewer during GH #752 round-2 work on branch ltm-fix-batch-2 (commit b20f4637).
Activity
ltm: scoring-correctness and visibility batch from epic #488 (#775)