Commit b3e19e2
Cache embedding_weights_by_table for EmbeddingFusedOptimizer (#2711)
Summary:
Pull Request resolved: #2711
The `split_embedding_weights()` method in the `emb_module` is a time-consuming operation. Currently, it is placed in the constructor of the `EmbeddingFusedOptimizer`. As a result, every time an `EmbeddingFusedOptimizer` instance is created, this method is executed. Since `_gen_named_parameters_by_table_fused` generates EmbeddingFusedOptimizer instances **thousands of times in a loop**, a significant amount of time is spent executing this method.
By extracting this operation out of the loop and passing it as a parameter to achieve a caching effect, we can save a lot of time. Specifically, the current **CREATE_TRAIN_MODULE.SHARD_MODEL** takes approximately **22 seconds** to run, but with this caching mechanism, the runtime can be reduced to around **15 seconds**. The AI Lab result shows 6.67s saving(https://www.internalfb.com/family_of_labs/test_results/689499818)
Reviewed By: dstaay-fb
Differential Revision: D68578829
fbshipit-source-id: 63332203dfaec1f326298d068101cf66885b33941 parent 0d827ea commit b3e19e2
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
216 | 215 | | |
217 | 216 | | |
218 | 217 | | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
395 | 397 | | |
396 | 398 | | |
397 | 399 | | |
| |||
674 | 676 | | |
675 | 677 | | |
676 | 678 | | |
| 679 | + | |
| 680 | + | |
677 | 681 | | |
678 | 682 | | |
679 | 683 | | |
| |||
709 | 713 | | |
710 | 714 | | |
711 | 715 | | |
| 716 | + | |
712 | 717 | | |
713 | 718 | | |
714 | 719 | | |
| |||
0 commit comments