Skip to content

feat(rollout): complete managed PD disaggregation - #433

Merged
yuanlehome merged 5 commits into
redai-studio:mainfrom
yuanlehome:feat/pd-disaggregation-miniswe
Oct 14, 2026
Merged

yuanlehome merged 5 commits into
redai-studio:mainfrom
yuanlehome:feat/pd-disaggregation-miniswe

Conversation

@yuanlehome

@yuanlehome yuanlehome commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

补齐 SGLang Prefill–Decode(PD)分离在 decode 使用 power_of_two 时的托管启动、故障恢复和资源清理流程。Router 使用已经就绪的 P/D engines 初始化,注册状态确认后才对后续 rollout 流程发布。

  • 修复 SGLang v0.5.17 patch 中 prefill bootstrap 超时的跨 rank 一致性问题。
  • 新增单节点 8 GPU、2P2D TP2 的 Mini SWE Agent 启动示例;agent server 由 Ray driver 管理生命周期。
  • 新增中英文通用 PD 指南,覆盖 CLI/YAML 配置、资源分配、路由策略、适用范围和排障。

Why

托管 PD 启动需要协调 engine 就绪、router 初始化和 worker 注册,避免以空 worker 集启动 power_of_two 路由。恢复过程中还需要区分注册响应丢失与连接失败,并在复用端点前确认旧 worker 已移除,避免重复注册或误删其他代的 worker。

关闭及全局重启时,router 子进程需要由实际持有它的 RolloutManager 释放;bootstrap 超时也应参与已有 rank 共识,避免各 rank 对同一请求作出不同的出队决定。

How

  1. 启动与发布:提前确定 Agentic SessionShard 使用的稳定 router 地址;先初始化 P/D engines,再以真实 URL 和实际 prefill bootstrap port 启动 router。校验完整健康注册表后,engine 绑定已有 worker ID,避免再次 POST 注册。
  2. 恢复与注册:保留 worker ID、角色及 bootstrap 信息,确认旧注册移除后再创建替代 engine。响应丢失时查询已有注册状态;连接未建立时允许重新 POST。替代 engine 必须完成健康注册后才能使用。
  3. 失败回滚与关闭:启动失败只清理本次创建的资源;RolloutManager 在 owner actor 中停止监控、关闭 engines 并清理 router。监控停止和 engine shutdown 使用共享时间预算,Controller 在删除 deployment 前先请求释放资源。
  4. SGLang patch:将本地 bootstrap deadline 转为失败 poll 状态,纳入已有 CP/TP、PP 处理流程,并补充 CPU 回归用例。

托管静态启动路径要求原生 SGLang engines、至少 1 个 prefill 和 2 个 decode engines、dp_size=1,且不启用 DP-aware routing。Decode 使用 consistent_hashing 时仍走动态 worker 注册路径;PD 池暂不支持运行时动态扩容。

Testing

回归用例覆盖静态注册校验、注册重试、身份安全清理、启动回滚、释放超时和顺序,以及 Agentic 请求历史与生命周期字段。合并了重复测试,同时保留不同故障场景的断言。

  • 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

Start the managed P2C router with the complete set of ready prefill and
decode workers, validate and adopt their registrations, and remove stale
worker generations before recovery. Bound owner disposal and unregister
operations so startup failures and shutdown release owned resources.

Apply prefill bootstrap deadlines before TP/CP status consensus in the
SGLang patch. Preserve existing target behavior and add regressions for
registration, rollback, recovery, cleanup, and full-history Agentic input.

Add an eight-GPU 2P2D TP2 Mini SWE Agent entrypoint and English/Chinese
guides, retaining the original non-PD entrypoint unchanged.

Validation: 364 framework regressions, 8 backend deadline tests, 6 Mini SWE
server tests, full documentation build, and all-file pre-commit checks.
Single-node H20 runs cover three-round Mini SWE training for regular,
consistent-hashing PD, and P2C PD; controlled P/D process failures cover
stale-registration removal, replacement generation, and resource cleanup.
Replace Mini SWE setup, launch, and experiment-specific instructions with
workload-independent PD configuration, resource sizing, request flow,
routing limits, and troubleshooting.

Keep the English and Chinese guides aligned and correct the example
README link description to reflect the guide's general scope.

Validation: full pre-commit checks, docs build, bilingual example and
rendered-link checks, and browser inspection through the dev preview.
Remove duplicate startup rollback parameters, combine agentic request
coverage, and parameterize registration timeout retries while preserving
distinct failure semantics and session lifecycle assertions.

Validation: pre-commit --all-files passes; router registration tests pass
(55 cases). PD startup tests skip without Ray/SGLang, and agentic test
collection is blocked by missing Ray. Multi-node GPU integration is not
run because the local environment lacks the required hardware.
@yuanlehome
yuanlehome requested review from a team and a balanced review from Copilot October 13, 2026 08:17
@rai-studio-bot

rai-studio-bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @yuanlehome! 感谢你为 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 ✅ 已通过

@rai-studio-bot

rai-studio-bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: 💬 已完成 · 有补充意见

审查版本: 991ad82

目标分支: main

针对 991ad82(fix(rollout): make failed PD recovery retryable)完成 28 文件增量审查。此前两个 P2 发现经核实解决并在行内线程回复验证证据:恢复路径在替换批次 init 失败时退役整批替换引擎并复位槽位、rank 0 恢复异常经 broadcast_object_list 传给全部 rank 统一失败;启动主链路四个接线缺口(托管启动调用、标志转发、Controller dispose、init 抛错)经删除型突变实验确认已全部被测试检出。增量部分未发现新问题。最终结论 COMMENT:保留一个待作者确认问题(scale_out 对托管 PD 组的代码层保护)与一条拆分建议(4 个与 PD 无关的测试基建重构)。

审查阶段进度范围与结果
常规审查 ✅ 已完成 28 文件(991ad823 vs dce533b)准入与全量核对。相对 98cc7e3 的增量:recover() 失败回滚(shutdown/注销 DCS 与 router/kill/槽位复位/num_new_engines 归零)、megatron update_weights 恢复结果 broadcast 传播、启动接线/初始化抛错/Controller dispose/元数据记录测试;其余 25 文件沿用上一轮已核对的结论。
深度审查 ✅ 已完成 F1 修复核实:recover() 失败回滚与重试收敛依赖 remove_dead_router_worker 零匹配返回 True(幂等预清理),test_pd_recovery_rolls_back_failed_replacements_and_retries 覆盖 shutdown 超时仍 kill、存留引擎不受影响、二次恢复成功且按代清理旧注册;megatron 广播路径经审读核实(本机缺 megatron.core 优雅跳过)。F2 修复核实:在 991ad82 重跑四个删除型突变(M1 删托管启动调用、M2 删标志转发、M5 删 Controller dispose、M10 删 init raise)分别被 test_start_rollout_servers_initializes_models_before_publishing_router[True]、test_controller_shutdown_disposes_rollout_owner、test_pd_init_requires_successful_router_registration[False] 检出(98cc7e3d 上同样的突变全部漏检)。套件本地 170 passed(4 个测试文件 + engine_metadata)。

审查发现

待处理
编号 严重性 问题状态规则来源
暂无待处理的记录。
已解决或已取代
编号 严重性 问题状态规则来源
F1 Medium severity 恢复路径:必需注册失败后槽位卡死且不可重试 ✅ 已解决 —
F2 Medium severity 托管启动主链路删除后测试仍全绿 ✅ 已解决 —
提交范围 · 接收 28 · 建议移出 0 · 待确认 0

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

文件结论仓库维护必要性依据替代去向或方案
relax/distributed/ray/rollout.py
relax/backends/sglang/sglang_engine.py
relax/core/controller.py
relax/utils/health_monitor.py
接收 PR 核心:托管 PD 引擎启动、必需注册状态机、死槽恢复、有界 dispose 与 router 归属清理。 PR 目标 complete managed PD disaggregation;真实调用方为 start_rollout_servers、recover()、Controller shutdown 与健康监控。 无——这是 PR 声称交付的主契约。
relax/agentic/pipeline/runtime.py
relax/agentic/rollout.py
relax/agentic/session/admission_coordinator.py
relax/agentic/session/service.py
接收 头部 fix commit 引入的替换发布路径:引擎就绪并校验后,把已验证的托管 router 端点绑定给 agentic shard 与准入协调器,替代引擎存在前的端点预留。 Commit 98cc7e3 移除端点预留;agentic shard 与 AdmissionCoordinator 需要跨进程获得真实 router 端点后才能启动会话。 概念上可与第 1 组合并,单独分组以便显式审查跨进程发布边界。
relax/backends/megatron/actor.py
接收 991ad82 新增:rank 0 恢复结果经 broadcast_object_list 传播到全部 rank,替代原先「rank 0 异常判死、其余 rank 卡 barrier」的行为,是恢复路径可重试修复的训练侧配套。 use_fault_tolerance 下 update_weights 由全部 TP rank 执行;恢复失败须在权重同步前一致失败。 无——与 rollout.py 的 recover() 回滚共同构成失败恢复契约。
docker/patch/sglang/v0.5.17.patch
接收 在既有 pinned-SGLang patch 机制上追加:prefill bootstrap 超时并入 CP/TP MIN 共识,是 PR 声称的跨 rank 一致性修复的载体。 PR Why 段:bootstrap 超时须参与既有 rank 共识,避免各 rank 对同一请求作出不同出队决定。 上游修复更理想,但合入节奏不受本 PR 控制。
docs/.vitepress/config.mts
docs/en/guide/pd-disaggregation.md
docs/zh/guide/pd-disaggregation.md
接收 用户级通用 PD 指南(CLI/YAML、资源分配、路由策略、排障)并注册 VitePress 中英文导航;按先前维护者反馈从 Mini SWE 专属文档泛化。 仓库用户可见能力以 docs/en 与 docs/zh guide + config.mts 导航承载。 无;结构与既有 guide 一致。
examples/mini_swe_agent/README.md
examples/mini_swe_agent/pd-2p2d-tp2.yaml
examples/mini_swe_agent/run_mini_swe_agent_pd.sh
接收 可运行的单机 8 卡 2P2D TP2 示例,端到端行使新托管 PD 路径。 PR What 段承诺可运行 Mini SWE Agent PD 示例;examples/ 承载用户级示例。 无。
tests/distributed/ray/test_pd_router_startup.py
tests/backends/sglang/test_router_registration.py
tests/core/test_pd_disposal.py
tests/utils/test_health_monitor.py
tests/test_agentic_rollout.py
tests/entrypoints/test_startup_failure.py
接收 新生命周期回归族:静态注册校验、注册重试矩阵、身份安全清理、dispose 时限、agentic 端点发布与启动回滚;991ad823 补齐启动接线锚定与失败恢复回滚/重试用例。 PR Testing 段;各族对应前几组的生产契约。 无;覆盖缺口作为发现报告,不作为准入拒绝理由。
tests/backends/megatron/test_actor_rollout_recovery.py
tests/distributed/ray/test_engine_metadata.py
接收 991ad82 新增/扩展:update_weights 恢复结果共享(成功/失败、双 rank、禁止 barrier)测试;start_engines 元数据记录参数化扩展到 managed PD 初始/恢复模式。 对应本组生产改动与托管 PD 启动契约的回归保护。 无。
tests/backends/sglang/source_utils.py
tests/backends/sglang/test_kimi_k3_weight_reload.py
tests/backends/sglang/test_mxfp4_weight_reload.py
tests/backends/megatron/test_sync_checkpoint_staging.py
接收 与 PD 无关的捆绑测试基建重构:共享 sglang source-path helper 替代各文件内 isolated patch,及 checkpoint-staging 精简;已验证通过,但标记为无关打包改动。 文件仅存在于头部区间并受 pre-commit/测试契约覆盖;非 PD 契约所需。 理想情况拆分独立 PR;作为无生产耦合的纯测试重构可在本 PR 以卫生问题审查。
精简审查与验证依据
审查范围进度结论
生产代码 ✅ 已完成 覆盖托管启动/注册、端点发布、生命周期守卫、有界 dispose 与失败回滚五个机制簇,结论均为保留。头部系列自行删除了 1541d59 的端点预留机制(改为就绪后发布)并把失败恢复收敛为统一回滚路径,是 PR 内已完成的简化,记录为对照。
测试 ✅ 已完成 覆盖 7 个测试族。991ad823 后启动接线、初始化抛错、Controller dispose 与失败回滚均有真实入口锚定(删除型突变 M1/M2/M5/M10 全部被检出);各族保留:参数化保留基线用例、重试矩阵按响应类型区分语义。捆绑的 4 个无关测试重构已验证通过,建议拆分(卫生事项)。

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

范围必须保留的契约更简单的方案结论依据与限制
托管 PD 启动与注册(_start_managed_pd_router、_wait_pd_router_workers、bind_registered_pd_worker、required 注册状态机) 对外发布前注册表完整且健康;恢复替换引擎前旧注册确认移除(rollout.py 启动/恢复主链路) router 先启动 + 引擎动态注册(POST /workers 自注册) 保留 power_of_two 解码策略要求 router 启动参数携带静态 prefill_urls/decode_urls,即启动时就需要完整 decode 集合;动态注册无法在发布前校验完整注册表。已对照本机 sglang_router 0.3.2 实测 POST/GET 语义。
端点就绪后发布(start_rollout_servers → bind_agentic_router → RuntimeDomain.bind_router → shard/coordinator set_router_address) agentic shard 与 AdmissionCoordinator 跨进程获得已验证端点后,才启动会话与准入轮询 在 ingress 预留端点(1541d597 原设计,已删除);或 shard 直接读 RolloutManager 的 args 保留 shard 为独立 Ray actor、持有各自 args 副本,读不到 RolloutManager 对 args 的更新,显式发布是唯一通路;新设计同时消除了预留端口在引擎初始化窗口内被抢占的竞态与对应状态字段。
recover() 失败回滚(整批退役替换引擎 + num_new_engines 归零 + 重抛) init 失败后不留半可用 actor,下一轮恢复可重试且按代清理旧注册 只清理失败的单个槽位(无法处理多节点 pending 对端);或静默吞掉异常保留句柄(原缺陷) 保留 991ad82 的回滚把 shutdown_engines(含 DCS/router 注销与 kill)作用于整批替换槽位并复位为 None,预清理幂等(零匹配返回 True)使重试收敛;test_pd_recovery_rolls_back_failed_replacements_and_retries 固化该语义。
set_router_address 生命周期守卫;有界 dispose(monitor timeout=0 + 5s 共享 deadline、engine shutdown 15s、Controller 5s 查询 + 35s dispose) 防止端点静默替换;teardown 在 Controller 预算内完成且 engines 先于 router 停止 删除守卫直接赋值;恢复无界 join 保留 守卫把静默端点漂移变成显式错误,成本一个布尔分支;无界 join 在引擎退出慢时挂起 Controller 关闭,tests/core/test_pd_disposal.py 固定时限与顺序。

测试的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
test_pd_router_startup.py / test_router_registration.py / test_pd_disposal.py / test_actor_rollout_recovery.py / test_engine_metadata.py / test_health_monitor.py / test_agentic_rollout.py 测试族 各族针对不同故障场景与断言粒度(defer/发布/回滚/重试、注册 pending/重试、有界停止、恢复结果共享、元数据记录) 合并重复用例或删除弱断言 保留 重试矩阵按响应类型区分 pending/重试语义;回滚用例覆盖 shutdown 超时仍 kill 与二次恢复成功;删除任何一族都会重新打开对应接线或语义的检测缺口(突变实验证据)。
Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Router registration can become permanently stuck after HTTP errors, and the published router port is not actually reserved.

2 open findings
What changed in this PR

Completes managed prefill/decode disaggregation, including router lifecycle, worker recovery, shutdown handling, documentation, and an 8-GPU example.

Changes:

  • Adds managed static PD router startup, registration, recovery, and rollback.
  • Bounds monitor and engine shutdown operations.
  • Adds PD tests, documentation, SGLang patching, and Mini SWE Agent configuration.
File Description
relax/​distributed/​ray/​rollout.py Implements managed PD router lifecycle and recovery.
relax/​backends/​sglang/​sglang_engine.py Adds static worker adoption and registration handling.
relax/​core/​controller.py Disposes rollout owners before teardown.
relax/​utils/​health_monitor.py Adds bounded monitor shutdown.
tests/​distributed/​ray/​test_pd_router_startup.py Tests PD startup, recovery, and cleanup.
tests/​backends/​sglang/​test_router_registration.py Tests PD router registration behavior.
tests/​core/​test_pd_disposal.py Tests controller disposal ordering and timeouts.
tests/​utils/​test_health_monitor.py Tests bounded monitor shutdown.
tests/​test_agentic_rollout.py Expands routing and history regression coverage.
docker/​patch/​sglang/​v0.5.17.patch Makes bootstrap timeout handling rank-consistent.
examples/​mini_swe_agent/​run_mini_swe_agent_pd.sh Adds an 8-GPU PD training launcher.
examples/​mini_swe_agent/​pd-2p2d-tp2.yaml Defines the 2P2D TP2 topology.
examples/​mini_swe_agent/​README.md Documents the PD example.
docs/​en/​guide/​pd-disaggregation.md Adds the English PD guide.
docs/​zh/​guide/​pd-disaggregation.md Adds the Chinese PD guide.
docs/​.vitepress/​config.mts Adds both guides to navigation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread relax/backends/sglang/sglang_engine.py Resolved
Comment thread relax/distributed/ray/rollout.py Resolved
Bind the verified first-model router to SessionShards and admission before
rollout can start. Wait for every owner within the startup rollback boundary
instead of publishing an unbound port during engine initialization.

Retry definitively rejected worker registrations while reconciling ambiguous
responses, and update the partial-startup cleanup fixture.

Exercise installed K3, MXFP4, and Megatron checkpoint hooks directly instead
of reapplying or reconstructing deployment patches in tests. Retain patch
artifact checks for components outside the default CI image.

Validation: 98 targeted tests passed; 5 skipped for missing Megatron/CUDA.
Twelve isolated routing and lifecycle checks and all pre-commit hooks passed.
Full Ray and multi-GPU validation require the CI environment.

@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.

💬 审查完成(COMMENT)

已按当前头部 98cc7e3 完成审查(基准 main,merge-base dce533b)。托管 PD 分离的整体设计方向是成立的:引擎先于 router 启动、校验完整健康注册表后才对外发布、engine 侧绑定避免重复注册、router 清理归属实际持有它的 RolloutManager。两个 P2 问题已行内留言:

  1. 恢复路径在"必需注册失败"后槽位卡死且不可重试(relax/backends/sglang/sglang_engine.py);
  2. 托管启动主链路删除后测试仍全绿,接线未被测试锚定(tests/distributed/ray/test_pd_router_startup.py)。

另有两条非行级事项:

  • 非行级:跨文件行为确认 —— 弹性扩容(scale_out)会复用 engine_groups[0] 作为模板并经动态注册加入引擎。PR 描述已注明"PD 池暂不支持运行时动态扩容",建议确认 scale_out/scale_in 对托管 PD 组(power_of_two 静态启动)在代码层已禁用或受保护,避免模板组被扩容后经动态注册进入静态启动的 router。
  • 非行级:无关改动打包 —— tests/backends/sglang/source_utils.py、test_kimi_k3_weight_reload.py、test_mxfp4_weight_reload.py、tests/backends/megatron/test_sync_checkpoint_staging.py 是与 PD 目标无关的测试基建重构(共享 source-path helper 替代各文件内 isolated patch),已验证本地通过;拆分到独立 PR 会更干净。

发现明细与提交范围准入见审查看板。

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

Comment on lines +702 to +703
if getattr(self, "_require_router_registration", False) and self.node_rank == 0 and not registered:
raise RuntimeError("Required PD router registration failed")

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.

Medium severity P2 · 恢复路径:必需注册失败后槽位卡死且不可重试

start_engines 在引擎 init 完成前就把 actor 句柄存入 rollout_engines(relax/distributed/ray/rollout.py:680),而 recover() 只把 engine is None 的槽位视为待重建(relax/distributed/ray/rollout.py:884)。若替换引擎走到这里的必需注册失败(例如 router 短暂不可达导致 60s 就绪等待超时后在此抛出),该槽位会停留在一个"进程健康但未注册"的引擎上,后续 recover() 不会再重试,也不会清理这个半可用 actor。

后果在故障容忍路径被放大:rank 0 调用 recover_rollout_engines 是未包裹的 ray.get(relax/backends/megatron/actor.py:2871),init 异常会直接判死本轮 update_weights,其余 rank 随后卡在 barrier(actor.py:2873)。

建议:recover() 对句柄已存在但 ray.get 探测失败的槽位,先 shutdown/kill 该 actor 并把槽位复位为 None,让下一轮 recover() 重建(与托管 PD "旧注册确认移除后才复用端点" 的既有顺序兼容)。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

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.

已核实 991ad82 从两侧修复,确认解决:

  • 恢复侧:recover() 在替换批次 init 失败时对整批替换引擎执行 shutdown(10s 超时后仍 kill)、注销 DCS 与 router 并把槽位复位为 None,num_new_engines 归零后重抛(relax/distributed/ray/rollout.py:997);下一轮 recover() 重新走预清理,而 remove_dead_router_worker 对"注册表零匹配"返回 True(幂等),重试可收敛。test_pd_recovery_rolls_back_failed_replacements_and_retries 覆盖 shutdown 超时仍 kill、存留引擎不受影响、二次恢复成功且按代清理旧注册。
  • 训练侧:update_weights 把 rank 0 的恢复异常经 broadcast_object_list(显式 process_group)传给全部 rank 后统一抛出 Rollout engine recovery failed(relax/backends/megatron/actor.py:2870),原先「rank 0 判死、其余 rank 卡 barrier」的放大路径消除;test_update_weights_shares_rollout_recovery_result_before_weight_sync 覆盖成功/失败与双 rank(本机缺 megatron.core 优雅跳过,逻辑经审读核实)。


publish = Mock(side_effect=RuntimeError("startup failed") if fail_at == "publication" else None)
monkeypatch.setitem(sys.modules, "relax.agentic.rollout", SimpleNamespace(bind_agentic_router=publish))
monkeypatch.setattr(rollout_module, "_start_rollout_servers_impl", start)

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.

Medium severity P2 · 托管启动主链路删除后测试仍全绿

本文件第 235 行对 _start_rollout_servers_impl 打桩,托管启动主链路没有真实入口覆盖。变更实验(在 98cc7e3 上逐项做删除/改写后跑相关套件):

  • 从 _start_rollout_servers_impl 删除 _start_managed_pd_router 调用与端点记录 → 90 passed(基线 121)
  • require_router_registration=defer_router 改为 False → 86 passed
  • Controller.shutdown 删除 _dispose_rollout_manager() → 27 passed
  • 删除引擎 init 的必需注册 raise → 86 passed

即托管启动调用、skip/require_router_registration 标志转发、model 0 端点记录与就绪后 bind_agentic_router 发布这些接线被删除,现有断言仍会通过(#388 的同类问题)。

建议:补一条经真实 _start_rollout_servers_impl(mock 引擎组与 router 启动函数)的用例,断言 defer_router 时托管启动被调用、两个标志随 defer_router 转发、端点写入 args 且发布后才绑定 agentic;另补 Controller.shutdown 触发 dispose、init 注册失败抛 RuntimeError 的断言。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

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.

已核实,确认解决。在 991ad82 上重跑删除型突变实验(此前在 98cc7e3 上同样的突变测试仍全绿):

  • 删除 _start_rollout_servers_impl 内托管启动调用与端点记录 → test_start_rollout_servers_initializes_models_before_publishing_router[True] 失败;
  • require_router_registration=defer_router 改为 False → 同一用例失败(skip/require_router_registration 断言);
  • Controller.shutdown 删除 _dispose_rollout_manager() → test_controller_shutdown_disposes_rollout_owner 失败;
  • 删除 init 必需注册 raise → test_pd_init_requires_successful_router_registration[False] 失败。

四个接线缺口(托管启动调用、标志转发、Controller dispose、init 抛错)现在都有真实入口锚定,本发现按已解决处理。

def hooks(kimi_source):
ns = {"torch": torch, "ReplicatedLinear": object, "RMSNorm": object}
_function(ast.parse(_source_path("srt/layers/attn_residual.py").read_text()), "get_cw", ns)
_function(ast.parse(sglang_source_path("srt/layers/attn_residual.py").read_text()), "get_cw", ns)

@SigureMo SigureMo Oct 13, 2026 •

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.

话说这里用法是不是还是有点畸形?是不是应该有办法直接 import 它?

独立问题,我后面统一看看这些单测吧,感觉之前 Agent 为了过 CI 搞了一堆 hack

Retire replacement engines when initialization fails while preserving
their metadata for router cleanup on the next recovery attempt. Broadcast
the recovery result across Megatron ranks before entering weight sync.

Exercise the real startup, engine initialization, and shutdown entry points
with external I/O mocked. Cover required registration flags, publication
ordering, partial multi-node recovery cleanup, and all-rank failure handling.

@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.

💬 审查完成(COMMENT)

已按当前头部 991ad82 完成增量审查(基准 main,merge-base dce533b)。此前两个 P2 发现均已核实解决并在对应行内线程回复了验证证据:

  1. 恢复槽位卡死 —— recover() 现在在替换批次 init 失败时退役整批替换引擎(shutdown/注销/kill 并复位槽位)并重抛,下一轮重试;rank 0 的恢复异常经 broadcast_object_list 传给全部 rank 统一失败,消除 barrier 挂起。
  2. 启动主链路未被测试锚定 —— 新增经真实 _start_rollout_servers_impl 的接线用例与 init 抛错/Controller dispose 用例;在 991ad82 上重跑四个删除型突变均被现有套件检出(此前全部漏检)。

增量部分(recover() 回滚、broadcast_object_list 传播、相应测试)未发现新问题。一个此前提出、尚未回应的问题保留:弹性扩容(scale_out)以 engine_groups[0] 为模板并经动态注册加入引擎,请确认对托管 PD 组(power_of_two 静态启动)在代码层已禁用或受保护(PR 描述已注明"PD 池暂不支持运行时动态扩容");另建议将与 PD 无关的测试基建重构(tests/backends/sglang/source_utils.py 等 4 个文件)拆分独立 PR。

发现明细与提交范围准入见审查看板。

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

@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 🐾

@yuanlehome
yuanlehome merged commit e4b6bdf into redai-studio:main Oct 14, 2026
20 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.

4 participants