[Bug] `get_seed` consumes a draw from the shared RandomState even when decision augmentation is disabled, changing the train/val split and dataset shuffle

Open Beginner friendly
#10,466 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@ryznren is already working on this.

Since Oct 29, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python
Domain
data

Research direction

Start in swift/dataset/loader.py around lines 350 and 384, then read get_seed in swift/utils/np_utils.py and check how the shared RandomState is used by post_process, interleave, and shuffle_dataset. Done when disabled decision augmentation no longer consumes a draw and the downstream train/validation split and shuffle match the prior behavior; verify with a regression test for the disabled path.

Written by the indexing model from the issue text.

Description

bug
Checklist / 检查清单
  • I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述

In swift/dataset/loader.py:384, get_seed(seed) is passed as an argument to init_decision_augment:

init_decision_augment(dataset_meta, decision_augment_config, get_seed(seed))

seed here is a stateful np.random.RandomState (converted once at loader.py:350), shared with post_process(..., random_state=seed) below and with the interleave / shuffle_dataset calls further down. get_seed consumes one draw from it (swift/utils/np_utils.py:24):
seed = random_state.randint(0, seed_max)
init_decision_augment returns immediately when augmentation is off:

if dataset_meta is None or augment_config is None:
    return

But Python evaluates arguments eagerly, so the draw is consumed even on that early return. Every downstream consumer of the shared stream is shifted by one position.

Decision augmentation is disabled by default — DataArguments._decision_augment_enabled is False unless one of decision_drop_instructions / decision_subsample_options / decision_state_as_text / decision_shuffle_fields is set, and get_dataset_kwargs() then does not even pass decision_augment_config. So the code clearly intends this path to be inert, yet it silently changes the data pipeline for every user.

Effect: upgrading 4.5.x → 4.6 silently changes (a) which samples land in train vs val, and (b) the dataset shuffle order. No error, no warning.

How to Reproduce / 如何复现

Versions: 4.5.3 → 4.6.0

Minimal reproduction of the mechanism:

import numpy as np

M = np.iinfo(np.int32).max

def get_seed(rs):
return rs.randint(0, M)

def init_decision_augment(meta, cfg=None, augment_seed=42):
if meta is None or cfg is None:
return # early return, but get_seed() already ran

# v4.5.3: post_process is the first consumer
rs = np.random.RandomState(42)
split_453 = rs.permutation(10)

# v4.6: the extra draw shifts the stream
rs = np.random.RandomState(42)
init_decision_augment('meta', None, get_seed(rs))
split_460 = rs.permutation(10)

print(split_453) # [8 1 5 0 7 2 9 4 3 6]
print(split_460) # [5 0 9 6 2 1 8 4 7 3]
print(np.array_equal(split_453, split_460)) # False

Additional Information / 补充信息

No response

Dominant language
Python
Stars
16.1k
Forks
1.8k
Avg merge
1d 17h
Merged PRs (30d)
70

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelscope/ms-swift

All issues in modelscope/ms-swift

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.