-
Notifications
You must be signed in to change notification settings - Fork 6.5k
[modular] add tests for qwen modular #12585
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
base: main
Are you sure you want to change the base?
Conversation
| @property | ||
| def inputs(self) -> List[InputParam]: | ||
| return [ | ||
| InputParam("latents"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to how it's done in the other pipelines.
| ) | ||
| ] | ||
| * block_state.batch_size | ||
| for _ in range(block_state.batch_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have two options:
- Either this
- Or how it's done in edit:
diffusers/src/diffusers/pipelines/qwenimage/pipeline_qwenimage_edit.py
Lines 752 to 757 in 325a950
img_shapes = [ [ (1, height // self.vae_scale_factor // 2, width // self.vae_scale_factor // 2), (1, calculated_height // self.vae_scale_factor // 2, calculated_width // self.vae_scale_factor // 2), ] ] * batch_size
Regardless, the current implementation isn't exactly the same as how the standard pipeline implements it and would break for the batched input tests we have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for qwen image, not edit though https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/qwenimage/pipeline_qwenimage.py#L636
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad sorry. I meant to refer to the Qwen Image pipeline, actually:
| img_shapes = [[(1, height // self.vae_scale_factor // 2, width // self.vae_scale_factor // 2)]] * batch_size |
In modular, we are doing:
diffusers/src/diffusers/modular_pipelines/qwenimage/before_denoise.py
Lines 544 to 553 in 5a47442
| block_state.img_shapes = [ | |
| [ | |
| ( | |
| 1, | |
| block_state.height // components.vae_scale_factor // 2, | |
| block_state.width // components.vae_scale_factor // 2, | |
| ) | |
| ] | |
| * block_state.batch_size | |
| ] |
Which I think are different (first just multiplies with batch_size while the second does an inner multiplication).
As a consequence of that, we get:
FAILED tests/modular_pipelines/qwen/test_modular_pipeline_qwenimage.py::TestQwenImageModularPipelineFast::test_inference_batch_consistent - RuntimeError: The size of tensor a (16) must match the size of tensor b (32) at non-singleton dimension 1
FAILED tests/modular_pipelines/qwen/test_modular_pipeline_qwenimage.py::TestQwenImageModularPipelineFast::test_inference_batch_single_identical - RuntimeError: The size of tensor a (16) must match the size of tensor b (32) at non-singleton dimension 1The change in this PR fixes that. I also checked the test_qwenimage.py test-suite to see if we're skipping those failing tests and it seems like we are not. But I will defer to you for the final call here.
Let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh ok got it!
let's just do same as the qwen image pipeline?
| block_state.negative_prompt_embeds = None | ||
| block_state.negative_prompt_embeds_mask = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, no CFG settings would break.
| @pytest.mark.xfail(condition=True, reason="Batch of multiple images needs to be revisited", strict=True) | ||
| def test_num_images_per_prompt(self): | ||
| super().test_num_images_per_prompt() | ||
|
|
||
| @pytest.mark.xfail(condition=True, reason="Batch of multiple images needs to be revisited", strict=True) | ||
| def test_inference_batch_consistent(): | ||
| super().test_inference_batch_consistent() | ||
|
|
||
| @pytest.mark.xfail(condition=True, reason="Batch of multiple images needs to be revisited", strict=True) | ||
| def test_inference_batch_single_identical(): | ||
| super().test_inference_batch_single_identical() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are skipped in the standard pipeline tests, too.
|
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. |
|
With Update: Checking with the All of those tests work with |
DN6
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just comments on aligning with new testing structure.
tests/modular_pipelines/qwen/test_modular_pipeline_qwenimage.py
Outdated
Show resolved
Hide resolved
tests/modular_pipelines/qwen/test_modular_pipeline_qwenimage.py
Outdated
Show resolved
Hide resolved
tests/modular_pipelines/qwen/test_modular_pipeline_qwenimage.py
Outdated
Show resolved
Hide resolved
tests/modular_pipelines/qwen/test_modular_pipeline_qwenimage.py
Outdated
Show resolved
Hide resolved
tests/modular_pipelines/qwen/test_modular_pipeline_qwenimage.py
Outdated
Show resolved
Hide resolved
|
I will wait for your #12579 PR to get merged first. Easier that way for me to apply your suggestions. |
|
@DN6 I have aligned the tests to follow the current structure. PTAL. |
|
@DN6 the following tests are failing: FAILED tests/modular_pipelines/stable_diffusion_xl/test_modular_pipeline_stable_diffusion_xl.py::TestSDXLModularPipelineFast::test_float16_inference - RuntimeError: expected scalar type Half but found Float
FAILED tests/modular_pipelines/stable_diffusion_xl/test_modular_pipeline_stable_diffusion_xl.py::TestSDXLImg2ImgModularPipelineFast::test_float16_inference - RuntimeError: expected scalar type Half but found FloatI think it's probably because of #12512 |
yiyixuxu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about img_shape here https://github.com/huggingface/diffusers/pull/12585/files#r2512902725
also, i think qwen pipelines currently do not support batch_size > 1, (num_images_per_prompt >1 is ok) so we can skip the test for multiple prompts for now
The rest of change looks good to me!
|
@yiyixuxu perfect. I have also addressed your comment on |
What does this PR do?
Some things came up with the tests that needed fixing. But LMK if you would like me to revert them.
I also fixed a bunch of small things related to tests as I was running them on both GPU and CPU.
Will propagate the changes from #12579 once it's merged.