[Bug] DeepSpeedDataSampler gates DP-group sampling on global_rank == 0 and broadcasts with raw src=0, crashing non-zero DP groups under 2D/3D parallelism
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
Start with deepspeed/runtime/data_pipeline/data_sampling/data_sampler.py, especially DeepSpeedDataSampler.__init__, get_new_cluster, get_next_global_batch, and load_state_dict. Trace how data_parallel_group, data_parallel_rank, and global_rank are used for cluster loading, state restoration, and distributed broadcasts. Extend tests/unit/runtime/test_data_efficiency.py with the multi-dimensional parallel setup described in the issue and verify that each DP group samples consistently without a missing-global-rank error.
索引モデルが issue の本文から書いたものです。
説明
Summary
In deepspeed/runtime/data_pipeline/data_sampling/data_sampler.py (commit a695f646974c6c92da2a9028bbafde8bb28bad1e, present at HEAD), DeepSpeedDataSampler assumes that the leader of self.data_parallel_group is always global rank 0:
# deepspeed/runtime/data_pipeline/data_sampling/data_sampler.py:79-85, 178-227, 284-301, 354-358
# In __init__:
if self.global_rank == 0:
self.data_clusters = []
self.data_cluster_sizes = []
...
# In get_new_cluster:
if self.global_rank == 0:
...
self.data_clusters.append(MMapIndexedDataset(cluster_path, skip_warmup=True))
self.data_cluster_sizes.append(len(self.data_clusters[-1][0]))
dist.barrier(group=self.data_parallel_group)
# In get_next_global_batch:
if self.global_rank == 0:
samples_per_cluster = self.sample_from_clusters()
...
batch = torch.tensor(batch, device=get_accelerator().current_device_name(), dtype=torch.long).view(-1)
else:
batch = torch.empty(self.global_batch_size,
device=get_accelerator().current_device_name(),
dtype=torch.long)
dist.broadcast(batch, 0, group=self.data_parallel_group)
Whenever any orthogonal parallelism dimension is enabled (TP > 1, PP > 1, or SP > 1), ranks with non-zero TP/PP/SP coordinates belong to a data_parallel_group that does not contain global rank 0 (for example, under TP=2, DP=2, DP group 0 is [0, 2] and DP group 1 is [1, 3]). On every non-zero DP group:
dist.broadcast(batch, 0, group=self.data_parallel_group)(line 299) passes raw global rank0instead ofdist.get_global_rank(self.data_parallel_group, 0), immediately raisingValueError: Global rank 0 is not part of groupon the very first batch.self.global_rank == 0in__init__(lines 79, 93),get_new_cluster(line 178),get_next_global_batch(line 284), andload_state_dict(line 354) leavesself.data_clustersandself.data_cluster_sizesuninitialized ondata_parallel_rank == 0of every non-zero DP group.dist.barrier(group=self.data_parallel_group)at line 227 only synchronizes within each DP group rather than across the world, allowing non-zero DP groups to race past global rank0while cluster files are being written to shared disk.
Existing tests/unit/runtime/test_data_efficiency.py only tests single-group DP (TP=1, PP=1), where global rank 0 is present in the sole DP group.
Affected Location
- Repository:
deepspeedai/DeepSpeed(a695f646974c6c92da2a9028bbafde8bb28bad1e, present atHEAD) - File & lines:
deepspeed/runtime/data_pipeline/data_sampling/data_sampler.py:79-103,178-230,284-301,354-358(DeepSpeedDataSampler.__init__,get_new_cluster,get_next_global_batch,load_state_dict)
Minimal Standalone Reproduction
import os
import torch.distributed as dist
from deepspeed.runtime.data_pipeline.data_sampling.data_sampler import DeepSpeedDataSampler
def worker(rank, cluster_dir):
os.environ["RANK"] = str(rank)
os.environ["WORLD_SIZE"] = "4"
dist.init_process_group("gloo", rank=rank, world_size=4)
# 2D parallelism: TP=2, DP=2 -> DP groups [0, 2] and [1, 3]
dp_g0 = dist.new_group(ranks=[0, 2])
dp_g1 = dist.new_group(ranks=[1, 3])
my_dp_group = dp_g0 if rank in (0, 2) else dp_g1
dp_rank = 0 if rank in (0, 1) else 1
sampler = DeepSpeedDataSampler(
data_efficiency_config=config,
one_epoch_total_samples=20,
micro_batch_size=2,
data_parallel_rank=dp_rank,
data_parallel_size=2,
data_parallel_group=my_dp_group,
gradient_accumulation_steps=1,
global_rank=rank,
)
sampler.get_next_global_batch()
Observed behavior / output (4-process Gloo execution against verbatim DeepSpeedDataSampler):
- Rank
0(dp_rank=0, group[0, 2]):OK,sampler.batch = [16, 18, 3, 9] - Rank
2(dp_rank=1, group[0, 2]):OK,sampler.batch = [16, 18, 3, 9] - Rank
1(dp_rank=0, group[1, 3]):ValueError: Global rank 0 is not part of group <torch.distributed.distributed_c10d.ProcessGroup ...> - Rank
3(dp_rank=1, group[1, 3]):ValueError: Global rank 0 is not part of group <torch.distributed.distributed_c10d.ProcessGroup ...>
Suggested Fix
- Gate per-DP-group cluster loading, batch sampling, and state restoration (
__init__,get_next_global_batch,load_state_dict) onself.data_parallel_rank == 0instead ofself.global_rank == 0. - In
get_next_global_batch(line 299), pass the DP group's global rank 0 (dist.get_global_rank(self.data_parallel_group, 0)) todist.broadcast(batch, src, group=self.data_parallel_group). - In
get_new_cluster, have global rank0write the shared.bin/.idxcluster files on disk, synchronize across the world (dist.barrier(), or a filesystem-safe world barrier) so non-zero DP groups never race file creation, and then let each DP group'sdata_parallel_rank == 0open the finalizedMMapIndexedDatasetfor deterministic DP sampling.
- 主要言語
- Python
- スター
- 43.3k
- フォーク
- 5.1k
- 平均マージ
- 5日 10時間
- マージ済み PR(30日)
- 85
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
deepspeedai/DeepSpeed のほかの issue
-
[Bug] DeepSpeedEngine.step leaves _running_engine_step=True permanently on exception, corrupting is_gradient_accumulation_boundary()対応中かも @its-amann が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
deepspeedai/DeepSpeed#9190 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[Bug] PipelineEngine._exec_reduce_grads and _exec_optimizer_step leave _force_grad_boundary=True permanently after any exception対応中かも @bantianyue が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepspeedai/DeepSpeed#9183 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
deepspeedai/DeepSpeed#9019 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
fp16 `hysteresis: 0` (or negative) makes DynamicLossScaler never lower the loss scale, so every overflowing step is skipped forever対応中かも @damienen が 26 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
deepspeedai/DeepSpeed#8982 ·
メンテナーはふだん 2 日以内に返信
-
[BUG] OneCycle applies the minimum momentum to the first Adam update対応中かも @ai-yang が 30 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepspeedai/DeepSpeed#8951 ·
メンテナーはふだん 2 日以内に返信
deepspeedai/DeepSpeed の issue をすべて見る
似ている issue
-
area/auth comp/agent P3 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NousResearch/hermes-agent#161417 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Dao-AILab/flash-attention#3251 ·
メンテナーはふだん 2 日以内に返信
-
[New Check]: sqlserver_public_network_access_disabled対応中かも @pouria-l が今日担当しました。 オープンfeature-request status/needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
prowler-cloud/prowler#13607 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
external langchain
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
langchain-ai/docs#8184 ·
メンテナーはふだん 1 日以内に返信