Skip to content

Fix image backend equivalence tests for Pillow 13 - #50105

Merged
tarekziade merged 1 commit into
mainfrom
tarek-pillow13-backend-equivalence
Oct 29, 2026
Merged

tarekziade merged 1 commit into
mainfrom
tarek-pillow13-backend-equivalence

Conversation

@tarekziade

@tarekziade tarekziade commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

🤗 Transformers CI

What does this PR do?

Per python-pillow/Pillow#9549 - Pillow 13.x changed the order of the two bicubic resize passes.

Previously, it resized horizontally, then vertically. It now sometimes resizes vertically first when the height shrinks substantially more than the width, to improve performance

That produces slightly different pixels and affects our tests when we're comparing PIL's output with Torchvision

This patch bumps backend_equivalence_atol to 0.5 to match Pillow 13.x behavior.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: chinese_clip, cohere_compass, ernie4_5_vl_moe, flava, ovis2, paddleocr_vl, qwen2_vl, video_llama_3

@tarekziade

Copy link
Copy Markdown
Collaborator Author

run-slow: chinese_clip, cohere_compass, ernie4_5_vl_moe, flava, ovis2, paddleocr_vl, qwen2_vl, video_llama_3

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine by me to merge so we don't block pr ci. Arw these all affected models, I was expecting more 😅

@github-actions

Copy link
Copy Markdown
Contributor

CI (Nvidia + AMD)

Nvidia · ✅ No new failures 🎉👏 · ⚙️ Workflow · 📊 Dashboard

AMD · ✅ No new failures 🎉👏 · ⚙️ Workflow · 📊 Dashboard

@tarekziade
tarekziade added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 31d360b Oct 29, 2026
124 checks passed
@tarekziade
tarekziade deleted the tarek-pillow13-backend-equivalence branch October 29, 2026 09:45
ydshieh added a commit that referenced this pull request Oct 30, 2026
…ibility (#50170)

Pillow >= 13 changed the order of bicubic resize passes (vertical-first when
height shrinks more than width), producing slightly different pixel values when
compared against torchvision. Matches the fix applied to other models in #50105.

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
ydshieh added a commit that referenced this pull request Nov 3, 2026
…s from #50105) (#50327)

fix(cosmos3_edge): bump backend_equivalence_atol for Pillow 13.x bicubic change (#50105 miss)

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
ydshieh added a commit that referenced this pull request Nov 9, 2026
…) (#50510)

* Fix flaky backend equivalence tests with Pillow 13 (follow-up of #50105)

Pillow >= 13 can reverse the order of the two bicubic resize passes, which gives isolated pixel differences vs
torchvision above the default `atol=0.1`. #50105 (and #50170, #50327) set `backend_equivalence_atol = 0.5` for the
affected models; bridgetower, poolformer, deepseek_ocr2, got_ocr2, hunyuan_vl and levit were missed.

bridgetower, deepseek_ocr2 and got_ocr2 override the backend equivalence tests and call
`_assert_tensors_equivalence` without `atol`, which ignored `backend_equivalence_atol`. Make the helper default to
the class attribute (same value as before when it's not set), so those tests (and e.g. flava's
`test_slow_fast_equivalence`) also use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Pass `backend_equivalence_atol` explicitly instead of changing the helper default

Keep `_assert_tensors_equivalence` unchanged and pass `atol=self.backend_equivalence_atol` to the pixel value
comparisons of the overridden backend equivalence tests (bridgetower, deepseek_ocr2, got_ocr2, and flava, which
already sets `backend_equivalence_atol = 0.5`). Masks are still compared with the default tolerance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants