Skip to content

Conversation

@elokrainz
Copy link

@elokrainz elokrainz commented Mar 11, 2025

Summary:
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 and using zip_longest to transpose 2D jagged lists.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 11, 2025
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

…eta-pytorch#2796)

Summary:

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.

_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}

Differential Revision:
D70960056

Privacy Context Container: L1292699
@facebook-github-bot
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants