Skip to content

Conversation

@DN6
Copy link
Collaborator

@DN6 DN6 commented Dec 19, 2024

What does this PR do?

Thanks to @jmahajan117 for flagging.

Ran this test on DGX and it passes

def test_model_parallelism(self):

Example code:

import torch
from diffusers import MochiPipeline, MochiTransformer3DModel
from diffusers.utils import export_to_video

model_id = "genmo/mochi-1-preview"
transformer = MochiTransformer3DModel.from_pretrained(
    model_id,
    subfolder="transformer",
    device_map="auto",
    max_memory={0: "24GB", 1: "24GB"}
)
print(transformer.hf_device_map)

pipe = MochiPipeline.from_pretrained(model_id,  transformer=transformer)
pipe.enable_model_cpu_offload()
pipe.enable_vae_tiling()

with torch.autocast(device_type="cuda", dtype=torch.bfloat16, cache_enabled=False):
    frames = pipe(
        prompt="Close-up of a chameleon's eye, with its scaly skin changing color. Ultra high resolution 4k.",
        negative_prompt="",
        height=480,
        width=848,
        num_frames=85,
        num_inference_steps=50,
        guidance_scale=4.5,
        num_videos_per_prompt=1,
        generator=torch.Generator(device="cuda").manual_seed(0),
        max_sequence_length=256,
        output_type="pil",
    ).frames[0]

export_to_video(frames, "output.mp4", fps=30)

Fixes # (issue)

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@DN6 DN6 requested a review from a-r-r-o-w December 19, 2024 07:31
@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.

Copy link
Contributor

@a-r-r-o-w a-r-r-o-w left a comment

Choose a reason for hiding this comment

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

Oh... I think I definitely forgot _no_split_modules on some of the latest integrations. They would probably suffer with the same issues?

@DN6
Copy link
Collaborator Author

DN6 commented Dec 19, 2024

@a-r-r-o-w Yeah it's a pretty safe addition to just add the transformer blocks to no split if you haven't already.

@DN6
Copy link
Collaborator Author

DN6 commented Dec 19, 2024

Failing example test is unrelated.

@DN6 DN6 merged commit 3ee9669 into main Dec 19, 2024
14 of 15 checks passed
Foundsheep pushed a commit to Foundsheep/diffusers that referenced this pull request Dec 23, 2024
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.

4 participants