mindspore-ai / mindspore-ai/hyper-parallel
[RFC]多维并行的随机状态管理
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 53
- Forks
- 63
- Avg merge
- 23h 45m
- Merged PRs (30d)
- 63
Description
当前发现的问题
当用户没有手动设置随机状态时(manual_seed()),DTensor的op_random操作会在op_dispatch里创建默认的OffsetBasedRNGTracker(显式执行),此时会执行platform.broadcast(rng_state, 0)操作,多个stage场景下会有问题。
业界情况调研
pytorch也有类似问题:在pp场景进行 lazy_init RNGTracker时,会出现卡死问题
具体说明:https://github.com/pytorch/pytorch/pull/141223
解决办法:手动调用manual_seed方法,不同stage设置不同的seed

例如torchtitan做法:初始化的时候会将不同的stage设置不同的seed

扩展
pytorch针对这个问题的讨论:https://github.com/pytorch/pytorch/issues/140301,
问题如下:
- 当前没有考虑PP场景
- 实现过于复杂
- 用户设置的seed有可能被覆盖(根据不同场景(TP\DP等)自动执行操作)
提出的解决办法:
- 扩展接口
torch.distributed.manual_seed(seed, sharded_groups=[pp, tp, fsdp])感知到DeviceMesh及并行分布 - 全局只创建一个RNG tracker对象,统一管理
结果:没有被采纳,设计初衷和DTensor违背
hyper解决办法
补齐Dtensor下的manual_seed方法,在pp场景,当前需要用户显式调用manual_seed方法,不同的stage设置不同的seed。
后续:统一在集群拉起阶段(init_dist)由框架自动拉起,类似torchtitan。
schema_version: 1
source: gitcode
gitcode_repo: mindspore/hyper-parallel
gitcode_issue: 153
source_url: https://gitcode.com/mindspore/hyper-parallel/issues/153
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by tracing DTensor's op_random handling in op_dispatch and the default OffsetBasedRNGTracker creation, then review the existing manual_seed path. Clarify the intended PP behavior and how stage-specific seeds should be represented; done should provide a DTensor manual_seed interface that avoids the problematic default broadcast and supports distinct seeds across stages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100