Repository navigation
Fix flaky image processor backend equivalence tests: configurable mean tolerance - #51110
Merged
Merged
Conversation
…n tolerance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: cohere_compass, got_ocr2, ovis2 |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
What
The image processor backend-equivalence tests fail occasionally in PR CI:
CohereCompassImageProcessingTest::test_backends_equivalence_batchedGotOcr2ProcessingTest::test_backends_equivalence_crop_to_patchesOvis2ProcessingTest::test_backends_equivalence_crop_to_patchesThey fail with e.g.
AssertionError: 0.00508 not less than or equal to 0.005. Seen 3 times in PR CI between 2026-11-19 and 2026-11-20; all 3 jobs ranpillow==13.0.0.Why: Pillow 13
This comes from the same Pillow 13 change as
#50105/#50170/#50327/#50510: Pillow 13 can reverse the order of the two bicubic resize passes (python-pillow/Pillow#9549). Those PRs raisedbackend_equivalence_atol, the max per-pixel tolerance (0.1 -> 0.5). But the change also raises the mean difference, and that check (mean(|pil - torchvision|) <= 5e-3in_assert_tensors_equivalence, hard-coded) was not adjusted.Mean |pil - torchvision| per class, current
main, torchvision 0.29.2, same random inputs as the tests:The 3 tests on
main(300 runs each, pytest-flakefinder): Pillow 13: 2 / 900 failed; Pillow 12: 0 / 900.Fix
backend_equivalence_mean_atolclass attribute (default5e-3, so nothing changes for other models)._assert_tensors_equivalenceuses it unlessmean_atolis passed explicitly.1e-2for these 3 test classes. Under Pillow 13 the tail stops around 5.3-5.4e-3 (no value above 6e-3 in 4000 GotOcr2 + Ovis2 samples). So1e-2is about 2x the worst case, while still about 80x above the Pillow 12 level, so a real processor bug would still show up.Verification (Pillow 13.0.0, CPU, pytest-flakefinder,
-n 16)main)The 4 image-processing test files (got_ocr2, ovis2, cohere_compass, llava): 107 passed, 18 skipped.
🤖 Generated with Claude Code