Skip to content

Commit

Permalink
Merge pull request #25 from argmaxinc/sd3-fix
Browse files Browse the repository at this point in the history
Fix sd3 layer norm bug
  • Loading branch information
atiorh authored Aug 27, 2024
2 parents ccf6509 + ad0ad24 commit d915340
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions python/src/diffusionkit/mlx/mmdit.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,11 +940,14 @@ def affine_transform(
norm_module: nn.Module = None,
) -> mx.array:
"""Affine transformation (Used for Adaptive LayerNorm Modulation)"""
if norm_module is not None:
if x.shape[0] == 1 and norm_module is not None:
return mx.fast.layer_norm(
x, 1.0 + residual_scale.squeeze(), shift.squeeze(), norm_module.eps
)
return x * (1.0 + residual_scale) + shift
elif norm_module is not None:
return norm_module(x) * (1.0 + residual_scale) + shift
else:
return x * (1.0 + residual_scale) + shift


def unpatchify(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import find_packages, setup
from setuptools.command.install import install

VERSION = "0.3.2"
VERSION = "0.3.3"


class VersionInstallCommand(install):
Expand Down

0 comments on commit d915340

Please sign in to comment.