Skip to content

Commit

Permalink
checking if attention mask present for ignoring pad tokens in ffn (#1188
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ShashankMosaicML authored May 9, 2024
1 parent ac563e6 commit 0c7bc2a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llmfoundry/models/layers/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ def apply_ffn(
"""
batch_size, seq_len = m.size()[:2]
indices = None
if not self.use_pad_tok_in_ffn:
if not self.use_pad_tok_in_ffn and attention_mask is not None:
assert unpad_input is not None
m, indices, _, _ = unpad_input(m, attention_mask)
n = self.ffn(m)
if not self.use_pad_tok_in_ffn:
if not self.use_pad_tok_in_ffn and attention_mask is not None:
assert pad_input is not None
n = pad_input(n, indices, batch_size, seq_len)
return n
Expand Down

0 comments on commit 0c7bc2a

Please sign in to comment.