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 embedding table compression script #261

Merged
merged 2 commits into from
Jul 19, 2022

Conversation

xiangzez
Copy link
Contributor

@xiangzez xiangzez commented Jul 6, 2022

Description

Brief Description of the PR:

Hi, This PR contains a script to compress TFRA dynamic embedding tables' value datatype from float32 to float16. It can be used to process exported SavedModel and can reduce ~50% size of models that have very large embedding tables. It is integrated into movielens-100k-estimator demo and I hope it can be a reference to other users who have similar needs.

The script only edits CuckooHashTable related ops in the model graph and will add a cast after CuckooHashTableFind op to keep outputs the same, so other parts of the model are not affected.

Type of change

  • Bug fix
  • New Tutorial
  • Updated or additional documentation
  • Additional Testing
  • New Feature

Checklist:

  • I've properly formatted my code according to the guidelines
    • By running yapf
    • By running clang-format
  • This PR addresses an already submitted issue for TensorFlow Recommenders-Addons
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

How Has This Been Tested?

If you're adding a bugfix or new feature please describe the tests that you ran to verify your changes:
*

Add a script to compress TFRA dynamic embedding tables' value
datatype from float32 to float16. It can be used for exported
SavedModel.
@rhdong
Copy link
Member

rhdong commented Jul 6, 2022

Hi @xiangzez , thank you for your first contribution, it's very valuable! I would like to know how much does compression affect the model's accuracy? I mean if you have done some comparison or benchmark, you can add it to the Readme of the demo for other user. Thank you!

@rhdong rhdong self-requested a review July 6, 2022 10:24
@xiangzez
Copy link
Contributor Author

xiangzez commented Jul 7, 2022

Hi @rhdong, this is a work we did for our customers, so we don't have accuracy change data of their production models. However this demo shows comparison of loss before/after compression. I have added example outputs in readme.

Copy link
Member

@rhdong rhdong left a comment

Choose a reason for hiding this comment

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

LGTM

@rhdong rhdong merged commit 0b81f24 into tensorflow:master Jul 19, 2022
@xiangzez xiangzez deleted the compress_model branch July 22, 2022 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants