Skip to content

Commit 0180f9e

Browse files
authored
Merge branch 'main' into tests-encode-prompt
2 parents 8a1d84a + a26d570 commit 0180f9e

File tree

158 files changed

+1877
-170
lines changed

Some content is hidden

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

158 files changed

+1877
-170
lines changed

.github/workflows/nightly_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ jobs:
272272
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
273273
-s -v -k "not Flax and not Onnx" \
274274
--make-reports=tests_torch_minimum_version_cuda \
275-
tests/models/test_modelling_common.py \
275+
tests/models/test_modeling_common.py \
276276
tests/pipelines/test_pipelines_common.py \
277277
tests/pipelines/test_pipeline_utils.py \
278278
tests/pipelines/test_pipelines.py \

.github/workflows/pr_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ jobs:
266266
# TODO (sayakpaul, DN6): revisit `--no-deps`
267267
python -m pip install -U peft@git+https://github.com/huggingface/peft.git --no-deps
268268
python -m uv pip install -U transformers@git+https://github.com/huggingface/transformers.git --no-deps
269+
python -m uv pip install -U tokenizers
269270
pip uninstall accelerate -y && python -m uv pip install -U accelerate@git+https://github.com/huggingface/accelerate.git --no-deps
270271
271272
- name: Environment

.github/workflows/release_tests_fast.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ jobs:
193193
python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile \
194194
-s -v -k "not Flax and not Onnx" \
195195
--make-reports=tests_torch_minimum_cuda \
196-
tests/models/test_modelling_common.py \
196+
tests/models/test_modeling_common.py \
197197
tests/pipelines/test_pipelines_common.py \
198198
tests/pipelines/test_pipeline_utils.py \
199199
tests/pipelines/test_pipelines.py \

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,33 @@ image = pipeline(prompt).images[0]
6262
image.save("auraflow.png")
6363
```
6464

65+
Loading [GGUF checkpoints](https://huggingface.co/docs/diffusers/quantization/gguf) are also supported:
66+
67+
```py
68+
import torch
69+
from diffusers import (
70+
AuraFlowPipeline,
71+
GGUFQuantizationConfig,
72+
AuraFlowTransformer2DModel,
73+
)
74+
75+
transformer = AuraFlowTransformer2DModel.from_single_file(
76+
"https://huggingface.co/city96/AuraFlow-v0.3-gguf/blob/main/aura_flow_0.3-Q2_K.gguf",
77+
quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
78+
torch_dtype=torch.bfloat16,
79+
)
80+
81+
pipeline = AuraFlowPipeline.from_pretrained(
82+
"fal/AuraFlow-v0.3",
83+
transformer=transformer,
84+
torch_dtype=torch.bfloat16,
85+
)
86+
87+
prompt = "a cute pony in a field of flowers"
88+
image = pipeline(prompt).images[0]
89+
image.save("auraflow.png")
90+
```
91+
6592
## AuraFlowPipeline
6693

6794
[[autodoc]] AuraFlowPipeline

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Refer to the [Quantization](../../quantization/overview) overview to learn more
5959
```py
6060
import torch
6161
from diffusers import BitsAndBytesConfig as DiffusersBitsAndBytesConfig, SanaTransformer2DModel, SanaPipeline
62-
from transformers import BitsAndBytesConfig as BitsAndBytesConfig, AutoModelForCausalLM
62+
from transformers import BitsAndBytesConfig as BitsAndBytesConfig, AutoModel
6363

6464
quant_config = BitsAndBytesConfig(load_in_8bit=True)
65-
text_encoder_8bit = AutoModelForCausalLM.from_pretrained(
65+
text_encoder_8bit = AutoModel.from_pretrained(
6666
"Efficient-Large-Model/Sana_1600M_1024px_diffusers",
6767
subfolder="text_encoder",
6868
quantization_config=quant_config,

examples/community/README.md

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

examples/community/lpw_stable_diffusion_xl.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,9 @@ def encode_prompt(
827827
)
828828

829829
# We are only ALWAYS interested in the pooled output of the final text encoder
830-
pooled_prompt_embeds = prompt_embeds[0]
830+
if pooled_prompt_embeds is None and prompt_embeds[0].ndim == 2:
831+
pooled_prompt_embeds = prompt_embeds[0]
832+
831833
prompt_embeds = prompt_embeds.hidden_states[-2]
832834

833835
prompt_embeds_list.append(prompt_embeds)
@@ -879,7 +881,8 @@ def encode_prompt(
879881
output_hidden_states=True,
880882
)
881883
# We are only ALWAYS interested in the pooled output of the final text encoder
882-
negative_pooled_prompt_embeds = negative_prompt_embeds[0]
884+
if negative_pooled_prompt_embeds is None and negative_prompt_embeds[0].ndim == 2:
885+
negative_pooled_prompt_embeds = negative_prompt_embeds[0]
883886
negative_prompt_embeds = negative_prompt_embeds.hidden_states[-2]
884887

885888
negative_prompt_embeds_list.append(negative_prompt_embeds)

examples/community/pipeline_demofusion_sdxl.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ def encode_prompt(
290290
)
291291

292292
# We are only ALWAYS interested in the pooled output of the final text encoder
293-
pooled_prompt_embeds = prompt_embeds[0]
293+
if pooled_prompt_embeds is None and prompt_embeds[0].ndim == 2:
294+
pooled_prompt_embeds = prompt_embeds[0]
295+
294296
prompt_embeds = prompt_embeds.hidden_states[-2]
295297

296298
prompt_embeds_list.append(prompt_embeds)
@@ -342,7 +344,8 @@ def encode_prompt(
342344
output_hidden_states=True,
343345
)
344346
# We are only ALWAYS interested in the pooled output of the final text encoder
345-
negative_pooled_prompt_embeds = negative_prompt_embeds[0]
347+
if negative_pooled_prompt_embeds is None and negative_prompt_embeds[0].ndim == 2:
348+
negative_pooled_prompt_embeds = negative_prompt_embeds[0]
346349
negative_prompt_embeds = negative_prompt_embeds.hidden_states[-2]
347350

348351
negative_prompt_embeds_list.append(negative_prompt_embeds)

examples/community/pipeline_sdxl_style_aligned.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,9 @@ def encode_prompt(
628628
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)
629629

630630
# We are only ALWAYS interested in the pooled output of the final text encoder
631-
pooled_prompt_embeds = prompt_embeds[0]
631+
if pooled_prompt_embeds is None and prompt_embeds[0].ndim == 2:
632+
pooled_prompt_embeds = prompt_embeds[0]
633+
632634
if clip_skip is None:
633635
prompt_embeds = prompt_embeds.hidden_states[-2]
634636
else:
@@ -688,7 +690,8 @@ def encode_prompt(
688690
output_hidden_states=True,
689691
)
690692
# We are only ALWAYS interested in the pooled output of the final text encoder
691-
negative_pooled_prompt_embeds = negative_prompt_embeds[0]
693+
if negative_pooled_prompt_embeds is None and negative_prompt_embeds[0].ndim == 2:
694+
negative_pooled_prompt_embeds = negative_prompt_embeds[0]
692695
negative_prompt_embeds = negative_prompt_embeds.hidden_states[-2]
693696

694697
negative_prompt_embeds_list.append(negative_prompt_embeds)

examples/community/pipeline_stable_diffusion_xl_controlnet_adapter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ def encode_prompt(
359359
prompt_embeds = text_encoder(text_input_ids.to(device), output_hidden_states=True)
360360

361361
# We are only ALWAYS interested in the pooled output of the final text encoder
362-
pooled_prompt_embeds = prompt_embeds[0]
362+
if pooled_prompt_embeds is None and prompt_embeds[0].ndim == 2:
363+
pooled_prompt_embeds = prompt_embeds[0]
364+
363365
if clip_skip is None:
364366
prompt_embeds = prompt_embeds.hidden_states[-2]
365367
else:
@@ -419,7 +421,8 @@ def encode_prompt(
419421
output_hidden_states=True,
420422
)
421423
# We are only ALWAYS interested in the pooled output of the final text encoder
422-
negative_pooled_prompt_embeds = negative_prompt_embeds[0]
424+
if negative_pooled_prompt_embeds is None and negative_prompt_embeds[0].ndim == 2:
425+
negative_pooled_prompt_embeds = negative_prompt_embeds[0]
423426
negative_prompt_embeds = negative_prompt_embeds.hidden_states[-2]
424427

425428
negative_prompt_embeds_list.append(negative_prompt_embeds)

0 commit comments

Comments
 (0)