mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-15 21:28:33 -05:00
[PR #1869] [MERGED] fix(layers): Dropout uses global unseeded np.random instead of module rng #30969
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1869
Author: @Shashank-Tripathi-07
Created: 6/16/2026
Status: ✅ Merged
Merged: 6/16/2026
Merged by: @profvjreddi
Base:
main← Head:fix/dropout-seeded-rng📝 Commits (1)
180e933fix Dropout to use the module-level seeded rng instead of global np.random📊 Changes
1 file changed (+1 additions, -1 deletions)
View changed files
📝
tinytorch/src/03_layers/03_layers.py(+1 -1)📄 Description
What breaks
03_layers.pyseeds a module-level RNG for reproducibility:Dropout._create_mask()ignores this and callsnp.random.random(shape), which draws from the global unseeded state. Dropout masks are therefore different on every run even when the user expects deterministic behavior from the module seed. Any unit test that checks a specific Dropout output value will be flaky.Fix
One line change -- Dropout now participates in the same reproducible stream as every other random operation in the module.
Test plan
pytest tinytorch/tests/03_layers/passes🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.