mindspore-ai / mindspore-ai/hyper-parallel
[BUG] torch >= 2.8 下 fused AdamW + cpu_ram_efficient_loading 触发 device 检查失败
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 53
- Forks
- 63
- Avg merge
- 23h 45m
- Merged PRs (30d)
- 63
Description
该问题是怎么引起的?
在 torch >= 2.8 上,开启 cpu_ram_efficient_loading=True 时参数先放到 meta,再由 load_state_dict 材料化。HSDPModule.load_state_dict 忽略 assign,走 in-place(只改 Python 的 _local_tensor,不替换 param 对象)。torch >= 2.8 下这种方式 Python 层 param.device 已是真实 device、检查不出问题,但 DTensor 外壳的 C++ device 仍停在 meta;fused AdamW 在 C++ 层比对 device 时报错。torch 2.7.1 不暴露此问题。
重现步骤
同时满足以下三个条件即可复现:
- torch >= 2.8
cpu_ram_efficient_loading=True- AdamW
fused=True(如optim=adamw_torch_fused)
跑 LlamaFactory + HyperParallel 训练,在第一个 optimizer step 触发。
报错信息
RuntimeError: Tensors of the same index must be on the same device and the same dtype
except `step` tensors that can be CPU and float32/64 notwithstanding
调用栈:optimizer.step() → AdamW.step → _fused_adam → _group_tensors_by_device_and_dtype(C++ 抛)。
schema_version: 1
source: gitcode
gitcode_repo: mindspore/hyper-parallel
gitcode_issue: 198
source_url: https://gitcode.com/mindspore/hyper-parallel/issues/198
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 with HSDPModule.load_state_dict and follow optimizer.step() into AdamW._fused_adam and _group_tensors_by_device_and_dtype. Reproduce with torch >= 2.8, cpu_ram_efficient_loading=True, and fused AdamW on LlamaFactory + HyperParallel; done when the first optimizer step completes without the reported device/dtype error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100