Unverified Commit 3ec299f4 authored by Subho Ghosh's avatar Subho Ghosh Committed by GitHub
Browse files

fix: fix ValueError in NunchakuQwenImagePipeline.prepare_latents unpacking (#616)

* fix: enhance latent variable preparation in NunchakuQwenImagePipeline

- Refactored latent variable preparation to utilize the parent method for generating latents.
- Added manual generation of latent_image_ids to ensure correct indexing.

* refactor: clean up whitespace in NunchakuQwenImagePipeline

- Removed unnecessary whitespace in the latent variable preparation section for improved readability.
parent 9ed2db76
......@@ -96,7 +96,9 @@ class NunchakuQwenImagePipeline(QwenImagePipeline):
# 4. Prepare latent variables
num_channels_latents = self.transformer.config.in_channels // 4
latents, latent_image_ids = self.prepare_latents(
# Get latents from parent method (returns single tensor)
latents = super().prepare_latents(
batch_size * num_images_per_prompt,
num_channels_latents,
height,
......@@ -106,6 +108,12 @@ class NunchakuQwenImagePipeline(QwenImagePipeline):
generator,
latents,
)
# Generate latent_image_ids manually
seq_len = latents.shape[1] if len(latents.shape) > 1 else 0
latent_image_ids = torch.arange(seq_len, device=device, dtype=torch.long)
latent_image_ids = latent_image_ids.unsqueeze(0).repeat(batch_size * num_images_per_prompt, 1)
img_shapes = [(1, height // self.vae_scale_factor // 2, width // self.vae_scale_factor // 2)] * batch_size
# 5. Prepare timesteps
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment