Commit 7652c5d
Reduce unnecessary function call in _set_sharding_context_post_a2a (#2796)
Summary:
Pull Request resolved: #2796
This diff aims to improve the performance of the `_set_sharding_context_post_a2a` in `embedding_sharding` module in TorchRec by reducing unnecessary function calls.
From different benchmark results, it reduce the function call by over 50% as below:
_set_sharding_context_post_a2a_previous-KJT_len:100-keys:10 | Runtime (P90): 0.45 ms
_set_sharding_context_post_a2a-KJT_len:100-keys:10 | Runtime (P90): 0.28 ms
_set_sharding_context_post_a2a_previous-KJT_len:100-keys:100 | Runtime (P90): 2.47 ms
_set_sharding_context_post_a2a-KJT_len:100-keys:100 | Runtime (P90): 0.89 ms
_set_sharding_context_post_a2a_previous-KJT_len:1000-keys:10 | Runtime (P90): 4.55 ms
_set_sharding_context_post_a2a-KJT_len:1000-keys:10 | Runtime (P90): 2.73 ms
_set_sharding_context_post_a2a_previous-KJT_len:1000-keys:100 | Runtime (P90): 24.49 ms
_set_sharding_context_post_a2a-KJT_len:1000-keys:100 | Runtime (P90): 8.68 ms
_set_sharding_context_post_a2a_previous-KJT_len:10000-keys:10 | Runtime (P90): 46.85 ms
_set_sharding_context_post_a2a-KJT_len:10000-keys:10 | Runtime (P90): 28.00 ms
_set_sharding_context_post_a2a_previous-KJT_len:10000-keys:100 | Runtime (P90): 243.57 ms
_set_sharding_context_post_a2a-KJT_len:10000-keys:100 | Runtime (P90): 89.14 ms
Previous trace: about 4-5ms
{F1975959472}
Now: less than 4ms, some even less than 0.2ms, with much less operations
{F1975959630}
{F1975959609}
Test on IG TAB ESR TTSN model:
NE trending is same:
{F1975957602}
{F1975957605}
{F1975957635}
Reviewed By: dstaay-fb
Differential Revision:
D70960056
Privacy Context Container: L1292699
fbshipit-source-id: d5678b6893dbdae63e1f9119e63314c70a808cc01 parent fb1f2c4 commit 7652c5d
File tree
4 files changed
+165
-10
lines changed- torchrec/distributed
- benchmark
- tests
4 files changed
+165
-10
lines changedLines changed: 105 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
| |||
749 | 751 | | |
750 | 752 | | |
751 | 753 | | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
757 | 766 | | |
758 | 767 | | |
759 | 768 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
| 665 | + | |
665 | 666 | | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
| 667 | + | |
| 668 | + | |
671 | 669 | | |
672 | 670 | | |
673 | 671 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| 37 | + | |
34 | 38 | | |
| 39 | + | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
| |||
489 | 494 | | |
490 | 495 | | |
491 | 496 | | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
0 commit comments