Skip to content

Reseed the Cortex-M test RNG before each test module is imported - #21794

Open
rascani wants to merge 1 commit into
pytorch:mainfrom
rascani:cortex-m-test-seed-collection-order
Open

Reseed the Cortex-M test RNG before each test module is imported#21794
rascani wants to merge 1 commit into
pytorch:mainfrom
rascani:cortex-m-test-seed-collection-order

Conversation

@rascani

@rascani rascani commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@rascani
rascani requested a review from zingo August 12, 2026 23:11
@pytorch-bot

pytorch-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

🔗 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 Failures

As of commit a7d3403 with merge base d92a619 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 12, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant