Skip to content

Commit

Permalink
Merge pull request EleutherAI#722 from EleutherAI/opt-embeddings-fix
Browse files Browse the repository at this point in the history
Fix learned and sinusoidal embeddings after OPT regression
  • Loading branch information
StellaAthena committed Jan 18, 2023
2 parents 375de3f + c72ca1c commit 01f75eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion configs/neox_arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Logging Arguments

- **git_hash**: str

Default = 075a525
Default = 62e9440

current git hash of repository

Expand Down
10 changes: 4 additions & 6 deletions megatron/model/word_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,11 @@ def forward(self, input_ids, position_ids, tokentype_ids=None):
# Embeddings.
words_embeddings = self.word_embeddings(input_ids)
if self.use_pos_emb and self.embedding_type in ["learned", "sinusoidal"]:
if self.layer_past is not None:
position_ids = position_ids + self.layer_past + 1

self.layer_past = position_ids[:, -1]

# OPT always adds 2 for some reason, according to the HF implementation
if self.opt_pos_emb_offset:
if self.layer_past is not None:
position_ids = position_ids + self.layer_past + 1
self.layer_past = position_ids[:, -1]
# OPT always adds 2 for some reason, according to the HF implementation
position_ids = position_ids + self.opt_pos_emb_offset
position_embeddings = self.position_embeddings(position_ids)
embeddings = words_embeddings + position_embeddings
Expand Down

0 comments on commit 01f75eb

Please sign in to comment.