Skip to content

TorchDynamo with Pipeline loading #3403

@thepowerfuldeez

Description

@thepowerfuldeez

Describe the bug

Hi! I am using accelerate + diffusers for fine-tuning of stable diffusion using this script:
https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image.py
I have pytorch 2.0 and accelerate recently supports torch dynamo for improving speed of training.
However, when I set dynamo_backend = "inductor" in Accelerator class, I am getting error
in validation stage:

line 67:

pipeline = StableDiffusionPipeline.from_pretrained(
args.pretrained_model_name_or_path,
vae=accelerator.unwrap_model(vae),
text_encoder=accelerator.unwrap_model(text_encoder),
tokenizer=tokenizer,
unet=accelerator.unwrap_model(unet),
safety_checker=None,
revision=args.revision,
torch_dtype=weight_dtype,
)

of type: <class 'torch._dynamo.eval_frame.OptimizedModule'>, but should be <class 'diffusers.models.modeling_utils.ModelMixin'>

The issue is for unet

Reproduction

pipeline = StableDiffusionPipeline.from_pretrained(

Logs

No response

System Info

pytorch==2.0.1
diffusers==0.17.0.dev0
accelerate==0.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssues that haven't received updates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions