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

PegasusX add _no_split_modules #25933

Merged
Merged
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
3 changes: 3 additions & 0 deletions src/transformers/models/pegasus_x/modeling_pegasus_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ class PegasusXPreTrainedModel(PreTrainedModel):
config_class = PegasusXConfig
base_model_prefix = "model"
supports_gradient_checkpointing = True
_no_split_modules = [r"PegasusXEncoderLayer", r"PegasusXDecoderLayer"]

def _init_weights(self, module):
std = self.config.init_std
Expand Down Expand Up @@ -1299,6 +1300,8 @@ def forward(
# embed positions
positions = self.embed_positions(inputs_embeds, past_key_values_length)

positions = positions.to(inputs_embeds.device)

SunMarc marked this conversation as resolved.
Show resolved Hide resolved
hidden_states = inputs_embeds + positions

hidden_states = nn.functional.dropout(hidden_states, p=self.dropout, training=self.training)
Expand Down