Skip to content

introduce compute arch specific expectations and fix test_sd3_img2img_inference failure #11227

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

Merged
merged 6 commits into from
Apr 8, 2025

Conversation

yao-matrix
Copy link
Contributor

@yao-matrix yao-matrix commented Apr 8, 2025

@hlky , as you know, different compute arch can lead to different expected numeric for same case.
One example is: pytest -rA tests -k "StableDiffusion3Img2ImgPipelineSlowTests and test_sd3_img2img_inference" will fail on A100 and XPU since current expected_slice is designed for T4 (CUDA 7).

By borrowing the design from transformers for the same case(as @ivarflakstad introduced in huggingface/transformers#36569), I am proposing to use the same mechanism in diffusers tests.

I copied the implementations from transformers to avoid unnecessary versioning dependency, and let me know if you think directly import from transformers is more preferred from you.

W. this PR, test_sd3_img2img_inference case passed both pass on A100 and XPU 1550; before both failed.

Thx.

…merical characteristics

Signed-off-by: YAO Matrix <matrix.yao@intel.com>
Signed-off-by: YAO Matrix <matrix.yao@intel.com>
@yao-matrix
Copy link
Contributor Author

@faaany , if this approved and merged finally, we can follow same design to handle other numerical expectation related issues later.

@HuggingFaceDocBuilderDev

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.

Copy link
Contributor

@hlky hlky left a comment

Choose a reason for hiding this comment

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

Hi @yao-matrix. Thanks for making this PR, nice improvement. Copying from transformers is ok in this case, diffusers is still supporting Python 3.8, we will hopefully drop it by 0.34, the suggested changes here are all for that purpose. After those changes are applied and a make style && make quality, which I can apply via our bot, this should be good to go.

cc @yiyixuxu for awareness

@hlky
Copy link
Contributor

hlky commented Apr 8, 2025

@bot /style

Copy link
Contributor

github-actions bot commented Apr 8, 2025

Style fixes have been applied. View the workflow run here.

@hlky hlky requested review from DN6 and sayakpaul April 8, 2025 12:37
Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Looks really really good! Thanks for solving this longstanding problem.



@functools.lru_cache
def get_device_properties() -> DeviceProperties:
Copy link
Member

Choose a reason for hiding this comment

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

Should this return a dict instead? We could have sensible key namings like:

{"device_type": "cuda", "compute_info": 8.0}

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's raise it internally with transformers team as it's best to keep this in sync with their code (except Python 3.8 changes)

Copy link
Member

Choose a reason for hiding this comment

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

Fine by me. Cc: @ivarflakstad

Copy link
Member

Choose a reason for hiding this comment

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

Hey!
Honestly any type that can be used as a key is fine by me.
Originally it was a dataclass with fields, but we wanted to keep it as simple as possible while still solving the problem it's addressing.

Feel free to upstream any improvements you can think of ☺️

@hlky
Copy link
Contributor

hlky commented Apr 8, 2025

Failing tests are unrelated. Merging to not be a blocker, with a note to revisit get_device_properties after discussion with transformers.

@hlky hlky merged commit c51b6bd into huggingface:main Apr 8, 2025
11 of 12 checks passed
@yao-matrix yao-matrix deleted the issue79 branch April 9, 2025 05:14
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.

5 participants