You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
layout: same model and seed can produce different layouts #633
Generating a layout twice for the same model with the same random seed can give two different diagrams, in one process or across runs.
The seed exists so that layout is reproducible, and auto-layout picks the best of several seeds, so production output also varied run to run.
Example
Two runs of the layout eval sweep with LAYOUT_EVAL_MODELS=teacup,sir LAYOUT_EVAL_SEEDS=8 gave a SIR median cost of 0.7348 and 0.7071.
Teacup, which is tiny, happened to be stable.
Why it matters
Layout output is not reproducible, and a quality regression gate on layout cost cannot have a stable threshold.
Fix
The suspected cause is iterating Rust HashMap/HashSet, whose order is randomized per instance, in places where order changes the result: summing floating-point positions, and assigning starting angles to auxiliaries by iteration rank.
Iterate in sorted order (or use ordered containers) at those sites, and add a test that the same model and seed give an identical view on repeated calls, for both full and incremental layout.
Pointers
src/simlin-engine/src/layout/mod.rs (generate_layout_with_config, the initial-placement loop over var_to_node)
changed the title [-]layout: generate_layout_with_config is nondeterministic per seed (HashMap/HashSet iteration order in force accumulation)[/-][+]layout: same model and seed can produce different layouts[/+]on Oct 12, 2026
The initial-placement and centroid loops iterate a sorted view of var_to_node (src/simlin-engine/src/layout/mod.rs:1672-1679), with the same treatment in objective.rs:97, incremental.rs:738-742 and isolated-node parking (mod.rs:1451). Pinned by test_layout_deterministic_per_seed and test_incremental_layout_deterministic (src/simlin-engine/tests/integration/layout.rs:2277, 2303), plus branching and ghost determinism tests. The remaining HashMap iterations I read in layout/ (chain.rs:432, mod.rs:1056, incremental.rs:228, 621) are order-insensitive.
Activity
engine: make layout deterministic per seed (fix #633)
engine: layout_eval skip-on-failure + full-sweep smoke check
engine: add human-vs-auto reference-pair ordering test (AC5.2)
doc: update simlin-engine context for layout-quality metric
[-]layout: generate_layout_with_config is nondeterministic per seed (HashMap/HashSet iteration order in force accumulation)[/-][+]layout: same model and seed can produce different layouts[/+]bpowers commentedon Oct 12, 2026
Closing: already fixed on main.
The initial-placement and centroid loops iterate a sorted view of
var_to_node(src/simlin-engine/src/layout/mod.rs:1672-1679), with the same treatment in objective.rs:97, incremental.rs:738-742 and isolated-node parking (mod.rs:1451). Pinned bytest_layout_deterministic_per_seedandtest_incremental_layout_deterministic(src/simlin-engine/tests/integration/layout.rs:2277, 2303), plus branching and ghost determinism tests. The remaining HashMap iterations I read in layout/ (chain.rs:432, mod.rs:1056, incremental.rs:228, 621) are order-insensitive.