Support datasets 5.1.0 shard-based streaming distribution to avoid read amplification at large DP scale

Aperta
#10,327 4 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@hjh0119 ci sta già lavorando.

Dal 10/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement
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

Lingua principale
Python
Stelle
16.2k
Fork
1.8k
Merge medio
1g 14h
PR unite (30g)
68

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelscope/ms-swift

Tutte le issue di modelscope/ms-swift

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.