Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mask-tying to sequence length #660

Merged
merged 3 commits into from
Feb 3, 2023

Conversation

erip
Copy link
Contributor

@erip erip commented Jan 30, 2023

What does this PR do?

Fixes #655

This PR allows a class-level causal attention mask for fixed sequence-length tasks; otherwise it creates a new mask on-the-fly in the forward pass to disentangle the mask from sequence length which can vary between batches in tasks like MT.

Before submitting

  • Did you have fun?
    • Make sure you had fun coding 🙃
  • Did you read the contributor guideline?
  • Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
    • N/A
  • Did you make sure to update the docs?
    • N/A
  • Did you write any new necessary tests?
    • N/A
  • Did you update the changelog? (if needed)
    • N/A

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 30, 2023
@erip
Copy link
Contributor Author

erip commented Jan 30, 2023

This is mostly a quick smoke test (haven't tested locally yet --- running into issues with local dev). I think this needs a unit test and probably an inspection of benchmark performance to ensure the new branching doesn't impact speed.

@erip erip force-pushed the hotfix/attention-mask branch from a888d65 to c29e380 Compare January 30, 2023 15:49
@erip erip force-pushed the hotfix/attention-mask branch from 1243c74 to 735b617 Compare January 30, 2023 16:24
@erip erip changed the title [WIP] fix mask-tying to sequence length fix mask-tying to sequence length Jan 30, 2023
@erip
Copy link
Contributor Author

erip commented Jan 30, 2023

I think this is ready for review. It's a pretty small change, benchmarks look OK, and tests pass (locally). cc @danthe3rd @blefaudeux

@danthe3rd
Copy link
Contributor

Hi @erip and thanks for your contribution :)
I'm not familiar with this code - maybe @blefaudeux can have a look, or @fmassa ?

Copy link
Contributor

@blefaudeux blefaudeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I was probably the one writing the stateful masking, but thinking a bit more it's not obvious that it's a win. Deferring to @fmassa if something is wrong here, but out of principle looks good to me ! Thanks @erip

Copy link
Contributor

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

As discussed in the previous comments, we really need to do some cleanup and refactoring on those APIs. But this is already a good improvement, thanks!

@fmassa fmassa merged commit 7f4fdce into facebookresearch:main Feb 3, 2023
@erip erip deleted the hotfix/attention-mask branch February 3, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shape mismatch between batches if lengths are different.
5 participants