huggingface / huggingface/diffusers
Please reconsider `transformers>=5.0.0`
- Dominant language
- Python
- Stars
- 34.5k
- Forks
- 7.3k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 91
Description
### 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. https://github.com/Nerogar/OneTrainer/pull/1506)
We will eventually upgrade transformers, but I'd appreciate it if it isn't forced by upgrading diffusers.
Details:
```python
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
Contributor guide
Research direction
Start at the ErnieImagePipeline module and inspect the module-level transformers version guard, the optional pe and pe_tokenizer components, and the Ministral3ForCausalLM import. Reproduce the reported import with transformers 4.57.6, then verify that importing the pipeline without prompt enhancement works on transformers 4.x while the optional component retains its required version behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100