Skip to content

Tied word embeddings #1260

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

Merged
merged 1 commit into from
Oct 9, 2024
Merged

Conversation

gabe-l-hart
Copy link
Contributor

@gabe-l-hart gabe-l-hart commented Oct 3, 2024

Dependencies

This PR is part of a sequence in support of adding Granite Code. It depends on merging the following PRs:

Issues

Closes #1252

Description

This PR adds support for models which have shared weights between the input word embeddings and the output layer (tied word embeddings).

Changes

  • Add the tie_word_embeddings parameter to TransformerArgs
  • Add a load_hook to the Transformer class where, if configured with tie_word_embeddings, the self.output module will share weights with the self.tok_embeddings module.

Testing

In conjunction with my other changes for Granite Code, I've been able to validate that the results produced with this logic do produce the expected token sequence.

NOTE: If there's any preferred way to include unit tests along with the PR, please let me know and I can get them added! I don't see a familiar unit test structure in the project at this point, so I've been relying on local ad-hoc testing.

Copy link

pytorch-bot bot commented Oct 3, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchchat/1260

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit c840070 with merge base 6a2a2e8 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 3, 2024
@gabe-l-hart gabe-l-hart force-pushed the TiedWordEmbeddings-1252 branch 3 times, most recently from b1e2fff to 254fc51 Compare October 4, 2024 20:01
@Jack-Khuu
Copy link
Contributor

Sweet and simple, @Gasoonjia for a sanity check

@gabe-l-hart gabe-l-hart force-pushed the TiedWordEmbeddings-1252 branch 2 times, most recently from e002700 to ced5d03 Compare October 8, 2024 21:01
Branch: GraniteCodeSupport

Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
@gabe-l-hart gabe-l-hart force-pushed the TiedWordEmbeddings-1252 branch from ced5d03 to c840070 Compare October 9, 2024 12:39
@gabe-l-hart gabe-l-hart marked this pull request as ready for review October 9, 2024 12:40
@gabe-l-hart
Copy link
Contributor Author

Thanks for working through the chain @Jack-Khuu! This is the next one up

@Jack-Khuu Jack-Khuu merged commit 438ebb1 into pytorch:main Oct 9, 2024
52 checks passed
@gabe-l-hart gabe-l-hart deleted the TiedWordEmbeddings-1252 branch October 10, 2024 16:07
@gabe-l-hart gabe-l-hart mentioned this pull request Oct 31, 2024
6 tasks
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 Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for tied word embeddings
3 participants