fix(tests/pytest_random_plugin.py): also seed Python's random#12
Open
yurekami wants to merge 1 commit intodeepseek-ai:mainfrom
Open
fix(tests/pytest_random_plugin.py): also seed Python's random#12yurekami wants to merge 1 commit intodeepseek-ai:mainfrom
random#12yurekami wants to merge 1 commit intodeepseek-ai:mainfrom
Conversation
The autouse `seed` fixture seeds torch but not Python's `random`. Tests that go through `tile_kernels/testing/generator.py:generate_rand_float` draw the magnitude exponent from `random.randint(-110, 126)`, so the input scale varies across runs even when --seed is fixed. Add `random.seed(seed)` so --seed is fully reproducible.
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.
Closes #11.
What
Add
random.seed(seed)next totorch.manual_seed(seed)in the autouseseedfixture so the--seedCLI option reproduces test inputs thatflow through Python's stdlib
random.Why
tile_kernels/testing/generator.py:94(generate_rand_float) picks themagnitude exponent with
random.randint(-110, 126). The plugin onlyseeds torch, so this exponent — and therefore the input scale used by
tests like
tests/quant/test_per_block_cast_lossless.py— variesacross runs even when
--seedis passed.Reproduction
The bug is in a pure-Python entropy source, so it reproduces without a
GPU. Mirroring the fixture and
generator.py:94:Three back-to-back invocations with the same simulated
--seed=0andthe same node id produce three different sequences. With the patch,
both invocations within one process produce identical sequences.
Scope
Python's
random.grep -r 'np\.random\|numpy.*random'isempty in this repo.