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

add cogvideox support for gaudi. #1600

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

Conversation

nc-BobLee
Copy link

@nc-BobLee nc-BobLee commented Dec 12, 2024

What does this PR do?

Fixes # (issue)

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?

@nc-BobLee nc-BobLee requested a review from regisss as a code owner December 12, 2024 09:07
@nc-BobLee
Copy link
Author

nc-BobLee commented Dec 12, 2024

test command:python cogvideo_generate.py --model_name_or_path /mnt/disk2/libo/hf_models/CogVideoX-2b/ --output_name
panda_gaudi.mp4
output video:https://github.com/user-attachments/assets/917511eb-9878-433e-96cc-37242c8e563c

@nc-BobLee
Copy link
Author

panda_gaudi.mp4

@nc-BobLee nc-BobLee closed this Dec 12, 2024
@nc-BobLee nc-BobLee reopened this Dec 12, 2024
@nc-BobLee
Copy link
Author

could you please help to review my change @shepark
thanks!

@shepark
Copy link
Collaborator

shepark commented Jan 18, 2025

could you please help to review my change @shepark thanks!

I sent email to you, please response it. thanks.

@Wei-Lin-Intel
Copy link
Contributor

Hi @regisss , could you please help to review this PR? Thanks!

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.

See comments for requested changes. Also, please run make style to fix code formatting

@@ -0,0 +1,86 @@
import argparse
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file and use text_to_video_generation.py script for this sample (need to switch pipeline based on model, similarly as one in text_to_image_generation.py)

@@ -1,3 +1,4 @@
from .pipelines.cogvideox.cogvideoX_gaudi import adapt_cogvideo_to_gaudi
Copy link
Contributor

Choose a reason for hiding this comment

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

remove from here

@@ -0,0 +1,468 @@
from typing import Any, Dict, Optional, Tuple, Union
Copy link
Contributor

Choose a reason for hiding this comment

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

This file does not belong here. Either add these definitions to your cogvideox pipeline py file, or maybe put some of the attention functions under optimum/habana/diffusers/models/* and rest inside cogvideox pipeline py file.

from diffusers.models.autoencoders.autoencoder_kl_cogvideox import AutoencoderKLCogVideoX


class AutoencoderKLCogVideoXGaudi(AutoencoderKLCogVideoX):
Copy link
Contributor

Choose a reason for hiding this comment

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

Adapted from? Please put reference here

from diffusers.models.autoencoders.vae import DecoderOutput


class CogVideoXCausalConv3dGaudi(nn.Module):
Copy link
Contributor

Choose a reason for hiding this comment

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

Adapted from? Please put reference here

frames: torch.Tensor

# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.retrieve_timesteps
def retrieve_timesteps(
Copy link
Contributor

Choose a reason for hiding this comment

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

can we import this directly from diffusers?

logger = logging.get_logger(__name__) # pylint: disable=invalid-name


class time_box_t():
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use same timing mechanism as in other pipelines (need to deal with warmup etc.)

htcore.mark_step()
time_box.show_time('transformer_hpu')

#HabanaProfile.stop()
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comment

).frames[0]

assert video is not None
assert 49 == len(video)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use self.assertEqual here

generator=torch.Generator(device="cpu").manual_seed(42),
).frames[0]

assert video is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

use self.assertIsNotNone here

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.

7 participants