Skip to content

[Version 0.39.0]AttributeError: 'CLIPTextModel' object has no attribute 'text_model' WHEN SET CKIP_SKIP NOT NONE #14124

Description

@CodingForAGI

Describe the bug

This bug should have been fixed, yet it still occurs in the latest version.
It does not trigger when clip_skip is set to None, but the issue appears whenever clip_skip has a non-None value.

Reproduction

pipe = StableDiffusionPipeline.from_single_file(
       pretrained_model_link_or_path=model_path,
       torch_dtype=torch.float16 if device.type == "cuda" else torch.float32,
       use_safetensors=True, 
   )

results = pipeline(
           prompt=[prompt] * batch,
           negative_prompt=[negative_prompt] * batch,
           height=height,
           width=width,
           num_inference_steps=steps,
           guidance_scale=guidance_scale,
           generator=generators,
           clip_skip=clip_skip
       )

Logs

- error log

 File "D:\Python\python_3_14\Lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 962, in __call__
    prompt_embeds, negative_prompt_embeds = self.encode_prompt(
                                            ~~~~~~~~~~~~~~~~~~^
        prompt,
        ^^^^^^^
    ...<7 lines>...
        clip_skip=self.clip_skip,
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "D:\Python\python_3_14\Lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 437, in encode_prompt
    prompt_embeds = self.text_encoder.text_model.final_layer_norm(prompt_embeds)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\python_3_14\Lib\site-packages\torch\nn\modules\module.py", line 1965, in __getattr__
    raise AttributeError(
        f"'{type(self).__name__}' object has no attribute '{name}'"
    )
AttributeError: 'CLIPTextModel' object has no attribute 'text_model'

System Info

  • Software Version
diffusers               0.39.0
transformers            5.13.0

Who can help?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions