Skip to content

Commit

Permalink
feat: allow flux transformer to be sharded during inference (#9159)
Browse files Browse the repository at this point in the history
* feat: support sharding for flux.

* tests
  • Loading branch information
sayakpaul authored Aug 16, 2024
1 parent 3e46043 commit 39b87b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/diffusers/models/transformers/transformer_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class FluxTransformer2DModel(ModelMixin, ConfigMixin, PeftAdapterMixin, FromOrig
"""

_supports_gradient_checkpointing = True
_no_split_modules = ["FluxTransformerBlock", "FluxSingleTransformerBlock"]

@register_to_config
def __init__(
Expand Down
2 changes: 2 additions & 0 deletions tests/models/transformers/test_models_transformer_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
class FluxTransformerTests(ModelTesterMixin, unittest.TestCase):
model_class = FluxTransformer2DModel
main_input_name = "hidden_states"
# We override the items here because the transformer under consideration is small.
model_split_percents = [0.7, 0.6, 0.6]

@property
def dummy_input(self):
Expand Down

0 comments on commit 39b87b1

Please sign in to comment.