[Bug] examples/train/grpo/plugin/treepo 无法运行:从 swift.rewards 导入未导出的 MultiTurnScheduler 触发 ImportError
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
Checklist / 检查清单
- 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述
examples/train/grpo/plugin/treepo/ 示例无法运行:其插件文件第 12 行从错误的模块导入 MultiTurnScheduler,而 swift.rewards 并未导出该符号,触发 ImportError。
examples/train/grpo/plugin/treepo/tree_rollout_plugin.py:12:
from swift.rewards import MultiTurnScheduler, multi_turns
但 swift/rewards/__init__.py 的 _import_structure 只导出三组符号:prm(prms、PRM)、orm(orms、ORM、AsyncORM)、rm_plugin(rm_plugins)——没有 MultiTurnScheduler 和 multi_turns,二者实际位于 swift.rollout。
结果:tree_rollout.sh(TreePO 示例)在当前 main 上一启动外部插件导入即失败,示例完全不可用。
How to Reproduce / 如何复现
环境:
- ms-swift 4.6.1(官方 NPU 镜像)与 main(4.7.0.dev0)均存在此问题(两版该行代码一致)
- 任意环境即可复现,无需 GPU
最小复现:
python -c "from swift.rewards import MultiTurnScheduler"
# ImportError: cannot import name 'MultiTurnScheduler' from 'swift.rewards' (../swift/rewards/__init__.py)
或直接运行示例:
bash examples/train/grpo/plugin/treepo/tree_rollout.sh
# 外部插件导入阶段即抛出上述 ImportError
Additional Information / 补充信息
修复(一行):改为正确的模块来源,与同目录 examples/train/grpo/plugin/plugin.py:17 的正确写法保持一致:
from swift.rollout import MultiTurnScheduler, multi_turns
swift.rollout 的 __init__.py 明确导出这两个符号(MultiTurnScheduler、multi_turns 均在其导出表中)。
说明:本 issue 的调查与复现在 AI 辅助下完成(导入失败已在 4.6.1 官方镜像内实测确认)。
- 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