Skip to content

enable unidiffuser test cases on xpu #11444

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 30, 2025

Conversation

yao-matrix
Copy link
Contributor

w/ pytest -rA tests/pipelines/unidiffuser/test_unidiffuser.py, all cases passed except below 2:

tests/pipelines/unidiffuser/test_unidiffuser.py::UniDiffuserPipelineFastTests::test_cpu_offload_forward_pass_twice
tests/pipelines/unidiffuser/test_unidiffuser.py::UniDiffuserPipelineFastTests::test_model_cpu_offload_forward_pass

these 2 cases fail both on cuda and xpu, track through this issue #11443.

Signed-off-by: Yao Matrix <[email protected]>
Signed-off-by: Yao Matrix <[email protected]>
@yao-matrix
Copy link
Contributor Author

@a-r-r-o-w @DN6 , pls help review, thx.

Copy link
Member

@a-r-r-o-w a-r-r-o-w left a comment

Choose a reason for hiding this comment

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

Thanks!

@yao-matrix
Copy link
Contributor Author

the failed cases seem not related to my changes.

@@ -1677,11 +1677,11 @@ def test_cpu_offload_forward_pass_twice(self, expected_max_diff=2e-4):

pipe.set_progress_bar_config(disable=None)

pipe.enable_model_cpu_offload(device=torch_device)
pipe.enable_model_cpu_offload()
Copy link
Member

Choose a reason for hiding this comment

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

Was going to merge but just realized this was removed. Change looks good, but is there a particular reason for this to be removed for XPU case? The enable_model_cpu_offload method correctly gets passed torch_device="xpu" here, no?

Copy link
Contributor Author

@yao-matrix yao-matrix Apr 29, 2025

Choose a reason for hiding this comment

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

I changed it just because this is introduced in this PR #9399, it puts explicit torch_device to enable_model_cpu_offload to try to make it work on device other than CUDA(which is XPU in that case). But it doesn't work because diffusers internal logic also call enable_model_cpu_offload which cannot fixed by only setting device in application code, I fixed that issue in this PR #11288, and the PR was merged.

So, with latest code, we don't need application/test code to explicitly set the device, so I changed such changes in this test back to original. And another motivation I changed back is: I can see this usage is the recommended way in diffusers docs, so to align w/ the recommendation and test the most common used pattern.

To be short, in current codebase, both(with torch_device and without torch_device) work, I just changed back the way in original test code.

Hope it explains. thx.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation. I've triggered the tests and will merge once they pass

@yao-matrix
Copy link
Contributor Author

@a-r-r-o-w , pls feel free to let me know if you need more clarification or you have more comments, thx

@yao-matrix
Copy link
Contributor Author

yao-matrix commented Apr 30, 2025

@a-r-r-o-w seems my rebase to main interrupted your test, sorry, pls help re-trigger.

@a-r-r-o-w a-r-r-o-w merged commit 35fada4 into huggingface:main Apr 30, 2025
24 of 25 checks passed
@yao-matrix yao-matrix deleted the unidiffuser-xpu branch May 5, 2025 22:25
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.

2 participants