Skip to content

Please reconsider transformers>=5.0.0 #13935

@dxqb

Description

@dxqb

Describe the bug

Can you please reconsider requiring transformers>=5.0.0 on the module-level solely for the optional prompt-enhancer (pe) component?

This is a significant burden for downstream projects that pin transformers 4.x for unrelated reasons. As one data point, migrating to transformers v5 in our project (OneTrainer) turned out to be a substantial breaking change well beyond Ernie itself (e.g. Nerogar/OneTrainer#1506)

We will eventually upgrade transformers, but I'd appreciate it if it isn't forced by upgrading diffusers.

Details:

if is_transformers_version("<", "5.0.0"):
    raise ImportError("`ErnieImagePipeline` requires `transformers>=5.0.0` for `Ministral3ForCausalLM`.")

from transformers import Ministral3ForCausalLM  # noqa: E402

Ministral3ForCausalLM is only used as the type of the optional pe/pe_tokenizer ("prompt enhancer") components (_optional_components = ["pe", "pe_tokenizer"]), which the pipeline runs perfectly well without

The actually-required components — text_encoder: Mistral3Model, the transformer, VAE and scheduler — work fine on transformers 4.x (Mistral3Model already exists there).

Because the guard is unconditional and at module scope, any code that imports ErnieImagePipeline at all — even without ever touching pe — is now forced onto transformers>=5.0.0, even though the core model doesn't need it.

Reproduction

import transformers 
print(transformers.__version__)  # e.g. 4.57.6

from diffusers import ErnieImagePipeline


Logs

  4.57.6
  Traceback (most recent call last):
    ...
  ImportError: `ErnieImagePipeline` requires `transformers>=5.0.0` for `Ministral3ForCausalLM`.

System Info

not needed

Who can help?

Other: @yiyixuxu @DN6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    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