FBGEMM icon indicating copy to clipboard operation
FBGEMM copied to clipboard

torchrec support on kvzch emb lookup module

Open duduyi2013 opened this issue 7 months ago • 2 comments

Summary:

Change logs

  1. add ZeroCollisionKeyValueEmbedding emb lookup
  2. address existing unit test missing for ssd offloading
  3. add new ut for kv zch embedding module
  4. add a temp hack solution for calculate bucket metadata
  5. embedding updates, details illustrated below

####################################################################### ########################### embedding.py updates ########################## #######################################################################

  1. keep the original idea to init shardedTensor during training init
  2. for kv zch table, the shardeTensor will be init using virtual size for metadata calculation, and skip actual tensor size check for ST init, this is needed as during training init, the table has 0 rows
  3. the new tensor, weight_id will not be registered in the EC becuase its shape is changing in realtime, the weight_id tensor will be generated in post_state_dict hooks
  4. the new tensor, bucket could be registered and preserved, but in this diff we keep it the same way as weight_id
  5. in post state dict hook, we call get_named_split_embedding_weights_snapshot to get Tuple[table_name, weight(ST), weight_id(ST), bucket(ST)], all 3 tensors are return in the format of ST, and we will update destination with the returned ST directly
  6. in pre_load_state_dict_hook, which is called upon load_state_dict(), we will skip all 3 tensors update, because the tensor assignment is done on the nn.module side, which doesn't support updating KVT through PMT. This is fine for now because, checkpoint loading will be done outside of the load_state_dict call, but we need future plans to make it work cohesively with other type of tensors

Differential Revision: D73567631

duduyi2013 avatar Apr 28 '25 19:04 duduyi2013

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
Latest commit 26b0b470eda625c20c5ad2bdd9048a18fab68b3c
Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/680fda70d6988b0008722fca
Deploy Preview https://deploy-preview-4035--pytorch-fbgemm-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Apr 28 '25 19:04 netlify[bot]

This pull request was exported from Phabricator. Differential Revision: D73567631

facebook-github-bot avatar Apr 28 '25 19:04 facebook-github-bot