Skip to content

Make CEPTR code generation fully deterministic - #679

Draft
terencelehmann wants to merge 1 commit into
Pele-Suite:developmentfrom
ITV-RWTH:tl_ceptr_determinism
Draft

Make CEPTR code generation fully deterministic#679
terencelehmann wants to merge 1 commit into
Pele-Suite:developmentfrom
ITV-RWTH:tl_ceptr_determinism

Conversation

@terencelehmann

Copy link
Copy Markdown
Contributor

Summary

CEPTR code generation can produce trivially different (but equivalent) output
across runs when PYTHONHASHSEED varies, causing the CI diff-check to flag
spurious changes, as mentioned in #659 . This PR aims to fix the sources of non-determinism in the generator:

  • intersection() in utilities.py: replace list(set(...)) with sorted(...)
  • identify_qssa_coupling() in qssa_reduction.py: same fix for the deduplication step
  • free_symbols iterations in species_info.py and symbolic_math.py: sort by str before iterating
  • CI CEPTR job: set PYTHONHASHSEED: 0 to fix SymEngine CSE variable numbering,
    which otherwise varies with Python's hash randomization

All four existing tests pass.


Co-authored by: Claude Sonnet 4.6 noreply@anthropic.com

Sort set-to-list conversions in intersection(), identify_qssa_coupling(),
and free_symbols iterations (species_info.py, symbolic_math.py) so that
output is stable across Python hash seeds and dependency versions.
Set PYTHONHASHSEED=0 in the CEPTR CI job to fix SymEngine CSE variable
numbering, which otherwise varies with hash randomization.
@drummerdoc

Copy link
Copy Markdown
Collaborator

Thanks for working on this, Terance. If you get a chance, and can figure a way to do it, is it possible to add a CI test that confirms that the results will be deterministic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants