Skip to content

[BUG] num_samples 向下去整, 防止prefrech预取时候超过数据集最大长度... #8690

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

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions paddlenlp/utils/batch_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

from __future__ import division, print_function

import math

import paddle

__all__ = ["DistributedBatchSampler"]
Expand Down Expand Up @@ -110,7 +108,7 @@
# In pre-training mode when using distributed dataloader, the input dataset can be None. We should handle this situation.
self.num_samples = 0
else:
self.num_samples = int(math.ceil(len(self.dataset) * 1.0 / self.nranks))
self.num_samples = int(len(self.dataset) * 1.0 / self.nranks)

Check warning on line 111 in paddlenlp/utils/batch_sampler.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/utils/batch_sampler.py#L111

Added line #L111 was not covered by tests
self.total_size = self.num_samples * self.nranks

def get_start_end_idx(self):
Expand All @@ -125,7 +123,7 @@
self.consumed_samples,
self.nranks,
)
self.remain_num_samples = int(math.ceil((len(self.dataset) - self.consumed_samples) * 1.0 / self.nranks))
self.remain_num_samples = int((len(self.dataset) - self.consumed_samples) * 1.0 / self.nranks)

Check warning on line 126 in paddlenlp/utils/batch_sampler.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/utils/batch_sampler.py#L126

Added line #L126 was not covered by tests
self.remain_total_size = self.remain_num_samples * self.nranks
self.batch_size_times_rank_size = self.batch_size * self.nranks

Expand Down
Loading