Skip to content

Commit

Permalink
Reintroduce Python 3.9 support for ModernBERT (#35458)
Browse files Browse the repository at this point in the history
Co-authored-by: Koichi Yasuoka <[email protected]>
  • Loading branch information
tomaarsen and KoichiYasuoka authored Jan 2, 2025
1 parent 919220d commit 5b516b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/transformers/models/modernbert/modeling_modernbert.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def eager_attention_forward(
dim: int,
output_attentions: Optional[bool] = False,
**_kwargs,
) -> Tuple[torch.Tensor, torch.Tensor] | Tuple[torch.Tensor]:
) -> Union[Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor]]:
# qkv: [batch_size, seqlen, 3, nheads, headdim]
cos, sin = module.rotary_emb(qkv, position_ids=position_ids)
query, key, value = qkv.transpose(3, 1).unbind(dim=2)
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/models/modernbert/modular_modernbert.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def eager_attention_forward(
dim: int,
output_attentions: Optional[bool] = False,
**_kwargs,
) -> Tuple[torch.Tensor, torch.Tensor] | Tuple[torch.Tensor]:
) -> Union[Tuple[torch.Tensor, torch.Tensor], Tuple[torch.Tensor]]:
# qkv: [batch_size, seqlen, 3, nheads, headdim]
cos, sin = module.rotary_emb(qkv, position_ids=position_ids)
query, key, value = qkv.transpose(3, 1).unbind(dim=2)
Expand Down

0 comments on commit 5b516b0

Please sign in to comment.