Replace per-rank table_names dump with a fingerprint - #4540
Open
kaanbaloglu wants to merge 1 commit into
Open
Conversation
Summary: This diff replaces the per-rank sharding-plan dump in the two sharder events with a small fingerprint, and keeps the full map on one rank per sharding group. `ShardedEmbeddingBagCollection.__init__` logs the full table-name to sharding-type map on every rank. Every rank builds an identical copy, so a large job repeats the same multi-kilobyte payload once per rank. That is a tiny share of the event stream's rows and most of its bytes. The planner already persists the same plan durably elsewhere. `ShardedEmbeddingCollection` does the same thing. Each sharder now emits two events. Every rank emits `<Module>.sharding_plan_fingerprint` with `num_tables`, per-sharding-type counts, and a fingerprint. One rank per sharding group also emits the existing `<Module>.table_names`, unchanged. The fingerprint comes from `sharding_plan_fingerprint` in `torchrec/distributed/utils.py`. It uses `blake2b`, not `hash()`, which is salted per process and not comparable across ranks. Every rank keeps a fingerprint because some jobs shard heterogeneously, so a payload can sit on a rank band that excludes rank 0. The gate is `is_plan_leader`. It keys on rank 0 of the env's own process group. The plan is broadcast over that group, so it is identical across it and can differ across groups. Under 2D sharding that group is `global_pg`. Tower and pipeline-stage sharding build an env per subgroup, and most of those subgroups do not contain global rank 0. A job-wide gate would drop their plans. One emission per process group removes every duplicate copy and keeps every distinct plan. Differential Revision: D114819716
Contributor
|
@kaanbaloglu has exported this pull request. If you are a Meta employee, you can view the originating Diff in D114819716. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This diff replaces the per-rank sharding-plan dump in the two sharder events with a small fingerprint, and keeps the full map on one rank per sharding group.
ShardedEmbeddingBagCollection.__init__logs the full table-name to sharding-type map on every rank. Every rank builds an identical copy, so a large job repeats the same multi-kilobyte payload once per rank. That is a tiny share of the event stream's rows and most of its bytes. The planner already persists the same plan durably elsewhere.ShardedEmbeddingCollectiondoes the same thing.Each sharder now emits two events. Every rank emits
<Module>.sharding_plan_fingerprintwithnum_tables, per-sharding-type counts, and a fingerprint. One rank per sharding group also emits the existing<Module>.table_names, unchanged. The fingerprint comes fromsharding_plan_fingerprintintorchrec/distributed/utils.py. It usesblake2b, nothash(), which is salted per process and not comparable across ranks. Every rank keeps a fingerprint because some jobs shard heterogeneously, so a payload can sit on a rank band that excludes rank 0. The gate isis_plan_leader. It keys on rank 0 of the env's own process group. The plan is broadcast over that group, so it is identical across it and can differ across groups. Under 2D sharding that group isglobal_pg. Tower and pipeline-stage sharding build an env per subgroup, and most of those subgroups do not contain global rank 0. A job-wide gate would drop their plans. One emission per process group removes every duplicate copy and keeps every distinct plan.Differential Revision: D114819716