Skip to content

Fix Hunyuan-VL PIL image resize parity with reference preprocessing#47233

Merged
zucchini-nlp merged 3 commits into
huggingface:mainfrom
IMvision12:fix4
Jul 22, 2026
Merged

Fix Hunyuan-VL PIL image resize parity with reference preprocessing#47233
zucchini-nlp merged 3 commits into
huggingface:mainfrom
IMvision12:fix4

Conversation

@IMvision12

@IMvision12 IMvision12 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

CI

This PR removes the manual PIL resize workaround from the Hunyuan-VL PIL image processor and routes resizing through the shared processor backend.

The previous code manually converted numpy images to PIL, called PIL.Image.resize(...), then converted back to numpy because the shared resize path produced degraded results. The difference came from the default resize method: plain PIL resize matches bicubic behavior here, while the shared path was falling back to bilinear when resample=None.

This PR preserves the original HunyuanOCR preprocessing behavior by defaulting Hunyuan-VL PIL resize to PILImageResampling.BICUBIC when no resample value is provided.

Tests

  • Added a regression test confirming the default Hunyuan-VL PIL resize output matches explicit bicubic resize.
  • Verified that bilinear produces different output, preventing accidental regression.

@Rocketknight1

Copy link
Copy Markdown
Member

cc @zucchini-nlp

@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.

yeah, we defi need to fix this now that the model is released! I will trigger slow CI, since I had no time to check what type of "difference from baseline implementation" there was

Comment thread src/transformers/models/hunyuan_vl/modular_hunyuan_vl.py Outdated
@zucchini-nlp

Copy link
Copy Markdown
Member

run-slow: hunyuan_vl

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/hunyuan_vl"]
quantizations: []

@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.

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 27e9fbe5 workflow commit (merge commit)
PR 331b795a branch commit (from PR)
main a8609bed base commit (on main)

⚠️ Model CI failed to report results

The test failure analysis could not be completed. Please check the workflow run for details.

@zucchini-nlp

Copy link
Copy Markdown
Member

Oh right, slow tests are failing in main as well, though the error messages look different. Can you check locally @IMvision12 ?

@IMvision12

Copy link
Copy Markdown
Contributor Author

@zucchini-nlp Yeah, I checked locally on GPU and the same slow Hunyuan-VL test fails because the generated text snapshot changed after the PIL image preprocessing update. I updated the expected ("cuda", None) output for test_small_model_integration_test_multi_image_nested using the CI-generated text.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/
  • A new high-severity security issue was detected in the changed Python files (Bandit check)

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@IMvision12
IMvision12 requested a review from zucchini-nlp July 16, 2026 18:02
Comment thread tests/models/hunyuan_vl/test_modeling_hunyuan_vl.py Outdated
@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: hunyuan_vl

@IMvision12

Copy link
Copy Markdown
Contributor Author

@zucchini-nlp can you again run the slow test?

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 29068900477:2
Result: success | Jobs: 3 | Tests: 49 | Failures: 0 | Duration: 1m 49s

@zucchini-nlp

Copy link
Copy Markdown
Member

run-slow: hunyuan_vl

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/hunyuan_vl"]
quantizations: []

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 1665004c workflow commit (merge commit)
PR de21dc48 branch commit (from PR)
main 75a5542e base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !

@IMvision12

Copy link
Copy Markdown
Contributor Author

@zucchini-nlp any updates from Hunyuan team?

@zucchini-nlp

Copy link
Copy Markdown
Member

Nope, silence from their side. Let's merge and I'll revert hardcoding if they decide to update hub configs

@zucchini-nlp
zucchini-nlp added this pull request to the merge queue Jul 22, 2026
Merged via the queue into huggingface:main with commit 3ac317a Jul 22, 2026
33 checks passed
@IMvision12
IMvision12 deleted the fix4 branch July 22, 2026 07:58
SangbumChoi added a commit to SangbumChoi/transformers that referenced this pull request Jul 22, 2026
* upstream/main: (39 commits)
  Remove deprecated training args and `is_fast` property (huggingface#46917)
  Consistent output shape from `get_image_features` (huggingface#46405)
  Fix multi-device mxfp4 dequantization race in `_convert_moe_packed_tensors` (huggingface#47423)
  fix failed test cases for qwen3_omni_moe model (huggingface#47449)
  Fix Hunyuan-VL PIL image resize parity with reference preprocessing (huggingface#47233)
  Move `value` padding into the attention interfaces that need it (huggingface#47451)
  Simplify function dispatch for linear attention (huggingface#47450)
  [cache] Allow sliding window layers to be roll-backed for speculative decoding (huggingface#47447)
  Fix double-shifted training loss in GitForCausalLM (huggingface#47395)
  Fix CohereASR training-loss double-shift (same as Moonshine fix huggingface#46784) (huggingface#46895)
  Warn when `group_by_length` is silently ignored for iterable datasets (huggingface#47379)
  Update bug report list (huggingface#46607)
  Fix shape mismatch in KyutaiSpeechToText `generate()` last window (huggingface#46952)
  Optimize flash attention max seqlen computation in vision attention (huggingface#47170)
  fix: remove unreachable return in special token builder (huggingface#47420)
  Add Harry to slow CI (huggingface#47454)
  BLT: vectorize patch length processing (huggingface#47385)
  Fix `TrackioCallback` fails to log evaluation metrics after training ends (huggingface#46935)
  [Kimi] add integration tests (huggingface#47383)
  Fix typo in `MusicgenForCausalLM.generate()` (huggingface#46974)
  ...
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.

4 participants