Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix in split_index method #5292

Merged
merged 15 commits into from
Apr 18, 2024
Merged
7 changes: 2 additions & 5 deletions deepspeed/runtime/data_pipeline/data_sampling/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

# DeepSpeed Team

import math
import numpy as np

from deepspeed.utils import logger
Expand Down Expand Up @@ -32,10 +31,8 @@ def find_fit_int_dtype(min_value, max_value):


def split_index(start_idx, end_idx, num_partitions):
partition_size = math.ceil((end_idx - start_idx) / num_partitions)
partitions = [[start_idx + x * partition_size,
min(end_idx, start_idx + (x + 1) * partition_size)] for x in range(num_partitions)]
return partitions
partition_boundaries = np.linspace(start_idx, end_idx, dtype=int, num=num_partitions + 1)
return [(partition_boundaries[i], partition_boundaries[i + 1]) for i in range(num_partitions)]


def split_dataset(dataset, num_workers, worker_id, num_threads):
Expand Down
Loading