Skip to content

ltm: multi-output-port module pathway/composite ordering is process-nondeterministic (unordered output-port set) #680

Closed

Description

@bpowers

Summary

find_model_output_ports (src/simlin-engine/src/db/ltm/loops.rs ~line 107) returns its output-port set via output_ports.into_iter().collect() -- an unordered HashSet drain. enumerate_pathways_to_outputs iterates these ports and extends per-input-port pathway lists in that order; the composite fold keeps the earlier pathway on a magnitude tie (generate_max_abs_selection), and the $⁚ltm⁚path⁚{port}⁚{index} synthetic-var indices follow this same order.

For a module that has multiple output ports and tied pathway scores, both the selected winner and the path-var indices are therefore process-dependent (Rust's HashSet randomizes iteration order per process via DefaultHasher).

Why it matters

salsa cache values should be byte-stable across processes. Any downstream consumer that keys on the selected pathway or on $⁚ltm⁚path⁚{port}⁚{index} synthetic-var names (model snapshots, persisted UI state, deterministic tests, cached salsa outputs) sees flapping results for multi-output-port modules with tied pathway scores. This is harmless for single-output stdlib modules (the common case), which is why it has gone unnoticed, but it is a latent determinism gap.

This is a distinct code site from #497 (closed), which fixed sibling-cycle ID nondeterminism in assign_loop_ids (ltm.rs). #497 does not touch find_model_output_ports / the multi-output-port pathway-enumeration path in db/ltm/loops.rs.

Component(s) affected

  • src/simlin-engine/src/db/ltm/loops.rs (find_model_output_ports, enumerate_pathways_to_outputs)

Possible approaches

  • Sort the port list before returning (e.g. by canonical port name) so iteration order, tie-break selection, and path-var indices are deterministic.
  • Add a test with a synthetic multi-output-port module and tied pathway scores asserting a stable winner and stable path-var indices across runs.

Severity

Minor -- only affects modules with multiple output ports and tied pathway scores; single-output stdlib modules are unaffected.

Context

Identified during a 2026-06-02 LTM design review. Tracking epic: #488. Related (different site): #497.

Activity

  1. added
    ltm
    on Jun 2, 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