Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/maxdiffusion/configs/base_flux2klein.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ max_sequence_length: 512
time_shift: True
base_shift: 0.5
max_shift: 1.15
image_paths: []
use_base2_exp: True


unet_checkpoint: ''
Expand Down
2 changes: 2 additions & 0 deletions src/maxdiffusion/configs/base_flux2klein_9B.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ max_sequence_length: 512
time_shift: True
base_shift: 0.5
max_shift: 1.15
image_paths: []
use_base2_exp: True


unet_checkpoint: ''
Expand Down
173 changes: 112 additions & 61 deletions src/maxdiffusion/generate_flux2klein.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/maxdiffusion/models/embeddings_flax.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def __init__(
weights_dtype=weights_dtype,
)

if pooled_projection_dim > 0:
if pooled_projection_dim is not None and pooled_projection_dim > 0:
self.pooled_embedder = NNXPixArtAlphaTextProjection(
rngs=rngs,
in_features=pooled_projection_dim,
Expand Down Expand Up @@ -643,7 +643,7 @@ def __call__(
else:
time_guidance_emb = timestep_emb

if pooled_projection is not None and self.pooled_projection_dim > 0:
if pooled_projection is not None and self.pooled_projection_dim is not None and self.pooled_projection_dim > 0:
pooled_projections = self.pooled_embedder(pooled_projection)
conditioning = time_guidance_emb + pooled_projections
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ def __init__(
qkv_bias: bool = False,
ulysses_shards: int = -1,
ulysses_attention_chunks: int = 1,
use_base2_exp: bool = False,
):
self.heads = heads
self.dim_head = dim_head
Expand All @@ -1352,6 +1353,7 @@ def __init__(
split_head_dim=False,
ulysses_shards=ulysses_shards,
ulysses_attention_chunks=ulysses_attention_chunks,
use_base2_exp=use_base2_exp,
)

kernel_axes = ("embed", "heads")
Expand Down Expand Up @@ -1504,6 +1506,7 @@ def __init__(
weights_dtype: jnp.dtype = jnp.float32,
ulysses_shards: int = -1,
ulysses_attention_chunks: int = 1,
use_base2_exp: bool = False,
):
self.num_attention_heads = num_attention_heads
self.attention_head_dim = attention_head_dim
Expand All @@ -1522,6 +1525,7 @@ def __init__(
split_head_dim=False,
ulysses_shards=ulysses_shards,
ulysses_attention_chunks=ulysses_attention_chunks,
use_base2_exp=use_base2_exp,
)
self.query_norm = nnx.RMSNorm(
num_features=attention_head_dim,
Expand Down Expand Up @@ -1560,6 +1564,7 @@ def __init__(
qkv_bias: bool = False,
ulysses_shards: int = -1,
ulysses_attention_chunks: int = 1,
use_base2_exp: bool = False,
):
self.dim = dim
self.num_heads = num_attention_heads
Expand Down Expand Up @@ -1616,6 +1621,7 @@ def __init__(
qkv_bias=qkv_bias,
ulysses_shards=ulysses_shards,
ulysses_attention_chunks=ulysses_attention_chunks,
use_base2_exp=use_base2_exp,
)

self.ff = NNXFlaxSwiGluFeedForward(
Expand Down Expand Up @@ -1703,6 +1709,7 @@ def __init__(
weights_dtype: jnp.dtype = jnp.float32,
ulysses_shards: int = -1,
ulysses_attention_chunks: int = 1,
use_base2_exp: bool = False,
):
self.dim = dim
self.num_attention_heads = num_attention_heads
Expand Down Expand Up @@ -1753,6 +1760,7 @@ def __init__(
weights_dtype=weights_dtype,
ulysses_shards=ulysses_shards,
ulysses_attention_chunks=ulysses_attention_chunks,
use_base2_exp=use_base2_exp,
)

def __call__(
Expand Down Expand Up @@ -1834,6 +1842,7 @@ def __init__(
scale_shift_order: str = "scale_shift",
ulysses_shards: int = -1,
ulysses_attention_chunks: int = 1,
use_base2_exp: bool = False,
):
self.in_channels = in_channels
self.out_channels = in_channels
Expand Down Expand Up @@ -1914,6 +1923,7 @@ def __init__(
weights_dtype=weights_dtype,
ulysses_shards=ulysses_shards,
ulysses_attention_chunks=ulysses_attention_chunks,
use_base2_exp=use_base2_exp,
)
for _ in range(num_layers)
]
Expand All @@ -1935,6 +1945,7 @@ def __init__(
weights_dtype=weights_dtype,
ulysses_shards=ulysses_shards,
ulysses_attention_chunks=ulysses_attention_chunks,
use_base2_exp=use_base2_exp,
)
for _ in range(num_single_layers)
]
Expand Down
253 changes: 181 additions & 72 deletions src/maxdiffusion/models/flux/util.py

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/maxdiffusion/models/flux/vae/__init__.py

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.

this file is missing license

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
Loading
Loading