Internvl fix#38946
Conversation
|
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 is a workaround to avoid a bug in torch.compile when dealing with uint8 on AMD MI3XX GPUs | ||
| # Tracked in PyTorch issue: https://github.com/pytorch/pytorch/issues/155209 | ||
| # TODO: remove this once the bug is fixed (detected with torch==2.7.0+git1fee196, torchvision==0.22.0+9eb57cd) | ||
| if torch.compiler.is_compiling() and is_rocm_platform(): | ||
| return self.compile_friendly_resize(image, new_size, interpolation, antialias) |
There was a problem hiding this comment.
could you share what tests would need this?
Why we have compiling in image processing stage ..?
There was a problem hiding this comment.
Added the failing tests to the PR description! As for why there is compiling, I am not sure -- probably helps speedup the processing stage
| shorter = size.shortest_edge | ||
| longer = int(1333 / 800 * shorter) | ||
| output_size = get_resize_output_image_size( | ||
| output_height, output_width = get_resize_output_image_size( |
There was a problem hiding this comment.
could you explain why such changes here and below?
There was a problem hiding this comment.
The idea here is to use the parent's class resize function rather than torchvision equivalent directly. To do that, we unpack the output_size to then use the output_height and output_width to build a SizeDict which is needed for super().resize
|
It's better to explain a bit about the changes. (maybe it's explained in the PR for Also since this is not only test files, I feel it's better for other team members (who work a lot on image stuffs ) to take a look too. |
|
Yes you are right, my bad! I added more context to the PR description. And as for other team members, I agree, tagging @yonigozlan and @zucchini-nlp as they already reviewed the last PR. |
zucchini-nlp
left a comment
There was a problem hiding this comment.
Since it was discussed already in side branch, lgtm!
Tiny nit: I see many other models calling F.resize instead of super() which aren't fixed in this PR (e.g. pixtral, convnext). Do we need to fix them as well, or are the tests not failing for them?
| stacked_videos = self.resize( | ||
| image=stacked_videos, | ||
| size=SizeDict(height=resized_height, width=resized_width), | ||
| interpolation=interpolation, |
There was a problem hiding this comment.
Qwen2-vl image processor as well 😄
There was a problem hiding this comment.
Made the change in image_processing_qwen2_vl_fast.py but not in image_processing_qwen2_vl.py because it has a input_data_format argument I am not sure about -- did you mean to change it in both?
There was a problem hiding this comment.
No, only the fast processor. Slow processors don't rely on torchvision :)
|
We only looked at tests that failed on Mi3XX that passed on the T4 CI, so either (1) the tests did not pass on the T4 (2) they were skipped on MI3XX or (3) they passed for some weird reason (no compilation, etc). I can look into those tests next |
|
Yeah, let's check those tests as well. In case the compile issue is not affecting all models equally under same settings, I think we should not need the workaround |
yonigozlan
left a comment
There was a problem hiding this comment.
LGTM as well! Agreed with @zucchini-nlp, if we can address the issue of using F.resize instead of self.resize (or super().resize) for all fast image processors that would be great, might be a bit out of scope for this PR though
|
run-slow: bridgetower, llava_next, llava_onevision, qwen2_vl, qwen2_vl |
|
let's wait the above CI runs |
|
This comment contains run-slow, running the specified jobs: models: ['models/bridgetower', 'models/llava_next', 'models/llava_onevision', 'models/qwen2_vl'] |
Tested with pixtral, and the test |
|
run-slow: bridgetower, llava_next, llava_onevision, qwen2_vl, qwen2_vl |
|
This comment contains run-slow, running the specified jobs: models: ['models/bridgetower', 'models/llava_next', 'models/llava_onevision', 'models/qwen2_vl'] |
|
Great @remi-or , thanks for digging! |
|
slow tests look good. I think we could merge? |
|
Yep, I also think we need to replace |
|
Should we take care of it in this PR or should we leave that for a PR with a larger scope? |
* Added a compile-friendly versiom of resize to BaseImgProcessorFast * Changed qwen2 processor to use its parent class .resize * Style * underlined issue only happens on AMD w/ comment and bool check * Fixed some utils functions * Fixed the same issue for bridgetower * Fixed the same issue for llava_next * Repo consistency for llava onevision * Update src/transformers/image_processing_utils_fast.py Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com>
* Image processor compile fix (huggingface#38540) * Added a compile-friendly versiom of resize to BaseImgProcessorFast * Changed qwen2 processor to use its parent class .resize * Style * underlined issue only happens on AMD w/ comment and bool check * Fixed some utils functions * Fixed the same issue for bridgetower * Fixed the same issue for llava_next * Repo consistency for llava onevision * Update src/transformers/image_processing_utils_fast.py Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> * Added an Expectation to an internvl test * Made qwen2_vl use the resize method of its parent clas * Changed to torch.where --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com>
* Image processor compile fix (huggingface#38540) * Added a compile-friendly versiom of resize to BaseImgProcessorFast * Changed qwen2 processor to use its parent class .resize * Style * underlined issue only happens on AMD w/ comment and bool check * Fixed some utils functions * Fixed the same issue for bridgetower * Fixed the same issue for llava_next * Repo consistency for llava onevision * Update src/transformers/image_processing_utils_fast.py Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> * Added an Expectation to an internvl test * Made qwen2_vl use the resize method of its parent clas * Changed to torch.where --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com>
* Image processor compile fix (huggingface#38540) * Added a compile-friendly versiom of resize to BaseImgProcessorFast * Changed qwen2 processor to use its parent class .resize * Style * underlined issue only happens on AMD w/ comment and bool check * Fixed some utils functions * Fixed the same issue for bridgetower * Fixed the same issue for llava_next * Repo consistency for llava onevision * Update src/transformers/image_processing_utils_fast.py Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> * Added an Expectation to an internvl test * Made qwen2_vl use the resize method of its parent clas * Changed to torch.where --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com>
* Image processor compile fix (huggingface#38540) * Added a compile-friendly versiom of resize to BaseImgProcessorFast * Changed qwen2 processor to use its parent class .resize * Style * underlined issue only happens on AMD w/ comment and bool check * Fixed some utils functions * Fixed the same issue for bridgetower * Fixed the same issue for llava_next * Repo consistency for llava onevision * Update src/transformers/image_processing_utils_fast.py Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> * Added an Expectation to an internvl test * Made qwen2_vl use the resize method of its parent clas * Changed to torch.where --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com>
* Image processor compile fix (huggingface#38540) * Added a compile-friendly versiom of resize to BaseImgProcessorFast * Changed qwen2 processor to use its parent class .resize * Style * underlined issue only happens on AMD w/ comment and bool check * Fixed some utils functions * Fixed the same issue for bridgetower * Fixed the same issue for llava_next * Repo consistency for llava onevision * Update src/transformers/image_processing_utils_fast.py Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> * Added an Expectation to an internvl test * Made qwen2_vl use the resize method of its parent clas * Changed to torch.where --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com>
* Image processor compile fix (huggingface#38540) * Added a compile-friendly versiom of resize to BaseImgProcessorFast * Changed qwen2 processor to use its parent class .resize * Style * underlined issue only happens on AMD w/ comment and bool check * Fixed some utils functions * Fixed the same issue for bridgetower * Fixed the same issue for llava_next * Repo consistency for llava onevision * Update src/transformers/image_processing_utils_fast.py Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> * Added an Expectation to an internvl test * Made qwen2_vl use the resize method of its parent clas * Changed to torch.where --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com>
* Image processor compile fix (huggingface#38540) * Added a compile-friendly versiom of resize to BaseImgProcessorFast * Changed qwen2 processor to use its parent class .resize * Style * underlined issue only happens on AMD w/ comment and bool check * Fixed some utils functions * Fixed the same issue for bridgetower * Fixed the same issue for llava_next * Repo consistency for llava onevision * Update src/transformers/image_processing_utils_fast.py Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com> * Added an Expectation to an internvl test * Made qwen2_vl use the resize method of its parent clas * Changed to torch.where --------- Co-authored-by: Mohit Sharma <mohit21sharma.ms@gmail.com>
This PR brings to main a fix that was added in
amd-hf-ci-branchhere: #38540The fix aims to correct a failure of
torch.compilewhen compiling a torchvisionresizefunction with an uint8 input. The failing tests were:This PR also add some Expectations for AMD machines.