Skip to content

Commit

Permalink
Small fixes for TF-ESM1b and ESM-1b weight conversions (#19683)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocketknight1 committed Oct 18, 2022
1 parent 90071fe commit fd5eac5
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/esm/convert_esm.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def convert_esm_checkpoint_to_pytorch(
self_attn.value.weight.data = esm_layer.self_attn.v_proj.weight
self_attn.value.bias.data = esm_layer.self_attn.v_proj.bias

if hasattr(esm_layer.self_attn, "rot_emb"):
if getattr(esm_layer.self_attn, "rot_emb", None) is not None:
# Matt: Although inv_freq is not a trainable weight, it is computed at model init and cached.
# During the training of ESM-2 the model was converted to float16 precision, which also converts
# the inv_freq tensor, and the loss of precision remains even if the model is loaded later as float32.
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/models/esm/modeling_tf_esm.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self, config, name=None):
)

if config.emb_layer_norm_before:
self.layer_norm = LayerNormalization(epsilon=config.layer_norm_eps)
self.layer_norm = LayerNormalization(epsilon=config.layer_norm_eps, name="layer_norm")
else:
self.layer_norm = None
# Matt: I think this line was copied incorrectly from BERT, disabling for now
Expand Down

0 comments on commit fd5eac5

Please sign in to comment.