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

Add an auto_expand option to SinusoidalPositionalEmbedding #5555

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

MaigoAkisame
Copy link
Contributor

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
    No; I'm discussing it in a Meta internal chat.
  • Did you read the contributor guideline?
  • Did you make sure to update the docs?
    No; I didn't find docs in the repo.
  • Did you write any new necessary tests?
    Not applicable.

What does this PR do?

In the fairseq SinusoidalPositionalEmbedding module, when the input length exceeds the number of pre-computed embeddings, the embeddings are expanded and written back to the weights field of the module.
However, mutating fields of a module can cause subtle bugs in multithreading environments.
This diff provides an auto_expand option to SinusoidalPositionalEmbedding to control whether the expanded embeddings are written back to the module.
The default is set to True, so the default behavior is not changed.
If you encounter bugs in multithreading environments, set auto_expand=False.

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.

Did you have fun?

Make sure you had fun coding 🙃

Copy link
Contributor

@cbalioglu cbalioglu left a comment

Choose a reason for hiding this comment

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

LGTM

@cbalioglu cbalioglu merged commit ecbf110 into facebookresearch:main Oct 18, 2024
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants