Skip to content

Conversation

nipung90
Copy link
Contributor

@nipung90 nipung90 commented Sep 2, 2025

Summary:
This diff enables the use of num_buckets ParameterConstraint in the planner. The presence of this planner will indicate the use of ZCH bucketing as part of rowwise sharding plans.

Without num_buckets present:

The current row-wise sharding strategy will be used.

With num_buckets present:

  • When devices have the same amount of memory available:

We will divide the buckets to be evenly distributed across hosts and distribute an additional bucket to the required number of hosts to handle the remainders.
For eg. if
Test case 2: hash_size = 100, num_devices = 4, num_buckets = 10
Each bucket has 10 rows, buckets distributed as [3,3,2,2]
So rows are distributed as [30,30,20,20]

  • When devices have uneven amount of memory

We will distribute the buckets in the proportion of the memory of the device to the total memory of all devices and all the remaining buckets left are stored on the last device in the case where buckets do not completely fit based on the memory ratios.
for eg
hash_size = 45, num_buckets = 9, bucket_size = 5
With memory ratio 2:1:1, buckets should be distributed as [4,2,3]
So rows are distributed as [20,10,15]

Differential Revision: D79659949

@meta-cla meta-cla 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 Sep 2, 2025
@facebook-github-bot
Copy link
Contributor

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

…kets for zch (pytorch#3341)

Summary:

This diff enables the use of num_buckets ParameterConstraint in the planner. The presence of this planner will indicate the use of ZCH bucketing as part of rowwise sharding plans.

## Without num_buckets present:
The current row-wise sharding strategy will be used.

## With num_buckets present:
* When devices have the same amount of memory available:

We will divide the buckets to be evenly distributed across hosts and distribute an additional bucket to the required number of hosts to handle the remainders.
  For eg.  if
        Test case 2: hash_size = 100, num_devices = 4, num_buckets = 10
        Each bucket has 10 rows, buckets distributed as [3,3,2,2]
        So rows are distributed as [30,30,20,20]
* When devices have uneven amount of memory

We will distribute the buckets in the proportion of the memory of the device to the total memory of all devices and all the remaining buckets left are stored on the last device in the case where buckets do not completely fit based on the memory ratios.
for eg
        hash_size = 45, num_buckets = 9, bucket_size = 5
        With memory ratio 2:1:1, buckets should be distributed as [4,2,3]
        So rows are distributed as [20,10,15]

Differential Revision: D79659949
@facebook-github-bot
Copy link
Contributor

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

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