-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Prevent tests from leaking their respective RNG #4497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7c20323
910d213
97d7c4a
7566dc4
92cc80a
e6159d9
3d58993
eb19521
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -714,6 +714,7 @@ def test_random_apply(device): | |
@pytest.mark.parametrize('channels', [1, 3]) | ||
def test_gaussian_blur(device, channels, meth_kwargs): | ||
tol = 1.0 + 1e-10 | ||
torch.manual_seed(12) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to add this to prevent the test from failing (see https://app.circleci.com/pipelines/github/pytorch/vision/10830/workflows/946973f0-bad1-48ed-aaf3-f3720ab5f56a/jobs/828462). If anything, this shows that the PR is working as expected and that this test is a bit flaky, and sensible to the To confirm I parametrized it over 100 random seeds, and I got 8 failures over 1000+ test instances. Each time, just 1 pixel was off. Considering the low failure rate, I think it's fine to keep the manual seeding here. |
||
_test_class_op( | ||
T.GaussianBlur, meth_kwargs=meth_kwargs, channels=channels, | ||
test_exact_match=False, device=device, agg_method="max", tol=tol | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty much the same as
freeze_rng_state()
https://github.com/pytorch/vision/blob/main/test/common_utils.py#L86autouse=True
means that this fixture will be used by every single test automatically.