Skip to content

Commit 0af123b

Browse files
committed
fix
Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
1 parent 6a638fc commit 0af123b

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

tests/test_samplers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,9 @@ def test_rank_aware_sampler_second_rank_gets_cached(self):
480480
)
481481

482482
assert sampled1 == sampled2 == [0, 1, 2]
483-
# First rank returns empty consumed (not all ranks have fetched yet)
483+
# First rank already returns consumed indexes
484484
assert consumed1 == [0, 1, 2]
485-
# Last rank returns consumed when all ranks have fetched
485+
# Second rank also sees the same consumed indexes; state is then cleaned up
486486
assert consumed2 == [0, 1, 2]
487487
# State should be cleaned up
488488
assert sampler._states == {}

transfer_queue/sampler/rank_aware_sampler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,22 @@ def sample(
7575
ready samples, all available samples will be returned.
7676
dp_group: The group id of current data parallel group. Used to
7777
identify which DP group this rank belongs to.
78-
dp_world_size: Number of ranks in the data parallel group. Used to
78+
dp_world_size: Number of ranks in the data parallelism group. Used to
7979
determine when all ranks have fetched their samples.
8080
world_size: Total number of ranks across all parallelism dimensions.
8181
Used to determine when all ranks have fetched their samples.
8282
*args: Additional positional arguments (ignored).
8383
**kwargs: Additional keyword arguments (ignored).
8484
8585
Returns:
86-
List of sampled global indices of length batch_size
86+
List of sampled global indices. The length is
87+
min(batch_size, len(ready_indexes)), and may be smaller than
88+
batch_size if fewer ready samples are available.
8789
88-
List of global indices of length batch_size that should be labeled as consumed
89-
(will never be retrieved in the future)
90+
List of global indices that should be labeled as consumed
91+
(will never be retrieved by other dp_groups in the future).
9092
91-
Raise:
93+
Raises:
9294
RuntimeError: If ``world_size`` is not divisible by ``dp_world_size``.
9395
9496
Note:

0 commit comments

Comments
 (0)