Repository navigation
BUG Preserve Scenario RNG state during serialization - #4284
Merged
Merged
Conversation
Anjikya08
force-pushed
the
fix-scenario-rng-serialization
branch
from
November 29, 2026 18:00
cb28d59 to
965f3f3
Compare
quaquel
reviewed
Nov 29, 2026
quaquel
reviewed
Nov 29, 2026
|
Thanks for explaining the restoration logic, @Anjikya08. @quaquel, the author has answered your questions and offered to remove the legacy-state fallback. Should this preserve only current RNG state and shared identity, or also support older serialized tuples? I recommend dropping the legacy fallback given the experimental status and 4.0 branch, while retaining the current round-trip fix for #4283. Automated note by an AI model; it can be wrong, and maintainers make the decisions. About this bot. |
quaquel
approved these changes
Nov 30, 2026
EwoutH
added a commit
to EwoutH/mesa
that referenced
this pull request
Nov 30, 2026
EwoutH
added a commit
that referenced
this pull request
Nov 30, 2026
* Update release notes and version for 4.0.0a1 Add the 4.0.0a1 release notes to HISTORY.md, leaving out changes already released in Mesa 3.5.1 to 3.5.4, and bump the version to 4.0.0a1. Move the #4182 replication id fix, which was added under 4.0.0a0, into the 4.0.0a1 notes where it was released. Assisted-by: Claude Opus 5.5 * Leave dependabot and pre-commit.ci bumps out of the 4.0.0a1 notes Assisted-by: Claude Opus 5.5 * Add PRs merged on 2026-11-30 to the 4.0.0a1 notes Seven PRs were merged after the notes were drafted: #4284, #3960, #4261, #3979, #4286, #4216 and #4301. Also moves the release date to 2026-11-30. Assisted-by: Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-PR Checklist
Summary
Fixes loss of Scenario RNG state and shared RNG identity during serialization and restoration.
When a Model and its Scenario share the same NumPy Generator, pickle restoration should preserve that shared identity. Otherwise, they can end up using separate random-number generators, potentially causing divergent random-number streams.
Bug / Issue
Closes #4283
A normally initialized Model satisfies
model.rng is model.scenario.rng. Serialization and restoration could fail to preserve this relationship.Expected behavior:
Implementation
Testing
Added regression tests covering:
Test command:
Result: 38 passed.
Ruff check and format checks passed.
git diff --checkpassed.Additional Notes
scenario.pyandtest_scenario.py.