Skip to content

Generator is non-deterministic (hash-seed-dependent); ~5.8% edges differ run-to-run #42

Description

@adamjohnwright

Problem

The generator is non-deterministic: regenerating the same pathway with identical code produces structurally different networks run-to-run.

Evidence (TP53, R-HSA-3700989, 31,884 edges):

  • Two runs, default env: 1,852 edges differ (~5.8%) in stId-space (input/output/depletion edges).
  • Two runs with PYTHONHASHSEED=0: identical (0 differing).

Root cause: Python hash randomization → set/dict iteration order of strings varies between runs → somewhere the generator's output depends on that order (matching picking among equivalent options, or set/variant selection, or entity iteration order).

Impact

  • Benchmark comparisons carry ±1–2 cases of regeneration noise, confounding A/B evaluation of generator changes (e.g. a spurious "−1 TP53" appeared when comparing two networks that only differed by noise).
  • Results aren't reproducible.

Fix

  • Immediate: set PYTHONHASHSEED=0 for all generation + benchmark runs.
  • Proper: make output order-independent — sort sets before iterating anywhere the choice affects output (matching, variant enumeration, entity iteration). Then determinism holds regardless of hash seed.

To do

  • Locate the order-dependent site(s) (start with find_best_reaction_match / matching, and any for x in <set> that picks a representative).
  • Add a determinism test: generate a pathway twice, assert stId-space edge multisets equal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions