Skip to content

Commit

Permalink
Fix bus error when using GPT2 on M1 macs (#34031)
Browse files Browse the repository at this point in the history
There's a bug on M1 macs with transformer >= 4.43.0 and torch >= 2.1.0, where if a model has tied embeddings, then the fast loading from #31771 causes a bus error when the model is actually run. This can be solved by disabling `_supports_param_buffer_assignment` for these models.

More info in comments in #33357
  • Loading branch information
chanind authored Oct 17, 2024
1 parent 9470c00 commit 1d2c29f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/transformers/models/gpt2/modeling_gpt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@ class GPT2DoubleHeadsModelOutput(ModelOutput):
GPT2_START_DOCSTRING,
)
class GPT2Model(GPT2PreTrainedModel):
_supports_param_buffer_assignment = False

def __init__(self, config):
super().__init__(config)

Expand Down

0 comments on commit 1d2c29f

Please sign in to comment.