Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ def run_map(self):
p = []
for thread in threads_to_run:
p.append(Process(target=self.run_map_helper, args=(thread, )))
p[thread].start()
p[-1].start()

for thread in threads_to_run:
p[thread].join()
for proc in p:
proc.join()
else:
assert self.num_threads == 1
self.run_map_helper(0)
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/runtime/test_data_efficiency.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import deepspeed
from deepspeed.accelerator import get_accelerator
import pytest
from deepspeed.runtime.data_pipeline.data_sampling.data_analyzer import DataAnalyzer
from deepspeed.runtime.data_pipeline.data_sampling.indexed_dataset import MMapIndexedDataset
from unit.common import DistributedTest
from unit.simple_model import SimpleModel, random_dataset
from deepspeed.runtime.data_pipeline.curriculum_scheduler import CurriculumScheduler
Expand Down Expand Up @@ -177,3 +179,28 @@ def data_post_process(data, data_sampler_state_dict):
model.step()
if n >= 10:
break


def identity_metric(batch):
return batch


def test_data_analyzer_runs_only_the_specific_threads(tmp_path):
# specific_threads is for rerunning some of the map threads, e.g. the ones that failed.
analyzer = DataAnalyzer(torch.arange(20),
num_threads=4,
specific_threads=[2, 3],
batch_size=2,
metric_names=["value"],
metric_functions=[identity_metric],
metric_types=["single_value_per_sample"],
metric_dtypes=[torch.int64],
save_path=str(tmp_path))
analyzer.run_map()

thread_dirs = sorted(d.name for d in (tmp_path / "value").iterdir())
assert thread_dirs == ["worker0_thread2", "worker0_thread3"]
for thread, expected in [(2, range(10, 15)), (3, range(15, 20))]:
fname = tmp_path / "value" / f"worker0_thread{thread}" / "value_sample_to_metric"
stored = MMapIndexedDataset(str(fname), skip_warmup=True)
assert [int(v[0]) for v in stored] == list(expected)
Loading