Fix RNG seeding and reject generators nothing advances - #75
Merged
jessegrabowski merged 5 commits intoAug 10, 2026
Conversation
Two draws off one generator leave it with no single next state, so pytensor threads no update for it; one generator per draw is how pymc avoids the same problem.
Reseeding on every compile discarded any seed the caller had set and jumped the stream of any function already drawing from that generator; pymc reseeds by default and offers random_seed=False for the same reason we now default to leaving them alone.
A rule that perturbs its step reads a generator the outputs never touch, so collecting from the outputs alone left it frozen and every step took the identical perturbation.
Supersedes a UserWarning that announced a silently frozen training run; the check is on the assembled updates, so a caller who advances the generator themselves still passes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #75 +/- ##
==========================================
+ Coverage 93.65% 95.39% +1.74%
==========================================
Files 45 45
Lines 1766 1782 +16
==========================================
+ Hits 1654 1700 +46
+ Misses 112 82 -30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Each error message already says what happened and how to get out of it, and that is the copy a stuck user actually reads.
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.
Compiling reseeded every generator it touched, so a seed the caller set never survived, and compiling a second function jumped the stream of one already drawing. Generators are left alone now unless you pass
random_seed— deliberately the opposite of pymc's default, which is there for cached functions rather than training loops.A
Dropoutapplied twice in one network also shared a single generator between two draws, which pytensor treats as inconsistent and threads no update for, so the mask froze for the whole run. Each application gets its own generator now, and a graph that still draws from a generator nothing advances raises instead of warning.