Skip to content

Introduce immutable RNG state for correct comparisons and pickling

Frederik Hennig requested to merge fhennig/rng-state into v2.0-dev

This MR refactors the frontend RNG architecture of !474 (merged) to use immutable RNG state objects.

An immutable state object must be attached to each RNG invocation in order to correctly compare equivalent invocations and allow them to be pickled. The RNG objects themselves now serve as factories for their invocations and associated series of state objects.

  • Add RngState class for immutable RNG state objects
  • Turn RngBase and subclass Philox into factories for their state
  • Remove RngFunc and replace it by an introspection-based typechecking mechanism (inheritance from RngFunc is not preserved by pickle)
  • Adapt backend parsing
  • Add test cases for RNG comparion and pickling
  • Bump SymPy dependency to ~=1.14 (RNG functions need https://github.com/sympy/sympy/pull/26881)
  • Fix SymPy-related spurious mypy errors
Edited by Frederik Hennig

Merge request reports

Loading