Skip to content

Conversation

@sayakpaul
Copy link
Member

What does this PR do?

Follow-up of #6665.

FYI @patrickvonplaten

I didn't address https://github.com/huggingface/diffusers/pull/6665/files#r1471447995 because I don't think the resizing scheme should be made a part of image_processor as it's quite specific I2VGenXL.

I will run the slow test of I2VGenXL once things look good just to be sure.

@sayakpaul sayakpaul requested review from DN6 and yiyixuxu February 4, 2024 13:16
@HuggingFaceDocBuilderDev

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.

Comment on lines 521 to 522
timesteps = timestep
timesteps = timesteps.to(sample.device)
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of using _to_tensor() here we simply do the device placement since timestep here will always come as a tensor IIUC.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok here but I didn't see that how timestep is forced to be tensor in the pipeline - note that the code to create timesteps is

    self.scheduler.set_timesteps(num_inference_steps, device=device)
    timesteps = self.scheduler.timesteps

so whether timesteps is a tensor or not it is really up to the how set_timesteps is implemented in the scheduler hence we still have to apply to_tensor inside the pipeline

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 3d26814.

If a scheduler in the pipeline changes and it set_timesteps() doesn't ensure tensor packing, it's gonna fail. I think the bigger question might be to think whether we should start setting timesteps to always be tensors from set_timesteps(). But I also think it's not a super high-prio right now.

Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

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

Thanks!
left one feedback and also let's fix the argument about attention_dim (see comment here #6665 (comment))

I'm ok with not refactoring the image pre-processing for now

Comment on lines 521 to 522
timesteps = timestep
timesteps = timesteps.to(sample.device)
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok here but I didn't see that how timestep is forced to be tensor in the pipeline - note that the code to create timesteps is

    self.scheduler.set_timesteps(num_inference_steps, device=device)
    timesteps = self.scheduler.timesteps

so whether timesteps is a tensor or not it is really up to the how set_timesteps is implemented in the scheduler hence we still have to apply to_tensor inside the pipeline

Number of layers to be skipped from CLIP while computing the prompt embeddings. A value of 1 means that
the output of the pre-final layer will be used for computing the prompt embeddings.
"""
# set lora scale so that monkey patched LoRA
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice clean up:)

@sayakpaul
Copy link
Member Author

Going to merge it now and tackle the num_attention_heads issue in a separate PR as discussed in https://huggingface.slack.com/archives/C065E480NN9/p1707185756803489.

@sayakpaul sayakpaul merged commit e6fd9ad into main Feb 6, 2024
@sayakpaul sayakpaul deleted the cleanup-i2vgenxl branch February 6, 2024 03:52
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* remove _to_tensor

* remove _to_tensor definition

* remove _collapse_frames_into_batch

* remove lora for not bloating the code.

* remove sample_size.

* simplify code a bit more

* ensure timesteps are always in tensor.
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.

5 participants