Skip to content

ltm: link-score generation is quadratic in an arrayed target's size #977

Open

Description

@bpowers

For an arrayed target with per-element equations, a link score has one slot per target element, and there is one link score per source element.
With N elements that is about N^2 slots for one causal edge, almost all of them for target elements that do not read that source element.
Generation time grows 4x per doubling of N.

Example

growth[Wide] with per-element equations pop[e] * rate * 0.01, pop[Wide] a stock fed by growth, rate a scalar:

N LTM generation link scores slots
100 141 ms 101 10,101
400 2,304 ms 401 160,401

On C-LEARN, 9,514 of 12,364 generated slots did not read their source.

What has been done

A slot is skipped (lowered to one store of 0) when its equation is provably the target's previous value: everything outside a PREVIOUS is a literal or operator.
Testing only "the source is held fixed" is not enough; it rewrote real C-LEARN scores to 0 when tried, because other inputs can still vary.
On C-LEARN this skipped 4,335 slots (17% of the flow program) with bit-identical results.
Another 5,023 were blocked only by a varying TIME; link-score equations now hold the clock fixed (#1016) and the check treats that as a one-step lag, so most of them should now be skipped too.
Not re-measured.

Fix

  1. Re-measure on C-LEARN and with per_element_generation_scaling, and record what is left.
  2. The remaining cost is not the slots: at N=400 with skipping, 439 ms of 520 ms is re-parsing and lowering the whole N-element target twice per link.
    Removing that is the fragments plan (docs/design-plans/2026-09-04-link-scores-from-fragments.md, not started); do not patch it separately.

Keep skipping only where the target has no EXCEPT default (there an absent slot takes the default, not 0).
#1060 and #1022 bear on which slots count as zero.

Pointers

  • src/simlin-engine/src/ltm_augment.rs: build_arrayed_link_score_equation
  • src/simlin-engine/src/ltm_augment_zero_slot.rs: the skip check
  • src/simlin-engine/src/db/ltm_tests.rs: per_element_generation_scaling (ignored; the timing instrument)
  • src/simlin-engine/src/db/ltm_value_gate_tests.rs: value checks for the skip

Activity

  1. added
    ltm
    on Jul 20, 2026
  2. changed the title [-]ltm: link-score generation is quadratic in an arrayed target's element count ((N+1)^2 equation arms per edge)[/-] [+]ltm: link-score generation materializes one full guard-form arm per element of an arrayed target (quadratic in element count)[/+] on Aug 10, 2026
  3. added
    enhancement
    on Oct 12, 2026
  4. changed the title [-]ltm: link-score generation materializes one full guard-form arm per element of an arrayed target (quadratic in element count)[/-] [+]ltm: link-score generation is quadratic in an arrayed target's size[/+] on Oct 12, 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

    enhancementltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions