fix(dataloader): track distributed progress by global batch - #204
Merged
Conversation
| size_t batch_size_ = 0; | ||
| size_t batch_idx_ = 0; | ||
| size_t max_batch_idx_ = 0; | ||
| size_t global_batch_idx_ = 0; |
Contributor
There was a problem hiding this comment.
这里变量不是直接表示batch维度的,为了防止理解混淆,建议改个名字,比如 dataloader_step_ ,另外其他变量也统一改下命名
Contributor
Author
There was a problem hiding this comment.
改动:
global_batch_idx_ -> dataloader_step_
num_global_batches_ -> num_dataloader_steps_
|
|
||
| DataLoader::DataLoader(const std::shared_ptr<Dataset> &dataset, size_t batch_size) | ||
| : dataset_(dataset), batch_size_(batch_size), max_batch_idx_((dataset_->Size() + batch_size_ - 1) / batch_size_) {} | ||
| : dataset_(dataset), batch_size_(batch_size), num_global_batches_(CheckedCeilDiv(dataset_->Size(), batch_size_)) {} |
Contributor
There was a problem hiding this comment.
建议先校验 dataset_ != nullptr 和 batch_size_ > 0,再计算 num_global_batches_。当前在初始化列表中直接访问 dataset_->Size(),空指针会导致非法解引用,batch_size_ == 0 也会引发除零。
Contributor
Author
There was a problem hiding this comment.
新增
CHECK(dataset_ != nullptr) 和 CHECK_GT(batch_size_, 0)
chen2021673
force-pushed
the
fix/dataloader-global-batches
branch
from
August 27, 2026 02:36
cf6fe96 to
ee324e4
Compare
- rename global batch tracking to dataloader steps - validate dataset and batch size before computing steps
kilinchange
requested changes
Aug 27, 2026
- resume training by skipping consumed batches in main - keep resume positioning as a future sampler responsibility - preserve distributed global-batch partitioning
kilinchange
approved these changes
Sep 10, 2026
Collaborator
|
麻烦贴一下测试通过截图,并备份 log 和写入飞书性能表格。 |
Contributor
Author
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.



概述
修复分布式训练中 DataLoader 使用局部 batch 进行数据划分和索引,可能导致 batch 访问越界的问题。
主要修改