Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6f8e01b
towards krea2 modular
Cedric-Perauer Jun 27, 2026
2bae576
add test cases
Cedric-Perauer Jun 28, 2026
30c5138
self-review fixes: test model id to hf internal, guider change
Cedric-Perauer Jun 28, 2026
7450dc4
remove pnd
Cedric-Perauer Jun 28, 2026
4e4da7f
modular autodoc
Cedric-Perauer Jun 28, 2026
4da8d49
modular autodoc
Cedric-Perauer Jun 28, 2026
bc0c912
Merge branch 'main' into master
Cedric-Perauer Jun 28, 2026
689ee82
Merge branch 'main' into master
Cedric-Perauer Jun 29, 2026
d235700
Merge branch 'main' into master
Cedric-Perauer Jul 2, 2026
5a609ca
Merge branch 'main' into master
Cedric-Perauer Jul 3, 2026
3de62bd
Merge branch 'main' into master
Cedric-Perauer Jul 4, 2026
988beb9
Merge branch 'main' into master
Cedric-Perauer Jul 6, 2026
8022f8e
Merge branch 'main' into master
Cedric-Perauer Jul 8, 2026
93f59d9
Update src/diffusers/modular_pipelines/krea2/modular_blocks_krea2.py
Cedric-Perauer Jul 9, 2026
e6e288f
Update src/diffusers/modular_pipelines/krea2/before_denoise.py
Cedric-Perauer Jul 9, 2026
afd27d3
Update docs/source/en/api/pipelines/krea2.md
Cedric-Perauer Jul 9, 2026
3de7fad
input params, dim multiple of scale factor * patch
Cedric-Perauer Jul 9, 2026
e3b07ab
docs for krea2 turbo modular
Cedric-Perauer Jul 9, 2026
909bcc5
docs fix
Cedric-Perauer Jul 9, 2026
07ccbb2
Merge branch 'main' into master
dg845 Jul 10, 2026
ec123ba
Merge branch 'main' into master
Cedric-Perauer Jul 12, 2026
debb4dd
Merge branch 'main' into master
dg845 Jul 15, 2026
0eeca0d
Update tests/modular_pipelines/krea2/test_modular_pipeline_krea2.py
Cedric-Perauer Jul 15, 2026
a21b285
Update src/diffusers/modular_pipelines/krea2/before_denoise.py
Cedric-Perauer Jul 15, 2026
421d212
Merge branch 'main' into master
Cedric-Perauer Jul 15, 2026
2750680
Merge branch 'main' into master
Cedric-Perauer Jul 16, 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
81 changes: 80 additions & 1 deletion docs/source/en/api/pipelines/krea2.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import torch
from diffusers import Krea2Pipeline

# Load from a local directory produced by the Krea 2 conversion (no hub repo yet).
pipe = Krea2Pipeline.from_pretrained("path/to/krea2-diffusers", torch_dtype=torch.bfloat16)
pipe = Krea2Pipeline.from_pretrained("krea/Krea-2-Raw", torch_dtype=torch.bfloat16)
pipe.to("cuda")

prompt = "a fox in the snow"
Expand All @@ -50,6 +50,27 @@ image = pipe(
image.save("krea2.png")
```

We additionally provide an example for using Krea2 Turbo :

```python
import torch
from diffusers import Krea2Pipeline

pipe = Krea2Pipeline.from_pretrained("krea/Krea-2-Turbo", torch_dtype=torch.bfloat16)
pipe.to("cuda")

image = pipe(
"a fox in the snow",
height=1024,
width=1024,
num_inference_steps=8,
guidance_scale=0.0,
generator=torch.Generator("cuda").manual_seed(0),
).images[0]
image.save("krea2_turbo.png")
```


## Krea2Pipeline

[[autodoc]] Krea2Pipeline
Expand All @@ -59,3 +80,61 @@ image.save("krea2.png")
## Krea2PipelineOutput

[[autodoc]] pipelines.krea2.pipeline_output.Krea2PipelineOutput

## Modular

Krea 2 is also available as a [modular pipeline](../../modular_diffusers/overview). Classifier-free guidance is
configured through the `guider` component rather than a `guidance_scale` call argument. Krea 2 uses cond-anchored CFG,
which is [`ClassifierFreeGuidance`] with `use_original_formulation=True`; a scale of `0.0` disables guidance (the TDM
checkpoint).

```python
import torch
from diffusers import ClassifierFreeGuidance, ModularPipeline

pipe = ModularPipeline.from_pretrained("krea/Krea-2-Raw")
pipe.load_components(torch_dtype=torch.bfloat16)
pipe.to("cuda")

pipe.update_components(guider=ClassifierFreeGuidance(guidance_scale=4.5, use_original_formulation=True))
Comment thread
Cedric-Perauer marked this conversation as resolved.

image = pipe(
prompt="a fox in the snow",
height=1024,
width=1024,
num_inference_steps=28,
generator=torch.Generator("cuda").manual_seed(0),
).images[0]
image.save("krea2.png")
```

We additionally provide an example for using Krea2 Turbo. The distilled checkpoint disables guidance by

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ohh i think turbo should have its own set of blocks that it maps to, it is a different checkpoint

this way the distilled krea should not accept negative prompt and it should have guider disabled by default
you can take a look at how flux2 klein is implemented in relation to the klein base
https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux2/modular_blocks_flux2_klein.py

setting the `guider` scale to `0.0` and samples in a few steps:

```python
import torch
from diffusers import ClassifierFreeGuidance, ModularPipeline

pipe = ModularPipeline.from_pretrained("krea/Krea-2-Turbo")
pipe.load_components(torch_dtype=torch.bfloat16)
pipe.to("cuda")

pipe.update_components(guider=ClassifierFreeGuidance(guidance_scale=0.0, use_original_formulation=True))

image = pipe(
prompt="a fox in the snow",
height=1024,
width=1024,
num_inference_steps=8,
generator=torch.Generator("cuda").manual_seed(0),
).images[0]
image.save("krea2_turbo.png")
```

## Krea2ModularPipeline

[[autodoc]] Krea2ModularPipeline

## Krea2AutoBlocks

[[autodoc]] Krea2AutoBlocks
4 changes: 4 additions & 0 deletions src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@
"HunyuanVideo15ModularPipeline",
"Ideogram4AutoBlocks",
"Ideogram4ModularPipeline",
"Krea2AutoBlocks",
"Krea2ModularPipeline",
"LTXAutoBlocks",
"LTXModularPipeline",
"QwenImageAutoBlocks",
Expand Down Expand Up @@ -1373,6 +1375,8 @@
HunyuanVideo15ModularPipeline,
Ideogram4AutoBlocks,
Ideogram4ModularPipeline,
Krea2AutoBlocks,
Krea2ModularPipeline,
LTXAutoBlocks,
LTXModularPipeline,
QwenImageAutoBlocks,
Expand Down
8 changes: 8 additions & 0 deletions src/diffusers/modular_pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
"Ideogram4AutoBlocks",
"Ideogram4ModularPipeline",
]
_import_structure["krea2"] = [
"Krea2AutoBlocks",
"Krea2ModularPipeline",
]
_import_structure["qwenimage"] = [
"QwenImageAutoBlocks",
"QwenImageModularPipeline",
Expand Down Expand Up @@ -155,6 +159,10 @@
Ideogram4AutoBlocks,
Ideogram4ModularPipeline,
)
from .krea2 import (
Krea2AutoBlocks,
Krea2ModularPipeline,
)
from .ltx import LTXAutoBlocks, LTXModularPipeline
from .modular_pipeline import (
AutoPipelineBlocks,
Expand Down
47 changes: 47 additions & 0 deletions src/diffusers/modular_pipelines/krea2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from typing import TYPE_CHECKING

from ...utils import (
DIFFUSERS_SLOW_IMPORT,
OptionalDependencyNotAvailable,
_LazyModule,
get_objects_from_module,
is_torch_available,
is_transformers_available,
)


_dummy_objects = {}
_import_structure = {}

try:
if not (is_transformers_available() and is_torch_available()):
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
from ...utils import dummy_torch_and_transformers_objects # noqa F403

_dummy_objects.update(get_objects_from_module(dummy_torch_and_transformers_objects))
else:
_import_structure["modular_blocks_krea2"] = ["Krea2AutoBlocks"]
_import_structure["modular_pipeline"] = ["Krea2ModularPipeline"]

if TYPE_CHECKING or DIFFUSERS_SLOW_IMPORT:
try:
if not (is_transformers_available() and is_torch_available()):
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
from ...utils.dummy_torch_and_transformers_objects import * # noqa F403
else:
from .modular_blocks_krea2 import Krea2AutoBlocks
from .modular_pipeline import Krea2ModularPipeline
else:
import sys

sys.modules[__name__] = _LazyModule(
__name__,
globals()["__file__"],
_import_structure,
module_spec=__spec__,
)

for name, value in _dummy_objects.items():
setattr(sys.modules[__name__], name, value)
Loading
Loading