[Bug]: split_list(contiguous=True) creates empty leading shards and starves rank 0 when num_shards > len(list)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #10396 by @xuilen — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
Research direction
Read split_list and its tests in tests/utils/test_split_list.py; reproduce the two-item, four-shard example from the issue. Check that contiguous shards keep elements in order and place remainder items in the leading shards. The issue says a linked pull request is already open, so confirm its status before starting.
Written by the indexing model from the issue text.
Description
Checklist / 检查清单
- I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述
When calling split_list(ori_list, num_shards, contiguous=True) where num_shards > len(ori_list) (or when remainder exists across uneven shards), the function uses np.linspace(0, len(ori_list), num_shards + 1, dtype=np.int64) for slice indexing.
Because float truncation occurs when casting np.linspace to np.int64, for example with split_list([1, 2], 4, contiguous=True):
np.linspace(0, 2, 5, dtype=np.int64)produces[0, 0, 1, 1, 2].- The resulting slices are:
- Shard 0:
ori_list[0:0]->[](Rank 0 gets empty!) - Shard 1:
ori_list[0:1]->[1] - Shard 2:
ori_list[1:1]->[] - Shard 3:
ori_list[1:2]->[2]
- Shard 0:
- Resulting shards:
[[], [1], [], [2]].
This causes Rank 0 (shard 0, usually the primary/master worker in distributed data processing) to receive an empty shard [], while items are scattered across subsequent ranks.
In contrast, split_list(..., contiguous=False) and standard partitioning tools (torch.chunk, np.array_split) always pack non-empty elements into the leading shards: [[1], [2], [], []].
How to Reproduce / 如何复现
from swift.utils import split_list
# 2 items split across 4 shards with contiguous=True
res = split_list([1, 2], 4, contiguous=True)
print(res)
# Actual output: [[], [1], [], [2]] (Rank 0 gets empty list!)
# Expected output: [[1], [2], [], []] (consistent with contiguous=False and standard chunking)
Additional Information / 补充信息
Using integer arithmetic q, r = divmod(len(ori_list), num_shards) ensures balanced contiguous slices without float truncation artifacts, and places any remainder elements in the first r shards.
A patch with updated unit tests in tests/utils/test_split_list.py is ready to submit.
- 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