GiNaC term order of printed closed forms is not reproducible across processes

Open
#554 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in LKlinke/prodigy-ginac-bindings at the closed-form printing path and use the distribution_header and Tracer.snapshot workarounds referenced from #553 to identify order-dependent behavior. Add or adapt a test that prints the same expression in two fresh processes with different PYTHONHASHSEED values and compares the text. The change is complete when output is independent of hash seed and prior computations, and the call-order workarounds are removed or reworded.

Written by the indexing model from the issue text.

Description

area: engines priority: low topic: engine consistency

Found in #553 (exists on main).

GiNaC's term order in printed closed forms depends on the hash seed and on what the process computed before, since GiNaC's symbols are shared within a process. Two fresh runs of main print 17_die_even_invariant with different term orders. The values are the same; only the text of closed forms differs.

Consequences:

  • A byte comparison of GiNaC output (golden and JSON comparisons in refactoring PRs) needs PYTHONHASHSEED=0 and a fresh process per program.
  • Users can see the same result printed differently between runs.
  • A refactoring that only reorders engine calls changes the printed output (#553 had to restore the call order in distribution_header and Tracer.snapshot).

The fix belongs in LKlinke/prodigy-ginac-bindings (a canonical print order), not in Prodigy.

Done when

  • The printed form of a GiNaC closed form is the same across processes and hash seeds, and independent of earlier computations in the process.
  • A test in the bindings (or in Prodigy's engine tests) prints the same expression in two fresh processes with different hash seeds and compares the text.
  • Prodigy's workarounds that depend on the call order (the comments in distribution_header and Tracer.snapshot from #553) are removed or reworded.
Dominant language
Python
Stars
6
Forks
2
Avg merge
1h 52m
Merged PRs (30d)
187

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from LKlinke/Prodigy

All issues in LKlinke/Prodigy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.