Repository navigation
Description
Summary
compute_read_slice (src/simlin-engine/src/ltm_agg.rs, the StarRange bullet in its rustdoc at ~lines 852-857 at 3ba78eb4) maps IndexExpr2::StarRange(_, _) to AxisRead::Reduced unconditionally -- including when the named subdimension is a proper subset of the source axis's own dimension. For SUM(arr[*:SubDim]) where SubDim is a proper subdimension of arr's axis, the read slice claims the reducer reads the FULL parent extent of that axis, when in fact it reads only the subrange's elements.
The rustdoc bullet acknowledges the coarseness but says "tightening this is tracked as GH #765" -- which is incorrect (see "Distinct from #765/#764" below). This issue is the correct tracking entry; the breadcrumb at ltm_agg.rs:852-857 should be repointed here when this is picked up.
Consequences
Everything downstream of the read slice treats rows OUTSIDE the subrange as read by the reducer:
- Extra spurious element edges --
emit_agg_routed_edges(src/simlin-engine/src/db/analysis.rs) routes every element of the full parent extent into the agg node, a conservative SUPERSET of the true edges. Loop enumeration may discover loops through source elements the reducer never reads. - Wrong MEAN-style divisors -- per-row link scores via
read_slice_rows(src/simlin-engine/src/db/ltm/loops.rs) enumerate the co-reduced slice over the full extent, so a divisor-bearing reducer (MEAN, STDDEV) over a subrange divides by the parent dimension's size instead of the subdimension's size. Same value-imprecision flavor as ltm: cross-dimensional partial-reduce link scores ignore Pinned axes in the co-reduced slice (inflated divisor + garbage unread-row scores) #765's pinned-axis divisor bug, but with a different root cause (see below).
Distinct from #765 and #764
- ltm: cross-dimensional partial-reduce link scores ignore Pinned axes in the co-reduced slice (inflated divisor + garbage unread-row scores) #765: pinned axes are ignored by
try_cross_dimensional_link_scores's independent slice re-derivation, downstream of a CORRECT read_slice. Its proposed fix is "derive the per-row slices from the agg'sread_slice/ reuseread_slice_rows" -- which would NOT tighten this defect, because here theread_sliceitself is what's coarse (*:SubDim->Reducedloses the subrange). Fixing ltm: cross-dimensional partial-reduce link scores ignore Pinned axes in the co-reduced slice (inflated divisor + garbage unread-row scores) #765 leaves this bug fully intact. - ltm: variable-backed partial reducers with broadcast or permuted axes keep the conservative cross-product (loop scores stub to 0) #764: broadcast/permuted variable-backed shapes excluded from the
variable_backed_partial_reduce_agggate -- a different shape class (those stub to 0; this one over-approximates edges and mis-divides).
Root cause
AxisRead has no way to express "reduced over a subset of the axis": Reduced means the whole extent. compute_read_slice's StarRange arm deliberately matches classify_subscript_shape's AC1.4 treatment of an all-StarRange subscript as Wildcard, so the coarseness is consistent across the classifier and the agg machinery -- consistently coarse.
Possible approach
A subrange-aware AxisRead variant (or Reduced carrying an Option<Vec<element>> subset, resolved from the subdimension's elements via DimensionsContext/SubdimensionRelation):
compute_read_slice's StarRange arm resolves the named dimension; if it is a proper subdimension of the source's axis dimension, emit the subset variant.emit_agg_routed_edgesenumerates only the subset's elements for that axis.read_slice_rowsenumerates the co-reduced slice over the subset (fixing MEAN/STDDEV divisors).classify_subscript_shape's AC1.4Wildcardtreatment may need a matching refinement (or a documented residual) so the classifier and the hoisting test stay in agreement.- Repoint the rustdoc breadcrumb at
ltm_agg.rs:852-857from ltm: cross-dimensional partial-reduce link scores ignore Pinned axes in the co-reduced slice (inflated divisor + garbage unread-row scores) #765 to this issue.
Why it matters
Low severity. The element edges are a conservative superset (never a missed edge), and the value imprecision requires a divisor-bearing reducer (MEAN/STDDEV) over a proper subdimension inside a feedback loop -- an uncommon shape. Pre-existing since the #514-era read-slice work.
Components affected
src/simlin-engine/src/ltm_agg.rs--compute_read_sliceStarRange arm,AxisReadsrc/simlin-engine/src/db/analysis.rs--emit_agg_routed_edgessrc/simlin-engine/src/db/ltm/loops.rs--read_slice_rowssrc/simlin-engine/src/db/ltm_ir.rs--classify_subscript_shapeAC1.4 (consistency)
Related
- ltm: cross-dimensional partial-reduce link scores ignore Pinned axes in the co-reduced slice (inflated divisor + garbage unread-row scores) #765 -- pinned-axis co-reduced-slice divisor bug (different root cause: downstream of a correct slice; its fix does not cover this)
- ltm: variable-backed partial reducers with broadcast or permuted axes keep the conservative cross-product (loop scores stub to 0) #764 -- broadcast/permuted variable-backed residual shapes (different shape class)
- ltm: sliced reducer sub-expressions are not hoisted into aggregate nodes (stay on the wildcard-link-score path) #514 -- the read-slice hoisting work this coarseness dates from (closed)
- LTM needs to support arrays #273 -- LTM array support umbrella; epic: Loops that Matter (LTM) -- open work #488 -- LTM tracking epic
Discovery context
Flagged by a reviewer during GH #752 review rounds on branch ltm-fix-batch-2 (commit 3ba78eb4): the existing rustdoc breadcrumb describes this defect but mis-attributes its tracking to #765.
Activity