Reseed the Cortex-M test RNG before each test module is imported - #21794
Open
rascani wants to merge 1 commit into
Open
Reseed the Cortex-M test RNG before each test module is imported#21794rascani wants to merge 1 commit into
rascani wants to merge 1 commit into
Conversation
Model tests that build calibration data or example inputs at module scope draw from the global RNG during pytest collection, not during the test. Seeding only in pytest_configure therefore left those draws dependent on how many other modules pytest happened to import first, so a test's quantization could change purely because a file was added elsewhere in the directory. Adding a test_silero_vad import ahead of test_mobilenet_v2 moves mv2's first calibration sample sum from -310.9496 to -42.2950; the reverse order moves silero's input sum from 15.9070 to 7.8727. Reseeding in pytest_collectstart makes both stable, and leaves the existing per-test autouse fixture untouched. The TEST_RUNTIME_IS_NOT_OSS guard mirrors the one already in pytest_configure, which in turn follows backends/arm/test/conftest.py. Authored with assistance from Claude Code.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21794
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit a7d3403 with merge base d92a619 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
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.
Summary
Model tests that build calibration data or example inputs at module scope draw from the global RNG during pytest collection, not during the test. Seeding only in pytest_configure therefore left those draws dependent on how many other modules pytest happened to import first, so a test's quantization could change purely because a file was added elsewhere in the directory.
Adding a test_silero_vad import ahead of test_mobilenet_v2 moves mv2's first calibration sample sum from -310.9496 to -42.2950; the reverse order moves silero's input sum from 15.9070 to 7.8727. Reseeding in pytest_collectstart makes both stable, and leaves the existing per-test autouse fixture untouched.
The TEST_RUNTIME_IS_NOT_OSS guard mirrors the one already in pytest_configure, which in turn follows backends/arm/test/conftest.py.
Authored with assistance from Claude Code.