Skip to content
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

fix FlUX.1_dev guidance_batches bug for pad case in _split_inputs_int… #1607

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

huijuanzh
Copy link
Contributor

…o_batches

What does this PR do?

Fixes # (issue)
https://habana.atlassian.net/browse/CS-864

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

runtime error when num_images_per_prompt is not divisible by batch_size .
test cmd:
python text_to_image_generation.py --model_name_or_path /nfs_home/data/FLUX.1-dev --prompts "A cat holding a sign that says hello world" --num_images_per_prompt 10 --batch_size 4 --num_inference_steps 4 --image_save_dir /tmp/flux_1_images --scheduler flow_match_euler_discrete --use_habana --use_hpu_graphs --gaudi_config Habana/stable-diffusion --bf16

Traceback (most recent call last):
File "/host/mnt/ctrl/disk1/personal/huijuanz/ws/optimum-habana/examples/stable-diffusion/text_to_image_generation.py", line 699, in
main()
File "/host/mnt/ctrl/disk1/personal/huijuanz/ws/optimum-habana/examples/stable-diffusion/text_to_image_generation.py", line 662, in main
outputs = pipeline(prompt=args.prompts, **kwargs_call)
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "/host/mnt/ctrl/disk1/personal/huijuanz/ws/optimum-habana/optimum/habana/diffusers/pipelines/flux/pipeline_flux.py", line 638, in call
) = self._split_inputs_into_batches(batch_size, latents, prompt_embeds, pooled_prompt_embeds, guidance)
File "/host/mnt/ctrl/disk1/personal/huijuanz/ws/optimum-habana/optimum/habana/diffusers/pipelines/flux/pipeline_flux.py", line 371, in _split_inputs_into_batches
sequence_to_stack = (guidance_batches[-1],) + tuple(
File "/host/mnt/ctrl/disk1/personal/huijuanz/ws/optimum-habana/optimum/habana/diffusers/pipelines/flux/pipeline_flux.py", line 372, in
torch.zeros_like(guidance_batches[-1][0][None, :]) for _ in range(num_dummy_samples)
IndexError: too many indices for tensor of dimension 0

@huijuanzh huijuanzh requested a review from regisss as a code owner December 13, 2024 08:54
@huijuanzh
Copy link
Contributor Author

@regisss @dsocek please help to review

Copy link
Contributor

@dsocek dsocek left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix

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