Skip to content

ltm-augment: instantaneous and flow-to-stock link scores use inconsistent time windows within a loop #544

Closed

Description

@bpowers

Summary

Within a single feedback loop, LTM link scores are computed over different time windows depending on link type. Instantaneous (aux-to-aux / variable-to-variable) link scores are computed over [t-dt, t], while flow-to-stock link scores are computed over [t-2dt, t-dt] -- shifted one dt into the past. A loop that mixes instantaneous links with a flow-to-stock link therefore evaluates its links against inconsistent time baselines. This preserves the isolated-loop +/-1 raw-score invariant for linear flows, but for nonlinear flows it is a temporal smear, and the inconsistency is currently undocumented.

The discrepancy (verified in code)

src/simlin-engine/src/ltm_augment.rs:

Instantaneous link scores -- link_score_guard_form (around line 1379), used by generate_auxiliary_to_auxiliary_equation and the other instantaneous/ceteris-paribus generators:

numerator   = (partial_eq) - PREVIOUS(target_ref)
target_diff = target_ref - PREVIOUS(target_ref)
source_diff = source_ref - PREVIOUS(source_ref)

partial_eq holds the from reference live (sampled at t) and freezes every other dependency at PREVIOUS (t-dt). So an instantaneous link's score is a delta-ratio over the window [t-dt, t].

Flow-to-stock link scores -- generate_flow_to_stock_equation (around line 1782, numerator/denominator at lines 1824-1828):

numerator   = time_step * (PREVIOUS(flow) - PREVIOUS(PREVIOUS(flow)))
denominator = (stock - PREVIOUS(stock)) - (PREVIOUS(stock) - PREVIOUS(PREVIOUS(stock)))

The flow numerator samples the flow at t-dt (PREVIOUS(flow)) and t-2dt (PREVIOUS(PREVIOUS(flow))) -- i.e. the flow's contribution is measured over [t-2dt, t-dt], one dt earlier than every instantaneous link in the same loop.

The in-code comment at lines 1812-1814 explains the rationale for the flow-side shift (in Euler integration, the flow at t-dt is what drove the stock change observed at t, so PREVIOUS(flow) aligns the flow numerator with the second-order Δstock denominator). What it does not address is that this leaves the flow-to-stock link on a different time baseline than the instantaneous links it shares a loop with.

Why it matters

  • Correctness for nonlinear flows. The isolated-loop raw-score invariant (loop score magnitude 1 for a single isolated loop) was verified during the LTM review to still hold for linear flows despite the window mismatch -- the linearity makes the one-dt shift cancel out. For a nonlinear flow it does not cancel: the loop's link scores are multiplied together across mismatched time intervals, so the loop score is a temporal smear of two adjacent timesteps rather than a clean instantaneous measure. The error is bounded (it's a one-dt smear, not a divergence) but it is a real magnitude inaccuracy in exactly the models where loop dominance shifts fastest.
  • Undocumented invariant. Nothing in the code, the design doc, or the reference doc states that link scores in a loop can be on different time baselines. A future change to either generator could widen or "fix" the mismatch with no test or comment flagging the interaction. The linear-flow cancellation that currently rescues the invariant is itself undocumented.

Components affected

  • src/simlin-engine/src/ltm_augment.rs -- link_score_guard_form / generate_auxiliary_to_auxiliary_equation (and the sibling instantaneous/ceteris-paribus generators) vs. generate_flow_to_stock_equation.

Possible approaches

  1. Document the mismatch (minimum). Add a comment in generate_flow_to_stock_equation (next to the existing lines 1812-1814 rationale) and in link_score_guard_form noting that the two generators evaluate over [t-2dt, t-dt] vs [t-dt, t] respectively, that this is intra-loop-inconsistent, that the linear-flow case still satisfies the +/-1 invariant because the shift cancels, and that nonlinear flows are smeared by one dt. Mirror the note in docs/design/ltm--loops-that-matter.md.
  2. Align the windows (deeper fix). Either shift the instantaneous link scores back by one dt to match the flow-to-stock window, or rework the flow-to-stock numerator to [t-dt, t] (flow - PREVIOUS(flow)) and re-derive the denominator alignment. Both options need to preserve the dimensional time_step factor and the second-order Δstock denominator, and need a nonlinear-flow regression test that fails under the current mismatch and passes once aligned.

Relationship to existing issues

This is distinct from #505. #505 is about documenting that Simlin's flow-to-stock numerator is shifted by one dt relative to Stella / reference SD software (a cross-tool comparability concern, whole-score offset). This issue is about the intra-loop inconsistency: instantaneous links and flow-to-stock links in the same Simlin loop are on different baselines as each other. A fix for one does not necessarily address the other -- e.g. documenting the Stella offset (#505) says nothing about the aux-link window, and aligning the two Simlin windows internally could be done without changing the Stella relationship.

How discovered

Identified during an LTM subsystem review (one of a batch of ~6 LTM-review findings being filed). Verified against the current ltm_augment.rs source.

Tracking

Part of LTM epic #488.

Activity

  1. added
    ltm
    on May 14, 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