Skip to content

Commit 9a7f643

Browse files
authored
Merge branch 'main' into diff-d2
2 parents 44ef84f + 5910a1c commit 9a7f643

File tree

109 files changed

+1366
-606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1366
-606
lines changed

.github/workflows/pr_tests.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ jobs:
9292
runner: aws-general-8-plus
9393
image: diffusers/diffusers-pytorch-cpu
9494
report: torch_example_cpu
95-
9695
name: ${{ matrix.config.name }}
9796

9897
runs-on:
@@ -115,8 +114,7 @@ jobs:
115114
- name: Install dependencies
116115
run: |
117116
uv pip install -e ".[quality]"
118-
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
119-
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
117+
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
120118
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git --no-deps
121119
122120
- name: Environment
@@ -218,8 +216,6 @@ jobs:
218216

219217
run_lora_tests:
220218
needs: [check_code_quality, check_repository_consistency]
221-
strategy:
222-
fail-fast: false
223219

224220
name: LoRA tests with PEFT main
225221

@@ -247,9 +243,8 @@ jobs:
247243
uv pip install -U peft@git+https://github.com/huggingface/peft.git --no-deps
248244
uv pip install -U tokenizers
249245
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git --no-deps
250-
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
251-
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
252-
246+
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
247+
253248
- name: Environment
254249
run: |
255250
python utils/print_env.py
@@ -275,6 +270,6 @@ jobs:
275270
if: ${{ always() }}
276271
uses: actions/upload-artifact@v6
277272
with:
278-
name: pr_main_test_reports
273+
name: pr_lora_test_reports
279274
path: reports
280275

.github/workflows/pr_tests_gpu.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ jobs:
131131
run: |
132132
uv pip install -e ".[quality]"
133133
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git
134-
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
135-
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
134+
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
136135
137136
- name: Environment
138137
run: |
@@ -202,8 +201,7 @@ jobs:
202201
uv pip install -e ".[quality]"
203202
uv pip install peft@git+https://github.com/huggingface/peft.git
204203
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git
205-
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
206-
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
204+
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
207205
208206
- name: Environment
209207
run: |
@@ -264,8 +262,7 @@ jobs:
264262
nvidia-smi
265263
- name: Install dependencies
266264
run: |
267-
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
268-
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
265+
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
269266
uv pip install -e ".[quality,training]"
270267
271268
- name: Environment

.github/workflows/push_tests.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ jobs:
7676
run: |
7777
uv pip install -e ".[quality]"
7878
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git
79-
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
80-
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
79+
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
8180
- name: Environment
8281
run: |
8382
python utils/print_env.py
@@ -129,8 +128,7 @@ jobs:
129128
uv pip install -e ".[quality]"
130129
uv pip install peft@git+https://github.com/huggingface/peft.git
131130
uv pip uninstall accelerate && uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git
132-
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
133-
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
131+
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
134132
135133
- name: Environment
136134
run: |
@@ -182,8 +180,7 @@ jobs:
182180
- name: Install dependencies
183181
run: |
184182
uv pip install -e ".[quality,training]"
185-
#uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
186-
uv pip uninstall transformers huggingface_hub && uv pip install transformers==4.57.1
183+
uv pip uninstall transformers huggingface_hub && uv pip install --prerelease allow -U transformers@git+https://github.com/huggingface/transformers.git
187184
- name: Environment
188185
run: |
189186
python utils/print_env.py

docs/source/en/api/pipelines/cosmos.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ output = pipe(
4646
output.save("output.png")
4747
```
4848

49+
## Cosmos2_5_TransferPipeline
50+
51+
[[autodoc]] Cosmos2_5_TransferPipeline
52+
- all
53+
- __call__
54+
55+
56+
## Cosmos2_5_PredictBasePipeline
57+
58+
[[autodoc]] Cosmos2_5_PredictBasePipeline
59+
- all
60+
- __call__
61+
62+
4963
## CosmosTextToWorldPipeline
5064

5165
[[autodoc]] CosmosTextToWorldPipeline
@@ -70,12 +84,6 @@ output.save("output.png")
7084
- all
7185
- __call__
7286

73-
## Cosmos2_5_PredictBasePipeline
74-
75-
[[autodoc]] Cosmos2_5_PredictBasePipeline
76-
- all
77-
- __call__
78-
7987
## CosmosPipelineOutput
8088

8189
[[autodoc]] pipelines.cosmos.pipeline_output.CosmosPipelineOutput

docs/source/en/training/distributed_inference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ if __name__ == "__main__":
111111
Call `torchrun` to run the inference script and use the `--nproc_per_node` argument to set the number of GPUs to use.
112112

113113
```bash
114-
torchrun run_distributed.py --nproc_per_node=2
114+
torchrun --nproc_per_node=2 run_distributed.py
115115
```
116116

117117
## device_map

examples/custom_diffusion/test_custom_diffusion.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import os
1818
import sys
1919
import tempfile
20+
import unittest
21+
22+
from diffusers.utils import is_transformers_version
2023

2124

2225
sys.path.append("..")
@@ -30,6 +33,7 @@
3033
logger.addHandler(stream_handler)
3134

3235

36+
@unittest.skipIf(is_transformers_version(">=", "4.57.5"), "Size mismatch")
3337
class CustomDiffusion(ExamplesTestsAccelerate):
3438
def test_custom_diffusion(self):
3539
with tempfile.TemporaryDirectory() as tmpdir:

scripts/convert_cosmos_to_diffusers.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,15 @@
9494
--transformer_type Cosmos-2.5-Transfer-General-2B \
9595
--transformer_ckpt_path $transformer_ckpt_path \
9696
--vae_type wan2.1 \
97-
--output_path converted/transfer/2b/general/depth \
97+
--output_path converted/transfer/2b/general/depth/pipeline \
9898
--save_pipeline
9999
100+
python scripts/convert_cosmos_to_diffusers.py \
101+
--transformer_type Cosmos-2.5-Transfer-General-2B \
102+
--transformer_ckpt_path $transformer_ckpt_path \
103+
--vae_type wan2.1 \
104+
--output_path converted/transfer/2b/general/depth/models
105+
100106
# edge
101107
transformer_ckpt_path=~/.cache/huggingface/hub/models--nvidia--Cosmos-Transfer2.5-2B/snapshots/eb5325b77d358944da58a690157dd2b8071bbf85/general/edge/61f5694b-0ad5-4ecd-8ad7-c8545627d125_ema_bf16.pt
102108
@@ -120,18 +126,30 @@
120126
--transformer_type Cosmos-2.5-Transfer-General-2B \
121127
--transformer_ckpt_path $transformer_ckpt_path \
122128
--vae_type wan2.1 \
123-
--output_path converted/transfer/2b/general/blur \
129+
--output_path converted/transfer/2b/general/blur/pipeline \
124130
--save_pipeline
125131
132+
python scripts/convert_cosmos_to_diffusers.py \
133+
--transformer_type Cosmos-2.5-Transfer-General-2B \
134+
--transformer_ckpt_path $transformer_ckpt_path \
135+
--vae_type wan2.1 \
136+
--output_path converted/transfer/2b/general/blur/models
137+
126138
# seg
127139
transformer_ckpt_path=~/.cache/huggingface/hub/models--nvidia--Cosmos-Transfer2.5-2B/snapshots/eb5325b77d358944da58a690157dd2b8071bbf85/general/seg/5136ef49-6d8d-42e8-8abf-7dac722a304a_ema_bf16.pt
128140
129141
python scripts/convert_cosmos_to_diffusers.py \
130142
--transformer_type Cosmos-2.5-Transfer-General-2B \
131143
--transformer_ckpt_path $transformer_ckpt_path \
132144
--vae_type wan2.1 \
133-
--output_path converted/transfer/2b/general/seg \
145+
--output_path converted/transfer/2b/general/seg/pipeline \
134146
--save_pipeline
147+
148+
python scripts/convert_cosmos_to_diffusers.py \
149+
--transformer_type Cosmos-2.5-Transfer-General-2B \
150+
--transformer_ckpt_path $transformer_ckpt_path \
151+
--vae_type wan2.1 \
152+
--output_path converted/transfer/2b/general/seg/models
135153
```
136154
"""
137155

src/diffusers/hooks/_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
torch.nn.ConvTranspose2d,
4949
torch.nn.ConvTranspose3d,
5050
torch.nn.Linear,
51+
torch.nn.Embedding,
5152
# TODO(aryan): look into torch.nn.LayerNorm, torch.nn.GroupNorm later, seems to be causing some issues with CogVideoX
5253
# because of double invocation of the same norm layer in CogVideoXLayerNorm
5354
)

src/diffusers/loaders/lora_conversion_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ def _convert(original_key, diffusers_key, state_dict, new_state_dict):
856856
)
857857
state_dict = {k: v for k, v in state_dict.items() if not k.startswith("text_encoders.t5xxl.transformer.")}
858858

859-
has_diffb = any("diff_b" in k and k.startswith(("lora_unet_", "lora_te_")) for k in state_dict)
859+
has_diffb = any("diff_b" in k and k.startswith(("lora_unet_", "lora_te_", "lora_te1_")) for k in state_dict)
860860
if has_diffb:
861861
zero_status_diff_b = state_dict_all_zero(state_dict, ".diff_b")
862862
if zero_status_diff_b:
@@ -895,7 +895,7 @@ def _convert(original_key, diffusers_key, state_dict, new_state_dict):
895895
state_dict = {
896896
_custom_replace(k, limit_substrings): v
897897
for k, v in state_dict.items()
898-
if k.startswith(("lora_unet_", "lora_te_"))
898+
if k.startswith(("lora_unet_", "lora_te_", "lora_te1_"))
899899
}
900900

901901
if any("text_projection" in k for k in state_dict):

src/diffusers/loaders/lora_pipeline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5472,6 +5472,10 @@ def lora_state_dict(
54725472
logger.warning(warn_msg)
54735473
state_dict = {k: v for k, v in state_dict.items() if "dora_scale" not in k}
54745474

5475+
is_peft_format = any(k.startswith("base_model.model.") for k in state_dict)
5476+
if is_peft_format:
5477+
state_dict = {k.replace("base_model.model.", "diffusion_model."): v for k, v in state_dict.items()}
5478+
54755479
is_ai_toolkit = any(k.startswith("diffusion_model.") for k in state_dict)
54765480
if is_ai_toolkit:
54775481
state_dict = _convert_non_diffusers_flux2_lora_to_diffusers(state_dict)

0 commit comments

Comments
 (0)