Skip to content

Decode byte-encoded RNG names in HDF checkpoints - #582

Open
sjdoane wants to merge 1 commit into
dfm:mainfrom
sjdoane:codex/hdf-rng-byte-identifier
Open

sjdoane wants to merge 1 commit into
dfm:mainfrom
sjdoane:codex/hdf-rng-byte-identifier

Conversation

@sjdoane

@sjdoane sjdoane commented Oct 26, 2026 •

Copy link
Copy Markdown

An HDF checkpoint can store the RNG algorithm name as fixed-width bytes (b'MT19937'). HDFBackend.random_state returns those bytes unchanged, and NumPy rejects the state when EnsembleSampler reopens the checkpoint. This addresses the fixed-byte-name failure described in #331.

Decode the first RNG-state element when it is bytes. Text identifiers and the remaining state, including the Gaussian cache, stay unchanged. Reading does not modify the checkpoint or introduce a new storage schema.

Validation:

  • Added cases against original source: 4 failures / 2 text controls pass. Entire existing/new unit collection: 4 failures / 102 passes before; 106 passes after.
  • The 106 unit tests pass on Python 3.9 / NumPy 2.0 / h5py 3.14 and Python 3.12 / NumPy 2.5 / h5py 3.16, macOS arm64. All configured pre-commit hooks pass.
  • A separate checkout independently repeats the baseline and patched unit tests. Actual HDF byte/text attributes, custom groups, read-only file nonmutation, restored RNG output and exact short checkpoint continuation are checked.

The fixtures use current h5py to reproduce fixed-width byte storage; an original Python 2-created file and general Python 2 compatibility were not tested. Full integration tests, other platforms and hosted CI remain unverified.

Implementation and independent local review were performed by separate Codex agents.

This branch has not been deployed

No deployments
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.

1 participant