Skip to content

diffusers 0.30.0 StableDiffusionXLControlNetPipeline dtype error #9200

@yagmurx

Description

@yagmurx

Describe the bug

Description:

I am defining two ControlNetModel instances using the diffusers library and creating a pipeline using StableDiffusionXLControlNetPipeline. When I try to generate with this pipeline, I encounter an error in diffusers version 0.30.0, although it works fine in version 0.27.2. The error message is:

RuntimeError: mat1 and mat2 must have the same dtype, but got Float and Half

Additional Information:

  • The issue is present in diffusers version 0.30.0 but not in version 0.27.2.
  • The models and pipeline are all moved to CUDA.

Reproduction

from diffusers import (
     StableDiffusionXLPipeline,
     ControlNetModel,
     StableDiffusionXLControlNetPipeline
     )
     
SDXL_MODEL_PATH = "/local/path/to/safetensors/"
SDXL_MODEL_CONF =  "/local/path/to/config_yaml/"

pipe = StableDiffusionXLPipeline.from_single_file(
    SDXL_MODEL_PATH,
    original_config_file=SDXL_MODEL_CONF,
    torch_dtype=torch.float16,
    text_encoder=text_encoder,
    text_encoder_2=text_encoder_2,
    tokenizer=tokenizer,
    tokenizer_2=tokenizer,
    local_files_only=True,
    use_safetensors=True,
    add_watermarker=False,
    feature_extractor=None,
).to("cuda")

controlnets = [
    ControlNetModel.from_pretrained(
        "/local/path/to/destitech/controlnet-inpaint-dreamer-sdxl/",
        torch_dtype=torch.float16,
#         variant="fp16",
    ).to("cuda"),
    ControlNetModel.from_pretrained(
        "/local/path/to/diffusers/controlnet-zoe-depth-sdxl-1.0/",
        torch_dtype=torch.float16,
    ).to("cuda"),
]
pipeline = StableDiffusionXLControlNetPipeline(**pipe.components, controlnet=controlnets)


image = pipeline(
                   prompt,
                   negative_prompt=negative_prompt,
                   image= [init_image, zoe_mask],
                   guidance_scale=6.5,
                   num_inference_steps=25,
                   generator=generator,
                   controlnet_conditioning_scale=[0.5, 0.8],
                   control_guidance_end=[0.9, 0.6],
                   ).images[0]
                   
 image.save("output.jpg")
````

### Logs

_No response_

### System Info

- 🤗 Diffusers version: 0.30.0
- Platform: Linux-4.18.0-372.107.1.el8_6.x86_64-x86_64-with-glibc2.35
- Running on Google Colab?: No
- Python version: 3.10.12
- PyTorch version (GPU?): 2.3.1+cu121 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Huggingface_hub version: 0.23.3
- Transformers version: 4.41.2
- Accelerate version: 0.30.1
- PEFT version: not installed
- Bitsandbytes version: not installed
- Safetensors version: 0.4.3
- xFormers version: not installed
- Accelerator: (secret, 32GB)
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

### Who can help?

@sayakpaul 

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