Skip to content

Commit d915340

Browse files
authored
Merge pull request #25 from argmaxinc/sd3-fix
Fix sd3 layer norm bug
2 parents ccf6509 + ad0ad24 commit d915340

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

python/src/diffusionkit/mlx/mmdit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,11 +940,14 @@ def affine_transform(
940940
norm_module: nn.Module = None,
941941
) -> mx.array:
942942
"""Affine transformation (Used for Adaptive LayerNorm Modulation)"""
943-
if norm_module is not None:
943+
if x.shape[0] == 1 and norm_module is not None:
944944
return mx.fast.layer_norm(
945945
x, 1.0 + residual_scale.squeeze(), shift.squeeze(), norm_module.eps
946946
)
947-
return x * (1.0 + residual_scale) + shift
947+
elif norm_module is not None:
948+
return norm_module(x) * (1.0 + residual_scale) + shift
949+
else:
950+
return x * (1.0 + residual_scale) + shift
948951

949952

950953
def unpatchify(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import find_packages, setup
44
from setuptools.command.install import install
55

6-
VERSION = "0.3.2"
6+
VERSION = "0.3.3"
77

88

99
class VersionInstallCommand(install):

0 commit comments

Comments
 (0)