fix: encoder with attention - #29
Merged
Merged
Conversation
jorisSchaller
force-pushed
the
fix/encoder-with-attention
branch
from
March 23, 2026 13:12
e237d54 to
3f2c358
Compare
jorisSchaller
force-pushed
the
fix/encoder-with-attention
branch
from
March 23, 2026 16:50
014efa5 to
d6b2695
Compare
jannisborn
requested changes
Mar 26, 2026
jannisborn
left a comment
Contributor
There was a problem hiding this comment.
Great job overall! The forward looks good, but we are not using the mask in the inputs_embeds track. Why was this done?
| This allows exact replication of the input_ids path. | ||
| Expected shapes: [local_embs (B, P1', P2, ..., Pn, Dn), ..., global_embs (B, P1', D1)] | ||
| return_type: What to return - the loss, the logits, the the Hidden_state or the loss and the logits | ||
| mask: The |
Contributor
There was a problem hiding this comment.
doc for the attention mask is missing. Could make sense to rename mask to attention_mask as there is also loss_mask
jannisborn
reviewed
Apr 8, 2026
| if loss_mask is not None: | ||
| # potentially apply the loss mask. this does not involve | ||
| # broadcasting as after slicing above, the mask and the loss tensor | ||
| # potentially apply the loss attention_mask. this does not involve |
Contributor
There was a problem hiding this comment.
revert attention_mask back to mask
jannisborn
reviewed
Apr 8, 2026
| loss_tensor *= loss_mask | ||
|
|
||
| # after applying the mask, some elements might be 0 - they should not be | ||
| # after applying the attention_mask, some elements might be 0 - they should not be |
Contributor
There was a problem hiding this comment.
here we mean the loss mask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the attention issue where in case of batching, some padding is added and those tokens are not ignored in the attention.