Skip to content

Conversation

@DefTruth
Copy link
Contributor

@DefTruth DefTruth commented Nov 4, 2025

enable attention dispatch for huanyuan video, adapted from:

https://github.com/huggingface/diffusers/blob/ac5a1e28fc9cc233863bcfb2abb9eef6807f156f/src/diffusers/models/transformers/transformer_hunyuanimage.py#L46C7-L46C32

Example

import torch
from diffusers import HunyuanVideoPipeline
from diffusers.utils import export_to_video

pipe: HunyuanVideoPipeline = HunyuanVideoPipeline.from_pretrained(
    "hunyuanvideo-community/HunyuanVideo",
    torch_dtype=torch.bfloat16,
)

pipe.enable_model_cpu_offload()
pipe.vae.enable_tiling()

def run_pipe():
    prompt = "A cat walks on the grass, realistic"
    output = pipe(
        prompt,
        height=320,
        width=512,
        num_frames=61,
        num_inference_steps=30,
        generator=torch.Generator("cpu").manual_seed(0),
    ).frames[0]
    return output

video = run_pipe()
export_to_video(video, "huanyuan_video.mp4", fps=15)
w/o this PR w/ this PR
huanyuan_video_ori huanyuan_video

@yiyixuxu pipelines

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.

1 participant