fix FlUX.1_dev guidance_batches bug for pad case in _split_inputs_int… #1607
+6
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…o_batches
What does this PR do?
Fixes # (issue)
https://habana.atlassian.net/browse/CS-864
Before submitting
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