Skip to content

Commit

Permalink
PegasusX add _no_split_modules (huggingface#25933)
Browse files Browse the repository at this point in the history
* no_split_modules

* no_split_modules

* inputs_embeds+pos same device

* update _no_split_modules

* update _no_split_modules
  • Loading branch information
andreeahedes authored and parambharat committed Sep 26, 2023
1 parent bcdb232 commit d332220
Showing 1 changed file with 3 additions and 0 deletions.
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)

hidden_states = inputs_embeds + positions

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

0 comments on commit d332220

Please sign in to comment.