Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
039324a
switch to transformers main again./
sayakpaul Jan 14, 2026
c152b18
more
sayakpaul Jan 14, 2026
f8e50fa
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 15, 2026
c5e023f
up
sayakpaul Jan 15, 2026
d0f279c
up
sayakpaul Jan 15, 2026
96f0804
fix group offloading.
sayakpaul Jan 15, 2026
ea90a74
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 15, 2026
37cfcee
attributes
sayakpaul Jan 16, 2026
926db24
up
sayakpaul Jan 16, 2026
cec0209
up
sayakpaul Jan 16, 2026
7b55da8
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 19, 2026
3dcb97c
tie embedding issue.
sayakpaul Jan 19, 2026
084c959
fix t5 stuff for more.
sayakpaul Jan 19, 2026
4ea43ee
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 19, 2026
7f2cd5b
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 19, 2026
62bf2b0
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 20, 2026
3513163
matrix configuration to see differences between 4.57.3 and main failu…
sayakpaul Jan 20, 2026
387befd
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 20, 2026
2fe9f98
change qwen expected slice because of how init is handled in v5.
sayakpaul Jan 20, 2026
e1249d2
same stuff.
sayakpaul Jan 20, 2026
c2d8273
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 23, 2026
a21a6ac
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 23, 2026
5274ffd
up
sayakpaul Jan 23, 2026
515dd06
up
sayakpaul Jan 23, 2026
4dff318
Revert "up"
sayakpaul Jan 23, 2026
0eaa35f
Revert "up"
sayakpaul Jan 23, 2026
6e8e7ba
up
sayakpaul Jan 25, 2026
fefd0f4
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 25, 2026
b4b707e
up
sayakpaul Jan 25, 2026
7a0739c
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 26, 2026
2bee621
fix with peft_format.
sayakpaul Jan 26, 2026
f9bdc09
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 27, 2026
079e0e3
just keep main for easier debugging.
sayakpaul Jan 27, 2026
7eb51e9
resolve conflicts.
sayakpaul Jan 28, 2026
ea815e5
remove torchvision.
sayakpaul Jan 28, 2026
5fefef9
empty
sayakpaul Jan 28, 2026
8568200
up
sayakpaul Jan 28, 2026
c3249d7
Merge branch 'main' into transformers-v5-pr
sayakpaul Jan 29, 2026
10ef226
Merge branch 'main' into transformers-v5-pr
sayakpaul Feb 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/pr_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ jobs:
runner: aws-general-8-plus
image: diffusers/diffusers-pytorch-cpu
report: torch_example_cpu
transformers_version: ["main"]

name: ${{ matrix.config.name }}
name: ${{ matrix.config.name }} (transformers ${{ matrix.transformers_version }})

runs-on:
group: ${{ matrix.config.runner }}
Expand All @@ -115,8 +116,11 @@ jobs:
- name: Install dependencies
run: |
uv pip install -e ".[quality]"
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
if [ "${{ matrix.transformers_version }}" = "main" ]; then
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
else
uv pip uninstall transformers huggingface_hub && uv pip install transformers==${{ matrix.transformers_version }}
fi
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git --no-deps

- name: Environment
Expand Down Expand Up @@ -155,7 +159,7 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: pr_${{ matrix.config.framework }}_${{ matrix.config.report }}_test_reports
name: pr_${{ matrix.config.framework }}_${{ matrix.config.report }}_transformers_${{ matrix.transformers_version }}_test_reports
path: reports

run_staging_tests:
Expand Down Expand Up @@ -220,8 +224,10 @@ jobs:
needs: [check_code_quality, check_repository_consistency]
strategy:
fail-fast: false
matrix:
transformers_version: ["main"]

name: LoRA tests with PEFT main
name: LoRA tests with PEFT main (transformers ${{ matrix.transformers_version }})

runs-on:
group: aws-general-8-plus
Expand All @@ -247,9 +253,12 @@ jobs:
uv pip install -U peft@git+https://github.com/huggingface/peft.git --no-deps
uv pip install -U tokenizers
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git --no-deps
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1

if [ "${{ matrix.transformers_version }}" = "main" ]; then
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
else
uv pip uninstall transformers huggingface_hub && uv pip install transformers==${{ matrix.transformers_version }}
fi

- name: Environment
run: |
python utils/print_env.py
Expand All @@ -275,6 +284,6 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: pr_main_test_reports
name: pr_lora_transformers_${{ matrix.transformers_version }}_test_reports
path: reports

42 changes: 30 additions & 12 deletions .github/workflows/pr_tests_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- "tests/pipelines/test_pipelines_common.py"
- "tests/models/test_modeling_common.py"
- "examples/**/*.py"
- ".github/**.yml"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary. For this PR.

workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -106,13 +107,14 @@ jobs:
path: reports

torch_pipelines_cuda_tests:
name: Torch Pipelines CUDA Tests
name: Torch Pipelines CUDA Tests (transformers ${{ matrix.transformers_version }})
needs: setup_torch_cuda_pipeline_matrix
strategy:
fail-fast: false
max-parallel: 8
matrix:
module: ${{ fromJson(needs.setup_torch_cuda_pipeline_matrix.outputs.pipeline_test_matrix) }}
transformers_version: ["main"]
runs-on:
group: aws-g4dn-2xlarge
container:
Expand All @@ -131,8 +133,12 @@ jobs:
run: |
uv pip install -e ".[quality]"
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
if [ "${{ matrix.transformers_version }}" = "main" ]; then
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
else
uv pip uninstall transformers huggingface_hub && uv pip install transformers==${{ matrix.transformers_version }}
fi


- name: Environment
run: |
Expand Down Expand Up @@ -172,11 +178,11 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: pipeline_${{ matrix.module }}_test_reports
name: pipeline_${{ matrix.module }}_transformers_${{ matrix.transformers_version }}_test_reports
path: reports

torch_cuda_tests:
name: Torch CUDA Tests
name: Torch CUDA Tests (transformers ${{ matrix.transformers_version }})
needs: [check_code_quality, check_repository_consistency]
runs-on:
group: aws-g4dn-2xlarge
Expand All @@ -191,6 +197,7 @@ jobs:
max-parallel: 4
matrix:
module: [models, schedulers, lora, others]
transformers_version: ["main"]
steps:
- name: Checkout diffusers
uses: actions/checkout@v6
Expand All @@ -202,8 +209,12 @@ jobs:
uv pip install -e ".[quality]"
uv pip install peft@git+https://github.com/huggingface/peft.git
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
if [ "${{ matrix.transformers_version }}" = "main" ]; then
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
else
uv pip uninstall transformers huggingface_hub && uv pip install transformers==${{ matrix.transformers_version }}
fi


- name: Environment
run: |
Expand Down Expand Up @@ -241,12 +252,16 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: torch_cuda_test_reports_${{ matrix.module }}
name: torch_cuda_test_reports_${{ matrix.module }}_transformers_${{ matrix.transformers_version }}
path: reports

run_examples_tests:
name: Examples PyTorch CUDA tests on Ubuntu
name: Examples PyTorch CUDA tests on Ubuntu (transformers ${{ matrix.transformers_version }})
needs: [check_code_quality, check_repository_consistency]
strategy:
fail-fast: false
matrix:
transformers_version: ["main"]
runs-on:
group: aws-g4dn-2xlarge

Expand All @@ -264,8 +279,11 @@ jobs:
nvidia-smi
- name: Install dependencies
run: |
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
if [ "${{ matrix.transformers_version }}" = "main" ]; then
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
else
uv pip uninstall transformers huggingface_hub && uv pip install transformers==${{ matrix.transformers_version }}
fi
uv pip install -e ".[quality,training]"

- name: Environment
Expand All @@ -289,6 +307,6 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: examples_test_reports
name: examples_transformers_${{ matrix.transformers_version }}_test_reports
path: reports

4 changes: 4 additions & 0 deletions examples/custom_diffusion/test_custom_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import os
import sys
import tempfile
import unittest

from diffusers.utils import is_transformers_version


sys.path.append("..")
Expand All @@ -30,6 +33,7 @@
logger.addHandler(stream_handler)


@unittest.skipIf(is_transformers_version(">=", "4.57.5"), "Size mismatch")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class CustomDiffusion(ExamplesTestsAccelerate):
def test_custom_diffusion(self):
with tempfile.TemporaryDirectory() as tmpdir:
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/hooks/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
torch.nn.ConvTranspose2d,
torch.nn.ConvTranspose3d,
torch.nn.Linear,
torch.nn.Embedding,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happening because of the way weight loading is done in v5.

# TODO(aryan): look into torch.nn.LayerNorm, torch.nn.GroupNorm later, seems to be causing some issues with CogVideoX
# because of double invocation of the same norm layer in CogVideoXLayerNorm
)
Expand Down
7 changes: 6 additions & 1 deletion src/diffusers/loaders/textual_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
from torch import nn

from ..models.modeling_utils import load_state_dict
from ..utils import _get_model_file, is_accelerate_available, is_transformers_available, logging
from ..utils import (
_get_model_file,
is_accelerate_available,
is_transformers_available,
logging,
)


if is_transformers_available():
Expand Down
3 changes: 3 additions & 0 deletions src/diffusers/pipelines/cosmos/pipeline_cosmos2_5_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ def _get_prompt_embeds(
truncation=True,
padding="max_length",
)
input_ids = (
input_ids["input_ids"] if not isinstance(input_ids, list) and "input_ids" in input_ids else input_ids
)
Comment on lines +290 to +292
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input_ids = torch.LongTensor(input_ids)
input_ids_batch.append(input_ids)

Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/pipelines/kandinsky/text_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def __init__(self, config, *args, **kwargs):
self.LinearTransformation = torch.nn.Linear(
in_features=config.transformerDimensions, out_features=config.numDims
)
if hasattr(self, "post_init"):
self.post_init()

def forward(self, input_ids, attention_mask):
embs = self.transformer(input_ids=input_ids, attention_mask=attention_mask)[0]
Expand Down
5 changes: 4 additions & 1 deletion src/diffusers/pipelines/kolors/text_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,9 @@ def __init__(self, config: ChatGLMConfig, device=None, empty_init=True):
self.prefix_encoder = PrefixEncoder(config)
self.dropout = torch.nn.Dropout(0.1)

if hasattr(self, "post_init"):
self.post_init()

def get_input_embeddings(self):
return self.embedding.word_embeddings

Expand Down Expand Up @@ -811,7 +814,7 @@ def forward(
output_hidden_states = (
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
)
use_cache = use_cache if use_cache is not None else self.config.use_cache
use_cache = use_cache if use_cache is not None else getattr(self.config, "use_cache", None)
return_dict = return_dict if return_dict is not None else self.config.use_return_dict

batch_size, seq_length = input_ids.shape
Expand Down
6 changes: 6 additions & 0 deletions src/diffusers/pipelines/pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def is_saveable_module(name, value):
save_method_accept_safe = "safe_serialization" in save_method_signature.parameters
save_method_accept_variant = "variant" in save_method_signature.parameters
save_method_accept_max_shard_size = "max_shard_size" in save_method_signature.parameters
save_method_accept_peft_format = "save_peft_format" in save_method_signature.parameters

save_kwargs = {}
if save_method_accept_safe:
Expand All @@ -349,6 +350,11 @@ def is_saveable_module(name, value):
if save_method_accept_max_shard_size and max_shard_size is not None:
# max_shard_size is expected to not be None in ModelMixin
save_kwargs["max_shard_size"] = max_shard_size
if save_method_accept_peft_format:
# Set save_peft_format=False for transformers>=5.0.0 compatibility
# In transformers 5.0.0+, the default save_peft_format=True adds "base_model.model" prefix
# to adapter keys, but from_pretrained expects keys without this prefix
save_kwargs["save_peft_format"] = False

save_method(os.path.join(save_directory, pipeline_component_name), **save_kwargs)

Expand Down
8 changes: 6 additions & 2 deletions tests/models/test_models_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ def test_load_from_config_diffusers_with_subfolder(self, mock_load_config):
side_effect=[EnvironmentError("File not found"), {"model_type": "clip_text_model"}],
)
def test_load_from_config_transformers_with_subfolder(self, mock_load_config):
model = AutoModel.from_pretrained("hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder")
model = AutoModel.from_pretrained(
"hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder", use_safetensors=False
)
Comment on lines +23 to +25
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert isinstance(model, CLIPTextModel)

def test_load_from_config_without_subfolder(self):
model = AutoModel.from_pretrained("hf-internal-testing/tiny-random-longformer")
assert isinstance(model, LongformerModel)

def test_load_from_model_index(self):
model = AutoModel.from_pretrained("hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder")
model = AutoModel.from_pretrained(
"hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder", use_safetensors=False
)
assert isinstance(model, CLIPTextModel)
5 changes: 3 additions & 2 deletions tests/pipelines/bria/test_pipeline_bria.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import numpy as np
import torch
from huggingface_hub import hf_hub_download
from transformers import T5EncoderModel, T5TokenizerFast
from transformers import AutoConfig, T5EncoderModel, T5TokenizerFast

from diffusers import (
AutoencoderKL,
Expand Down Expand Up @@ -89,7 +89,8 @@ def get_dummy_components(self):
scheduler = FlowMatchEulerDiscreteScheduler()

torch.manual_seed(0)
text_encoder = T5EncoderModel.from_pretrained("hf-internal-testing/tiny-random-t5")
config = AutoConfig.from_pretrained("hf-internal-testing/tiny-random-t5")
text_encoder = T5EncoderModel(config)
Comment on lines +92 to +93
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokenizer = T5TokenizerFast.from_pretrained("hf-internal-testing/tiny-random-t5")

components = {
Expand Down
5 changes: 3 additions & 2 deletions tests/pipelines/chroma/test_pipeline_chroma.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np
import torch
from transformers import AutoTokenizer, T5EncoderModel
from transformers import AutoConfig, AutoTokenizer, T5EncoderModel

from diffusers import AutoencoderKL, ChromaPipeline, ChromaTransformer2DModel, FlowMatchEulerDiscreteScheduler

Expand Down Expand Up @@ -41,7 +41,8 @@ def get_dummy_components(self, num_layers: int = 1, num_single_layers: int = 1):
)

torch.manual_seed(0)
text_encoder = T5EncoderModel.from_pretrained("hf-internal-testing/tiny-random-t5")
config = AutoConfig.from_pretrained("hf-internal-testing/tiny-random-t5")
text_encoder = T5EncoderModel(config)

tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-t5")

Expand Down
5 changes: 3 additions & 2 deletions tests/pipelines/chroma/test_pipeline_chroma_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np
import torch
from transformers import AutoTokenizer, T5EncoderModel
from transformers import AutoConfig, AutoTokenizer, T5EncoderModel

from diffusers import AutoencoderKL, ChromaImg2ImgPipeline, ChromaTransformer2DModel, FlowMatchEulerDiscreteScheduler

Expand Down Expand Up @@ -42,7 +42,8 @@ def get_dummy_components(self, num_layers: int = 1, num_single_layers: int = 1):
)

torch.manual_seed(0)
text_encoder = T5EncoderModel.from_pretrained("hf-internal-testing/tiny-random-t5")
config = AutoConfig.from_pretrained("hf-internal-testing/tiny-random-t5")
text_encoder = T5EncoderModel(config)

tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-t5")

Expand Down
4 changes: 3 additions & 1 deletion tests/pipelines/chronoedit/test_chronoedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import torch
from PIL import Image
from transformers import (
AutoConfig,
AutoTokenizer,
CLIPImageProcessor,
CLIPVisionConfig,
Expand Down Expand Up @@ -71,7 +72,8 @@ def get_dummy_components(self):
torch.manual_seed(0)
# TODO: impl FlowDPMSolverMultistepScheduler
scheduler = FlowMatchEulerDiscreteScheduler(shift=7.0)
text_encoder = T5EncoderModel.from_pretrained("hf-internal-testing/tiny-random-t5")
config = AutoConfig.from_pretrained("hf-internal-testing/tiny-random-t5")
text_encoder = T5EncoderModel(config)
tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-t5")

torch.manual_seed(0)
Expand Down
5 changes: 3 additions & 2 deletions tests/pipelines/cogvideo/test_cogvideox.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import numpy as np
import torch
from transformers import AutoTokenizer, T5EncoderModel
from transformers import AutoConfig, AutoTokenizer, T5EncoderModel

from diffusers import AutoencoderKLCogVideoX, CogVideoXPipeline, CogVideoXTransformer3DModel, DDIMScheduler

Expand Down Expand Up @@ -117,7 +117,8 @@ def get_dummy_components(self, num_layers: int = 1):

torch.manual_seed(0)
scheduler = DDIMScheduler()
text_encoder = T5EncoderModel.from_pretrained("hf-internal-testing/tiny-random-t5")
config = AutoConfig.from_pretrained("hf-internal-testing/tiny-random-t5")
text_encoder = T5EncoderModel(config)
tokenizer = AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-t5")

components = {
Expand Down
Loading
Loading