huggingface / huggingface/diffusers

LTX2 import fails with Transformers 5.5.0 due to annotation-only Gemma4Unified dependency

Open
#14,773 2 comments 0 reactions 0 assignees View on GitHub
bug needs-env-info pipelines
Dominant language
Python
Stars
34.5k
Forks
7.3k
Avg merge
3d 3h
Merged PRs (30d)
91

Description

### Describe the bug

With Diffusers 0.40.0 and Transformers 5.5.0, importing `LTX2Pipeline` fails because `Gemma4UnifiedForConditionalGeneration` is unavailable. This blocks Gemma3-based LTX 2.3 use before any checkpoint is loaded. We encountered this in Unsloth Desktop, but the reproduction does not import Unsloth.

The unconditional import is also present on current [main](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/ltx2/pipeline_ltx2.py). In the five affected pipeline modules in 0.40.0, the missing class is used only in the `text_encoder` constructor annotation.

### Reproduction

In an environment with PyTorch, `diffusers==0.40.0`, and `transformers==5.5.0`:

```python
from diffusers import LTX2Pipeline
```

`LTX2ImageToVideoPipeline` fails similarly. No model download, GPU generation, or authentication is required to trigger this error.

### Logs

```text
RuntimeError: Failed to import diffusers.pipelines.ltx2.pipeline_ltx2 because of the following error (look up to see its traceback):
cannot import name 'Gemma4UnifiedForConditionalGeneration' from 'transformers'
```

### Proposed scope and validation

Would you accept a PR replacing the architecture-specific `text_encoder` annotation with `transformers.PreTrainedModel` and removing the unused Gemma imports across these five modules?

- `pipeline_ltx2.py`
- `pipeline_ltx2_image2video.py`
- `pipeline_ltx2_condition.py`
- `pipeline_ltx2_ic_lora.py`
- `pipeline_ltx2_hdr_lora.py`

An isolated candidate preserves Diffusers 0.40.0 and Transformers 5.5.0, with no changes to generation logic. Validation so far:

- Original fails with the error above on Windows and WSL; the candidate completes tiny-fixture text-to-video and image-to-video inference, including audio decoding and local save/reload, on both.
- On a separate Transformers 5.17.0 test stack, original and patched pipelines produce bit-for-bit identical video and audio tensors for those same tiny fixtures. The real Gemma4Unified class remains accepted by the annotation.
- All five affected pipeline imports/signature checks and MiniMax-H3/Music-3 modular pipeline imports pass.

The runtime checks use the upstream LTX tiny-component fixture and `hf-internal-testing/tiny-gemma3`. Full LTX 2.3 and MiniMax checkpoint generation have not been tested.

This investigation and candidate were AI-assisted. Following the contribution guidelines, I am opening this issue for maintainer acknowledgment before a PR, and am happy to adjust the approach or add repository-native regression coverage.

### System Info

Reproduced on both:

| | Windows | WSL2 Ubuntu |
|---|---|---|
| Diffusers | 0.40.0 | 0.40.0 |
| Transformers | 5.5.0 | 5.5.0 |
| Python | 3.13.5 | 3.13.12 |
| PyTorch | 2.10.0+cu130 | 2.11.0+cu130 |

Additional WSL environment: huggingface_hub 1.30.0, Accelerate 1.14.0, PEFT 0.18.1, safetensors 0.8.0. NVIDIA RTX 5070 Ti is available; the reproduction is import-only and does not use distributed execution.

Contributor guide

Open the contributing guide

Research direction

Start with the imports and text_encoder annotations in pipeline_ltx2.py, pipeline_ltx2_image2video.py, pipeline_ltx2_condition.py, pipeline_ltx2_ic_lora.py, and pipeline_ltx2_hdr_lora.py. Reproduce the LTX2Pipeline import with Diffusers 0.40.0 and Transformers 5.5.0, then run the affected pipeline import/signature checks and tiny-fixture inference. Done means imports succeed without the unavailable class and generation behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.