pytorch / FBGEMM

FB (Facebook) + GEMM (General Matrix-Matrix Multiplication) - https://code.fb.com/ml-applications/fbgemm/
Other
1.18k stars 486 forks source link

benchmark of fbgemm op - permute_multi_embedding #2771

Closed TroyGarden closed 2 months ago

TroyGarden commented 3 months ago

Summary:

performance notes

The good:

  1. the algorithm is designed in a way that it doesn't need to know in advance whether the 1-to-N mapping exists in the permutes.
  2. _all_keys_used_once is no longer needed
  3. no longer need a torch.cat before calling the old operator
  4. no need to use _pin_and_move for the meta data (arguments), it will be handled inside the operator, it's more friendly to tracing.

The same bad:

  1. it requires several HtoD communications (move tensor to device): a) [resolved] 3 tensors, which are permutes, input_lengths, and output_lengths. Those tensors needs to be on the device so that the cuda kernels has access to it. b) [resolved] 2 lists of (scalar_t*) pointers, input and output tensor lists. c) [resolved] Didn't find a good way to let the kernel knows the address of the lists of input/output tensors, because the lists are also need to be on the device.
  2. tensor.contiguous for the backward function, it looks like the grad from the backward are somehow not contiguous.

benchmark

traces

Differential Revision: D58906839

facebook-github-bot commented 3 months ago

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

netlify[bot] commented 3 months ago

Deploy Preview for pytorch-fbgemm-docs failed.

Name Link
Latest commit ea1ca6a1de3721543d2fae45f22d8cc341c68f59
Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/6676eeb209af39000818affb
facebook-github-bot commented 3 months ago

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

facebook-github-bot commented 2 months ago

This pull request has been merged in pytorch/FBGEMM@f8021eea2bb3da9baac31a45d16775368b876223.