Support datasets 5.1.0 shard-based streaming distribution to avoid read amplification at large DP scale
Maintainers usually reply within 1 day
@hjh0119 is already working on this.
Since Oct 10, 2026.
Assessment
This issue has not been assessed yet.
Description
Checklist / 检查清单
- I have searched existing issues, and this is a new feature request. / 我已经搜索过现有的 issues,确认这是一个新的 Feature Request。
Feature Request Description / Feature Request 描述
Description
我之前在分析 ms-swift 的 streaming 数据处理流程时,发现当前数据读取与预处理主要集中在 rank 0,再由 DataLoaderDispatcher 将batch 分发给其他 rank。随着 DP 并行度增加,rank 0 容易成为数据供给瓶颈。为解决这一问题,我在 Hugging Face datasets 提出了适用于 streaming dataset 的高效 source-shard 分片策略datasets issue #8253 该能力现已合入datasets 5.1.0。
希望 ms-swift 接入这一能力:让不同 DP rank 直接读取各自负责的 source shards,并在本 rank 内由 DataLoader workers 继续分配读取任务,以减少重复读取和 rank 0 的集中处理压力。
Proposed changes
-
升级并验证依赖:适配 datasets 5.1.0。
-
在预处理前划分数据:对 streaming 的 HF IterableDataset,在 encode 和 packing 包装之前调用 split_dataset_by_node(...,strategy="shards" | "examples"),使用 DP rank/world size,而非全局进程 rank/world size。
-
调整 rank 间数据分发:为该模式增加 rank-local DataLoader 路径,不再由 rank 0 为所有 DP rank 读取并 scatter batch;模型并行场景仍需保持并行组内正确的 batch 共享。
-
兼容 packing 与现有模式:优先落地普通 DDP、streaming、non-packing;随后处理 streaming packing 与 Megatron。暂不满足条件的场景继续使用现有 dispatcher 路径。
-
保证训练语义:覆盖各 rank 提前耗尽、max_steps、shuffle seed/epoch、checkpoint resume,以及 shards 数量不足或负载不均时的行为。
Expected outcome
在具备足够 source shards 的 streaming 数据集上,各 DP rank 只读取分配给自己的 shards,shards数不足时,可按照example级别做数据划分,消除现有 rank 0 集中预处理的瓶颈。在我们的内部环境测试下,多dp并行度模式下,数据部分的处理吞吐可提升n倍。
Pull Request / Pull Request 信息
No response
- Dominant language
- Python
- Stars
- 16.2k
- Forks
- 1.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 68
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelscope/ms-swift
-
get_multimodal_target_regex(..., exclude_router=True) does not exclude shared_expert_gatePossibly taken @KonnyakuMatcha claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelscope/ms-swift#10696 ·
Maintainers usually reply within 1 day
-
[BUG] GRPO REAL loss crashes with beta>0 and kl_in_reward=True (NoneType * Tensor)Possibly taken @newcloud123 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
modelscope/ms-swift#10690 ·
Maintainers usually reply within 1 day
-
[BUG] GRPO REAL loss divides by all groups instead of valid groups, silently scaling gradientsPossibly taken @newcloud123 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
modelscope/ms-swift#10688 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 Half a day Newbie friendliness 62/100
modelscope/ms-swift#10621 ·
Maintainers usually reply within 1 day
-
[Bug] `get_seed` consumes a draw from the shared RandomState even when decision augmentation is disabled, changing the train/val split and dataset shufflePossibly taken @ryznren claimed this 38 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelscope/ms-swift#10466 · 1 comment ·
Maintainers usually reply within 1 day
All issues in modelscope/ms-swift
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day