Skip to content

fix(ray): create all multinode scale-out actors - #361

Merged
SigureMo merged 2 commits into
redai-studio:mainfrom
ldemon2333:fix/ray-native-multinode-scaleout-360
Oct 16, 2026
Merged

SigureMo merged 2 commits into
redai-studio:mainfrom
ldemon2333:fix/ray-native-multinode-scaleout-360

Conversation

@ldemon2333

@ldemon2333 ldemon2333 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What

Fix ray-native scale-out for replicas spanning multiple nodes. Add a regression test for 16 GPUs per replica across 8-GPU nodes.

Why

The scale-out path reserves multiple actor ranks but initializes EngineGroup.all_engines with only one slot. Only the node-rank 0 actor is created, leaving SGLang waiting for the missing follower rank.

Fixes #360.

How

Allocate max(1, gpus_per_engine // num_gpus_per_node) engine slots per replica. Preserve the current main branch's model/config override inheritance during scale-out.

Testing

  • .venv/bin/python -m pytest tests/distributed/ray/test_scale_out_registration_order.py -q: 10 passed.

  • uvx --offline --from pre-commit==3.8.0 pre-commit run --all-files --show-diff-on-failure: all hooks passed. Version 3.8.0 is compatible with the local Git version.

  • Full test suite and real multi-node Ray/SGLang/GPU integration were not run; no multi-node GPU cluster was provided. The regression test uses mocks to verify actor slot allocation and registration forwarding.

  • pre-commit run --all-files passes

  • Tests pass (pytest tests/)

  • New tests added (if applicable)

  • Documentation updated (if applicable)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • CI/CD or build changes

Screenshots / Logs

10 passed, 32 warnings in 0.27s

@rai-studio-bot

rai-studio-bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: ✅ 已通过

审查版本: aa2ffb6

目标分支: main

已完成复审,未发现新增问题。作者 merge 最新 main(b2b0bb0b,#442)后 PR 补丁与已审版本(70cda03a)逐行一致,main 侧未改动 relax/ 源码,两个变更文件在合并树上与已审版本完全相同;合并树上回归测试重新运行通过,CI 无失败。既有核对结论(槽位分配、rank/端口与共享初始化地址、仅 node-rank 0 的注册链、回滚/恢复/缩容调用链)原样适用。多节点 GPU/NCCL 集成未运行(环境不具备)。

审查阶段进度范围与结果
常规审查 ✅ 已完成 合并树(aa2ffb64)复核:git diff 确认 PR 补丁与 70cda03 版本逐行一致且两个文件 blob 相同;main 侧 20 个变更文件均在 docker/docs/examples/tests,无 relax/ 源码;回归测试精确节点在合并树通过(1 passed);ci-refresh 无失败(fingerprint 637c5066…)。
深度审查 ✅ 已完成 必要性结论自 70cda03 轮原样迁移:合并未引入新机制,槽位分配仍为最小修复;测试 mock 粒度与环境限制结论不变,保留决策与证据见下。

没有未解决的审查问题。

提交范围 · 接收 2 · 建议移出 0 · 待确认 0

接收 2 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。

文件结论仓库维护必要性依据替代去向或方案
relax/distributed/ray/rollout.py
接收 同一核心修复在合并树上复核:多节点扩容副本按物理 actor 数分配 all_engines 槽位,使每个 follower rank 都能启动;与初始 group 路径一致。 Issue #360 与 PR 描述;merge main(b2b0bb0b)后补丁与已通过的 70cda03 范围逐行一致。 无更小替代:一行槽位分配即最小改动;构造前无法从 EngineGroup 派生该值。
tests/distributed/ray/test_scale_out_registration_order.py
接收 同一回归测试在合并树上驱动真实 _bring_up_single_replica,断言 2 节点副本的 all_engines 槽位分配。 PR Testing 小节;补丁与已审范围逐行一致。 真实多 actor 集成测试需要多节点 GPU 集群,环境不具备;mock 测试是合理放置。
精简审查与验证依据
审查范围进度结论
生产代码 ✅ 已完成 承接近轮审计:合并未改动 rollout.py 的 scale-out 相关区域(main 侧无 relax/ 源码变更),三处同形 actors_per_replica 推导的保留结论不变。
测试 ✅ 已完成 承接测试审计:同一回归测试在合并树上重新运行通过,检出能力结论(变异检查)不变。

生产代码的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
relax/distributed/ray/rollout.py 槽位分配(:2120,及 :1854 预留、:376 nodes_per_engine 的同形推导;行号以 70cda03 为准) 多节点扩容副本必须创建每个物理 actor(node_rank = rank % nnodes 依赖全部槽位存在),槽数须与调用方预留的 rank 数一致(调用链:_scale_out_ray_native → _bring_up_single_replica → EngineGroup.start_engines)。 由调用方计算一次 actors_per_replica 并作为参数传入 _bring_up_single_replica,消除三处重复推导。 保留 三处语义不同(预留 rank 数 / 待分配槽位 / 构造后 group 属性);被测方法由测试独立构造,增加参数会耦合测试;合并树复核确认补丁与已审版本逐行一致,无新机制引入。

测试的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
tests/distributed/ray/test_scale_out_registration_order.py 多节点槽位分配回归测试 当槽位分配回归为单槽(仅 node-rank 0 actor)时测试必须失败;驱动真实 _bring_up_single_replica 并断言捕获的 all_engines 与 finalize 调用。 真实多 actor 集成测试,或改为断言 start_engines 实际创建的 actor 数。 保留 合并树(aa2ffb64)上精确节点测试通过(1 passed,0.04s);此前在 70cda03 的变异检查(回退修复→测试失败)仍适用于逐行一致的测试内容。真实多节点 GPU 集成因环境不具备而不可行。
Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

@rai-studio-bot rai-studio-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查通过。已核对多节点 actor 数量、rank/bundle 分配、共享初始化地址及注册/回滚调用链,未发现本次变更新增的问题。

隔离执行真实扩容方法的四种 GPU 布局验证通过,恢复旧实现后多节点用例失败。仓库回归文件因缺少依赖跳过 9 项测试;当前无 CI 结果,未运行需要实际集群的多节点 GPU/NCCL 集成测试。

Powered by Nyanpasu with gpt-6-astra medium, please check the suggestions carefully.

RexFlux
RexFlux previously approved these changes Oct 15, 2026

@RexFlux RexFlux left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢提交PR,修复合理,请解决冲突后合入

# 🐛 Bug Fix

## Create all actors for multinode replicas

- Allocate one EngineGroup slot per physical actor during ray-native scale-out.
- Prevent SGLang from waiting for uncreated follower ranks.
- Fixes redai-studio#360.

---

# ✅ Tests

## Cover multinode actor slot allocation

- Add an 8-GPU-per-node and 16-GPU-per-replica regression test.
@ldemon2333
ldemon2333 force-pushed the fix/ray-native-multinode-scaleout-360 branch from 3cdbad1 to 70cda03 Compare October 15, 2026 10:40
@ldemon2333
ldemon2333 requested a review from a team October 15, 2026 10:40
@rai-studio-bot

rai-studio-bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @ldemon2333! 感谢你为 Relax 做出贡献!

📚 Contribution guide / 贡献指南

Describe the problem, your changes, and how you validated them. Keep each PR focused and run pre-commit run --all-files before submitting.

请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行 pre-commit run --all-files。

English contribution guide · 中文贡献指南

🛠️ CI commands / CI 指令
Command / 指令 Usage / 用途
/rerun Retry failed CI / 重跑失败的 CI
/rerun <target> Rerun a workflow or check / 重跑指定 workflow 或检查
/cancel <workflow> Cancel an entire workflow / 取消整个 workflow
/help Show commands and targets / 查看指令和 target
/review Request a code review / 请求代码 review

Put one command on the first line of a new PR comment. Rerun/cancel require PR authorship or repository write access.

在新 PR 评论的首行写一条指令。PR 作者或有仓库写权限的贡献者可以重跑、取消 CI。

CI usage and targets · CI 用法与 target

🔎 Merge requirements / 合入条件

GitHub:✅ 满足合入条件

Requirement / 条件 Status / 状态
审批人数 ✅ 1/1 · 至少 1 位有仓库 write 或更高权限的人 Approve · 已审批:SigureMo
团队审批(relax-block-reviewers) ✅ 1/1 · 已审批:SigureMo
CI ✅ 已通过

@ldemon2333

Copy link
Copy Markdown
Contributor Author

感谢提交PR,修复合理,请解决冲突后合入

已解决

@rai-studio-bot rai-studio-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查结论:通过

本轮针对 rebase 后的新 head(70cda03a)重新审查了完整范围(此前 3cdbad1 的通过仅覆盖旧基线)。修复使 _bring_up_single_replica 按 max(1, gpus_per_engine // num_gpus_per_node) 为多节点副本分配 all_engines 槽位,与初始 group 路径的槽数、_scale_out_ray_native 的 rank 预留及引擎侧 node_rank = rank % nnodes 语义一致;已核对槽位/rank/端口与共享 dist_init_addr 分配、DCS 与路由注册(仅 node-rank 0,与引擎侧 follower no-op 一致)、回滚、故障恢复、健康监控与缩容调用链。回归测试在当前 head 通过,且回退旧实现后该测试失败(已验证回归能力);补丁内容与已通过版本逐行一致,rebase 差异仅为新 main 已包含的 conftest 导入行。CI 无失败;多节点 GPU/NCCL 集成未运行(环境不具备,作者已说明)。

看板:Nyanpasu 审查看板

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

@ldemon2333

Copy link
Copy Markdown
Contributor Author

@rai-studio-bot Welcome Contributors / welcome (361) (pull_request_target) 这个 check 为什么没有通过

@SigureMo

Copy link
Copy Markdown
Member

只需要关注 required check 就好,这个不是 check

@ldemon2333

Copy link
Copy Markdown
Contributor Author

只需要关注 required check 就好,这个不是 check

哦哦,那应该没什么问题了,可以合入了 @SigureMo

@SigureMo SigureMo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@SigureMo
SigureMo enabled auto-merge (squash) October 16, 2026 06:52

@rai-studio-bot rai-studio-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查结论:通过

本轮针对 merge 最新 main 后的新 head(aa2ffb64)复审:PR 补丁与此前已审版本(70cda03a)逐行一致,main 侧(#442 CPU HiCache)未改动任何 relax/ 源码,两个变更文件在合并树上与已审版本完全相同,既有核对结论(槽位分配、rank/端口与共享初始化地址、仅 node-rank 0 的注册链、回滚/恢复/缩容调用链)原样适用。合并树上回归测试重新运行通过(1 passed);CI 无失败。多节点 GPU/NCCL 集成仍未运行(环境不具备,作者已说明)。

看板:Nyanpasu 审查看板

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

@SigureMo
SigureMo merged commit c45a6e9 into redai-studio:main Oct 16, 2026
16 checks passed
leelingrui added a commit to leelingrui/Relax that referenced this pull request Oct 17, 2026
…rence

Resolve conflicts with upstream redai-studio#433 (managed PD), redai-studio#437 (native image OPD),
redai-studio#439 (rollout utility extraction), redai-studio#361 (multinode scale-out) and the
placement factory relocation, porting their intent onto InferenceManager.

- Managed static PD: start_servers defers the Router until P/D engines are
  ready and seeds it with them; replacements still join after weight sync.
- Recovery broadcasts rank-0 failures before weight sync; pool monitors stop
  within one shared 5s budget; Controller bounds shutdown_all to 35s.
- Teacher engines get SGLANG_MM_AVOID_RETOKENIZE in config_adapters; the
  removed RELAX_OPD_PREEXPANDED_PATCH reference is dropped.
- Drop RolloutManager/TeacherManager-only code and tests; adapt new upstream
  tests to EngineGroupSpec/InferenceModelSpec and the inference manager.
leelingrui added a commit to leelingrui/Relax that referenced this pull request Oct 19, 2026
…rence

Resolve conflicts with upstream redai-studio#433 (managed PD), redai-studio#437 (native image OPD),
redai-studio#439 (rollout utility extraction), redai-studio#361 (multinode scale-out) and the
placement factory relocation, porting their intent onto InferenceManager.

- Managed static PD: start_servers defers the Router until P/D engines are
  ready and seeds it with them; replacements still join after weight sync.
- Recovery broadcasts rank-0 failures before weight sync; pool monitors stop
  within one shared 5s budget; Controller bounds shutdown_all to 35s.
- Teacher engines get SGLANG_MM_AVOID_RETOKENIZE in config_adapters; the
  removed RELAX_OPD_PREEXPANDED_PATCH reference is dropped.
- Drop RolloutManager/TeacherManager-only code and tests; adapt new upstream
  tests to EngineGroupSpec/InferenceModelSpec and the inference manager.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Ray-native scale-out hangs for multi-node replicas

4 participants