Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove in-place addition for dreambooth train with text encoder #8825

Merged
merged 4 commits into from
Apr 29, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from torch._inductor import config as inductor_config

from nemo.collections.multimodal.data.dreambooth.dreambooth_dataset import DreamBoothDataset
from nemo.collections.multimodal.modules.stable_diffusion.attention import LinearWrapper
from nemo.collections.multimodal.modules.stable_diffusion.distributions.distributions import (
DiagonalGaussianDistribution,
)
Expand Down Expand Up @@ -647,6 +646,8 @@ def load_from_checkpoint(
return checkpoint

def _check_and_add_adapter(self, name, module, peft_name, peft_cfg, name_key_to_mcore_mixins=None):
from nemo.collections.multimodal.modules.stable_diffusion.attention import LinearWrapper

if isinstance(module, AdapterModuleMixin):
if isinstance(module, LinearWrapper):
peft_cfg.in_features, peft_cfg.out_features = module.in_features, module.out_features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def forward(self, text):

def encode_with_transformer(self, text):
x = self.model.language_model.embedding.word_embeddings(text)
x += self.model.language_model.embedding.position_embeddings
x = x + self.model.language_model.embedding.position_embeddings
x = x.permute(1, 0, 2) # NLD -> LND
x = self.text_transformer_forward(x, attn_mask=self.model.attn_mask)
x = self.model.language_model.encoder.final_layernorm(x)
Expand Down
Loading