Skip to content

perf(agentic): pipeline session admission and resource reuse - #628

Merged
yuanlehome merged 20 commits into
redai-studio:mainfrom
yuanlehome:feat/agentic-fully-async-oversampling
Nov 17, 2026
Merged

yuanlehome merged 20 commits into
redai-studio:mainfrom
yuanlehome:feat/agentic-fully-async-oversampling

Conversation

@yuanlehome

@yuanlehome yuanlehome commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

  • 在统一 Agentic Runtime 中默认启用 Session 独立生成,覆盖训练和 Eval,与具体任务无关。
  • 将结果发布、逻辑 Group 名额归还与物理清理解耦,减少准备屏障和清理尾延迟。
  • Mini SWE 统一使用 Python 客户端与逐 Session 监督进程,新增 4 卡训练+4 卡 PD rollout、Prefill HiCache 的 fully async Blackwell recipe,支持 128K 上下文、100 turns,不保存 checkpoint。
  • 修复 PD 配对取消与请求 ID 复用、Mini SWE 启动取消竞态、无接收端的 DCS 通信及 Mooncake 端口冲突。

Why

组内成员的环境准备、排队和收尾耗时不同。等待全组首请求到齐、等待物理清理完成后再交付结果和归还逻辑名额,会延迟后续任务进入,降低 rollout 吞吐。

How

  • Group 注册后即可获得 Runtime lease;成员自己的请求就绪且生成 gate 打开后独立运行。奖励、过滤、补采样和导出仍按原始完整 Group 处理。
  • Session 发布结果后退出逻辑驻留,Group 完成或丢弃后归还逻辑名额;进程及后端清理在后台执行,清理失败记录 warning,不撤销已发布的有效结果。
  • 跨步保留 Session/请求身份,协调暂停、恢复与迟到请求。首请求尚未全部到齐的 Group 不计入 fully async interrupted credit;结束时清理已注册但未 lease 的 Prepare 工作。
  • Agent 命令负责工具、容器和远程任务清理,Relax 通过独立监督进程兜底本地后代回收。Mini SWE 服务端仍确认进程和容器释放,客户端校验 Session 身份及 nonce 后接受成功结果。

Scope and compatibility

  • 无需容量优化开关;--agentic-concurrency 仍限制逻辑 Group 数,--n-samples-per-prompt 决定每组成员数。物理配额由执行器约束,后台残留不受逻辑并发数硬限制。
  • 支持同步、过采样/补采样、fully async、partial rollout、prelaunch 和符合原约束的 dynamic GBS。Dynamic GBS 仅支持 colocate,要求 partial rollout 且过采样大于 rollout batch,不支持 fully async。Fully async 自带跨步留存;与 partial rollout 同时开启尚未单独完成实验验证。
  • 首个有效推理请求有独立的 1800 秒期限,包含执行器排队时间;超时或首请求前退出按整组失败补采。--agent-timeout 仍按活跃时间计时。
  • --agent-command 直接启动程序,不再隐式执行登录 Shell;环境激活、变量展开和管道需放入显式脚本。仓库相关 examples 已适配;各任务的实际吞吐收益仍需分别验证。
  • PD 取消修复依赖仓库指定的 SGLang Router 补丁;PD/HiCache 和 Blackwell 硬件参数属于 recipe 配置,不是通用调度的前提。

Testing

  • 新调度实现 713ddaea 已完成 Mini SWE 5-step 验证:1,280 条样本、最终补采欠额为零,观测到的任务进程和容器完成释放。
  • 此前原生 Rust Router 57 项 HTTP 回归通过,补丁在固定源码上以 --fuzz=0 重放一致;未据此宣称当前完整镜像已重新验证。

保留此前 20-step 容量 ON/OFF 实验的性能对比:

四卡合计有效吞吐 OFF ON 变化
Rollout tokens/s 4,723.49 5,327.95 +12.80%

两组采用相同模型、GPU 和 128 个物理槽位;ON 使用当时的容量 128/组并发 48,OFF 使用组并发 16,以适配旧组级屏障。速率按总有效 token/总 rollout 时间计算。两组均完成20次训练更新,最终资源和补采样欠额归零,奖励测试超时仍按失败并替换整组处理。

Type of Change

  • Bug fix
  • Performance improvement
  • Documentation update
  • Breaking change: agent-command no longer uses an implicit login shell

@yuanlehome
yuanlehome requested review from a team and a balanced review from Copilot November 11, 2026 04:47
@rai-studio-bot

rai-studio-bot commented Nov 11, 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 · 已审批:NINGBENZHE
团队审批(relax-block-reviewers) ✅ 1/1 · 已审批:NINGBENZHE
CI ✅ 已通过

@rai-studio-bot

rai-studio-bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: ✅ 已通过

审查版本: 5d101c7

目标分支: main

已完成当前版本复审,未确认未解决的代码缺陷。增量仅修复 async progress 测试收尾:原 FIFO/EOS/补采欠额断言保留,三个原失败用例在当前 head 的 CPU CI 均通过;PR 正文问题已解决。真实 Ray、远程执行器/Apptainer、多节点训练和 Router 重建未在本轮独立验证。

审查阶段进度范围与结果
常规审查 ✅ 已完成 固定基底未变,68 路径归属保持接收;复用上一版本已完成的源码与契约核查,确认生产、示例、文档和 skill 全部未变。PR 正文已区分逻辑并发、外部物理配额、命令清理责任及历史实验。
深度审查 ✅ 已完成 复核唯一增量与 async progress harness:删除不存在的方法调用,改查 tools 为空和所有 Group 任务结束,保留原有行为断言。当前 CPU job 133949775482(run 44057243632、attempt 1、Python 3.12.3)日志确认三个原失败用例均 PASSED;未本地重复运行,也未将受控 RPC/后端测试等同真实分布式或沙箱验收。

审查发现

待处理
编号 严重性 问题状态规则来源
暂无待处理的记录。
已解决或已取代
编号 严重性 问题状态规则来源
F1 Medium severity 同步迁移保留的 Runtime 回归夹具 ✅ 已解决 —
F2 Medium severity 释放确认未知时保留可重验的 owner 与凭据 ➖ 已被后续变更取代 物理释放未知时保留 owner 供 shutdown 重试
F3 Medium severity 同步移除 PR 说明中的旧配额与回执保证 ✅ 已解决 逻辑 Group 并发与外部物理配额边界

改进建议(非阻塞)

拆分

💡 1 个拆分方案

非阻塞建议维持七部分:完整 Group 生命周期保持原子,命令启动与必要示例迁移一起落地,Mini SWE 配套迁移;Router、DCS、端口修复独立,Blackwell 配方最后组装。固定差异共 68 路径、6724 行;仅静态核对拆分,未执行拆分后的测试或硬件验收。

箭头表示前置部分 → 后续部分;目标分支为 main。

flowchart LR
    target["目标分支"]
A["PR A"]
target --> A
B["PR B"]
A --> B
C["PR C"]
B --> C
D["PR D"]
target --> D
E["PR E"]
target --> E
F["PR F"]
target --> F
G["PR G"]
C --> G
D --> G
E --> G
F --> G
Loading
部分PR 主题内容与范围验证
A Group 租用与生命周期 保留 pipeline 三文件、agentic/rollout.py、session/service.py 全量:注册即租用、成员独立生成、1800 秒首 IR 期限、完整 Group 结果与补采样、Prepare 丢弃、后台清理、LoRA 释放及吞吐指标。携带 async_progress 当前完成断言、eager_session_generation、test_agentic_rollout、obs_isolation、observability 的非 managed-agent hunks,以及四份双语指南和八份 skill 文件中除 B 命令段落、G recipe 段落外的全部变更。 拟运行 eager/async_progress 及相关 rollout、observability、obs_isolation 回归,覆盖 train/Eval、迟到首请求、暂停恢复、失败补偿和清理不阻塞导出。CPU 边界替身不能证明真实 Ray、GPU、跨步训练或外部资源释放。
B 命令启动与回收 一起交付 runner/ipc.py、arguments.py 帮助文字及全部非 Mini SWE 示例:直接 argv 启动、root 优先 SIGTERM、独立 subreaper、目录归属、协议 v2、20 个显式 bash 调用迁移、README 和三个 agent 的清理。携带 runner_command/root_exit、agent_command_cleanup、NeMo 信号测试、observability 的 managed-agent hunks及指南/skill 的命令与信号回收段落;root 先退出、后代随后回收建立在 A 的逻辑退役契约上。 拟验证真实本地进程和 Unix transport 的引号参数、无隐式 shell、root 清理窗口、脱离进程组后代回收及自然/异常退出,并验证示例根 SIGTERM。运行时、协议双方和调用方迁移应同版验证。
C Mini SWE 任务生命周期 一起交付 agent_client.py/.sh、agent_server.py、session_process.py 及 client_retry、agent_server、mini_swe_client、resource_release 四组测试,包含幂等创建、重试取消、进程/容器释放、跨进程奖励限流、max turns 和可恢复请求等待。释放确认仅为客户端/服务端同步部署的 Mini SWE 私有协议,40 秒取消等待依赖 B 的 root 终止宽限期。 拟验证丢失创建响应、启动取消竞态、重复取消、协议身份和未确认释放。随后用真实 Apptainer 检查正常/取消任务的实例、后代和奖励槽位释放,CPU 假服务不能替代。
D PD 取消与 RID 复用 仅携带 v0.3.2-9daabcd-pd-dp-aware.patch 的直接差异及必要偏移调整,保留 base 已有 DP 路由/logprob 定制,增加配对取消、响应收敛和 RID 安全复用。它消费 base 已有的 rid/abort_request 接口,可独立于 A/B/C 落地。 拟在固定 Router 源码 9daabcd801c861088d93b8ce8a2a831490ce4bee 严格重放补丁并构建,验证双向取消、迟到注册、慢响应体、未确认取消和 RID 复用 HTTP 行为。历史通过数量不作为当前补丁或镜像的验证结果。
E DCS 空接收组 交付 device_direct.py 的空 actor_fwd/reference 拓扑跳过、发送/结束标记保护和非空未初始化报错,连同 test_empty_actor_fwd_ref_group.py 及 test_lora_training_publication.py 的单行 fixture 更新。沿用现有拓扑协议,可独立落地。 拟运行空组、reference-only、非空未初始化、跨步骤 metadata/stop 和 LoRA 发布回归。CPU 提取生产方法的测试仍需真实多 rank 权重同步验证补充。
F Mooncake RPC 端口 仅交付 distributed/ray/rollout.py 中 EngineGroup 的 MC_MIN_RPC_PORT/MC_MAX_RPC_PORT 默认值及环境覆盖行为。65001–65500 已由固定 base 的 ray-job.sh 保留,无须复制启动器变更。 拟检查实际 EngineGroup 子进程收到默认范围及用户覆盖,并验证 Mooncake 与 HTTP 端口不冲突。当前 delta 无专用回归,不能据此宣称部署通过。
G Blackwell PD recipe 交付新增 Blackwell shell/YAML、test_rloo_policy_loss_dispatch.py 新增 streamed GRPO/TIS 数值用例,以及双语指南的 recipe 小节、integration-contract 的组装小节与 SKILL.md 对应 recipe hunks。共享文件按段落从 A/B 分配,仅本层引入新脚本链接,七部分合并后完整保留固定 head 的最终树。 拟验证原生参数解析、脚本入口及新增 loss 数值/梯度,再在目标八卡 4+4 PD/HiCache/Mooncake 环境检查完整 Group、真实 optimizer update、补采样和退出释放。CPU 数值回归不能证明硬件 recipe 可用。
如何按依赖提交(stack)

作者 yuanlehome 的 author_association 为 MEMBER,head 为 yuanlehome/Relax、base 为 redai-studio/Relax;本轮只读 collaborator permission 接口重新确认其上游权限为 write。

先按表重组混合提交,每部分携带对应测试和文档;逐层验证,并核对顶层最终树与原 PR 一致。独立部分各自向目标分支开普通 PR;只将有依赖的线性链组成 stack,分叉或多前置依赖按图分别安排提交。

有上游写权限: 将各层分支放在上游仓库,在已按依赖拆好的一条分支链上注册并提交(替换目标分支与分支名):

gh stack init --base <target> <layer-1> <layer-2>
gh stack view
gh stack submit

下层更新后用 gh stack rebase 调整上层,或用 gh stack sync 同步整条链。上述命令管理已拆好的分支,不会自动拆开混合提交。参见 gh-stack 使用说明。

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

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

文件结论仓库维护必要性依据替代去向或方案
relax/agentic/pipeline/__init__.py
relax/agentic/pipeline/prepare.py
relax/agentic/pipeline/runtime.py
relax/agentic/rollout.py
relax/agentic/runner/ipc.py
relax/agentic/session/service.py
relax/distributed/checkpoint_service/backends/device_direct.py
relax/distributed/ray/rollout.py
relax/utils/arguments.py
接收 保留独立 Session 生成、完整 Group 交付、首请求期限与命令根进程清理;通信配套改动仍在现有模块。 当前提交3c34393/6713f18/aa44d1e和代码契约;原过采样/补采样及Group导出要求。 沿用现有 Runtime、Shard、runner;移除配额/回执后的行为需重新核查,不沿用旧物理资源保证。
docker/patch/sglang-router/v0.3.2-9daabcd-pd-dp-aware.patch
接收 固定 Router 补丁继续支撑配对取消和请求 ID 复用。 现有PD与跨步暂停/恢复调用。 保留固定版本补丁目录;历史原生验收不作为新head结果。
examples/codex/r2e_gym/agent.py
examples/deepeyes_agentic/README.md
examples/deepeyes_agentic/run_deepeyes_agentic.sh
examples/deepeyes_agentic/run_deepeyes_agentic_pr.sh
examples/deepeyes_agentic/run_deepeyes_agentic_qwen35_9B_async.sh
examples/deepeyes_agentic/run_deepeyes_agentic_qwen35_9B_async_sticky.sh
examples/deepeyes_v2_agentic/app/agent.py
examples/deepeyes_v2_agentic/run_deepeyes_v2_agentic.sh
examples/deepeyes_v2_agentic/run_deepeyes_v2_agentic_klx.sh
examples/mini_swe_agent/agent_client.py
examples/mini_swe_agent/agent_client.sh
examples/mini_swe_agent/agent_server.py
examples/mini_swe_agent/pd-hicache-cpu-1p1d-tp2-blackwell.yaml
examples/mini_swe_agent/run_mini_swe_agent_pd_blackwell.sh
examples/mini_swe_agent/session_process.py
examples/nemo_gym_agentic/recipes/calendar/run-qwen3-4B-8xgpu-nemo-gym-calendar.sh
examples/nemo_gym_agentic/recipes/gsm8k/run-qwen3-4B-8xgpu-nemo-gym.sh
examples/nemo_gym_agentic/recipes/multienv-math-workplace/run-qwen3-4B-8xgpu-nemo-gym-multienv.sh
examples/nemo_gym_agentic/recipes/r2e-gym/run-qwen35-9B-8xgpu-nemo-gym-r2e.sh
examples/nemo_gym_agentic/recipes/reasoning-gym-cc/run-qwen3-4B-8xgpu-nemo-gym-reasoning-gym-cc.sh
examples/nemo_gym_agentic/recipes/workplace-assistant/run-qwen3-4B-8xgpu-nemo-gym-workplace-hybrid-async.sh
examples/nemo_gym_agentic/recipes/workplace-assistant/run-qwen3-4B-8xgpu-nemo-gym-workplace.sh
examples/on_policy_distillation/agentic_opd/alfworld/run-alfworld-grpo-qwen35-35B-A3B-8xgpu.sh
examples/on_policy_distillation/agentic_opd/alfworld/run-alfworld-opd-qwen35-35B-A3B-8xgpu.sh
examples/on_policy_distillation/agentic_opd/search_qa/run-search_qa-grpo-qwen3-1.7B-8xgpu.sh
examples/on_policy_distillation/agentic_opd/search_qa/run-search_qa-opd-qwen3-1.7B-8xgpu.sh
examples/on_policy_distillation/agentic_opd/webshop/app/agent.py
examples/on_policy_distillation/agentic_opd/webshop/run-webshop-grpo-qwen35-35B-A3B-8xgpu.sh
examples/on_policy_distillation/agentic_opd/webshop/run-webshop-opd-qwen35-35B-A3B-8xgpu.sh
examples/search_r1/run_search_r1.sh
接收 命令改用直接 argv 后,各 recipe 需显式 shell 入口;外部资源的 SIGTERM 清理由示例根进程拥有。 命令启动契约变更与新增 Codex/DeepEyes V2/WebShop 清理处理。 复用示例既有 finally/退出路径,保持特殊资源处理在示例侧。
docs/en/guide/agentic-kv-scheduling.md
docs/en/guide/agentic-rollout.md
docs/zh/guide/agentic-kv-scheduling.md
docs/zh/guide/agentic-rollout.md
接收 双语使用说明调整为逻辑并发、独立生成、固定首请求期限及最佳努力清理。 当前框架实现和示例使用契约。 留在已有双语指南;旧物理配额与回执保证必须移除或标为历史。
skills/agentic-rollout/SKILL.md
skills/agentic-rollout/references/external-agent-capacity.md
skills/agentic-rollout/references/integration-contract.md
skills/agentic-rollout/references/large-scale-rollout.md
skills/agentic-rollout/references/parameter-preflight.md
skills/agentic-rollout/references/partial-and-async-lifecycle.md
skills/agentic-rollout/references/resident-lifecycle.md
skills/agentic-rollout/references/runtime-operations.md
接收 现有Agentic指导需跟随本轮简化,避免继续要求已删除接口。 本轮移除owner/host quota及直接命令启动行为。 在既有skill引用内维护;作为审查材料,不扩展本轮权限。
tests/cpu/agentic/test_async_progress.py
tests/cpu/agentic/test_eager_session_generation.py
tests/cpu/agentic/test_runner_command.py
tests/cpu/agentic/test_runner_root_exit.py
tests/cpu/backends/megatron/test_rloo_policy_loss_dispatch.py
tests/cpu/distributed/checkpoint_service/test_empty_actor_fwd_ref_group.py
tests/cpu/distributed/checkpoint_service/test_lora_training_publication.py
tests/cpu/examples/nemo_gym_agentic/test_run_agent_app.py
tests/cpu/examples/test_agent_command_cleanup.py
tests/cpu/examples/test_mini_swe_agent_client_retry.py
tests/cpu/examples/test_mini_swe_agent_server.py
tests/cpu/examples/test_mini_swe_client.py
tests/cpu/examples/test_mini_swe_resource_release.py
tests/cpu/test_agentic_observability.py
tests/cpu/test_agentic_rollout.py
tests/cpu/utils/test_agentic_obs_isolation.py
接收 新增及迁移CPU回归覆盖完整Group、启动期限、root退出/清理和示例入口,LoRA夹具跟随空接收标志。 本轮故障风险和现有产品契约;保留明确的外部资源/GPU验证缺口。 复用实际生产路径的定向回归;新长期测试应有独立可观察契约,不依据行数删除。
Powered by Nyanpasu with gpt-6.1-sol xhigh, 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.

初步审查意见

已确认一处 Runtime 接口变更未同步迁移回归夹具的问题,定向两例均失败;目前未确认生产调度错误。常规源码检查已完成,资源释放不确定状态的重试路径仍在核查,CI 失败原因单独记录。

审查看板

Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.

Comment thread relax/agentic/pipeline/runtime.py Outdated

actor_name: str
handle: Any
node_id: str

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 · 同步迁移保留的 Runtime 回归夹具

这里新增必填 node_id,但 现有构造器 仍只传两个参数;test_resident_teacher_tracks_original_session[across_steps] 因 TypeError 在验证跨步行为前失败。同一文件的关闭条件夹具也没有 max_staleness,与本次新增的正 staleness 前提不一致。

在 584e676 上仅运行以下两例,结果为 2 failed(Python 3.12.3,CPU;没有运行整文件或硬件集成):

python -m pytest -q \
  'tests/cpu/test_agentic_rollout.py::test_resident_teacher_tracks_original_session[across_steps]' \
  'tests/cpu/test_agentic_rollout.py::test_finish_eligibility_uses_physical_debt_and_interrupted_resident_groups[True-False-True-2-0-2-True]'

请给保留夹具提供明确的节点身份及零/正 staleness 场景,并同步其 manager 调用预期,恢复原有行为断言。这是已复现的回归验证问题;生产连接器会提供这些字段,当前证据不表明生产调度错误。

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.

已确认此问题在 1831212 修复:夹具补齐节点身份,关闭条件明确使用正 staleness,并新增零 staleness 场景;原有跨步 Session、teacher logprob 和 manager 调用断言均保留。

在该 head 仅重跑本线程列出的两个用例,结果 2 passed(Python 3.12.3,CPU,23.85 秒)。这确认了本线程的夹具修复,不代表完整套件或硬件集成通过。

Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.

Copilot stopped reviewing on behalf of yuanlehome due to an error November 11, 2026 05:07

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

审查完成:有补充意见

已完成固定版本 584e676 的常规与深度审查,仍有回归验证及资源释放重试问题需要处理,详见行级意见。两个定向 CPU 用例失败;重试结论依据一次真实 launcher 最小实验及源码核查。未验证真实容器、多节点 GPU 或新 Router 镜像,CI 环境故障另列于看板。

审查看板

Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.

Comment thread relax/agentic/runner/ipc.py Outdated
Comment on lines +684 to +693
finally:
# A broken owner must never bypass launcher capability cleanup.
try:
await process.close()
except BaseException:
self.resource_released = False
raise
else:
self._process = None
self.resource_released = confirmed and self._within_cleanup_deadline()

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 · 释放确认未知时保留可重验的 owner 与凭据

若已退出的进程拥有有效回执,但首次 confirm_release() 因可恢复的读取问题返回 None,这里仍会关闭并清空 capability,随后 TemporaryDirectory 删除回执;Session 收尾 也清空 resources 并退休记录。后续 drop_group 只能重放不完整的释放 ID 集合,没有 owner 能重新确认原 lease。标准 ReceiptResourceOwner 的读取器也会将 OSError 转为未知,因此触发不必依赖迟到写入或延长过期预算。

在固定 head 的真实 Unix launcher+Session drop 最小 CPU 实验中,通过 owner 接口仅注入首次未知确认:有效匹配回执已存在,但两次 drop 均返回空集合,确认函数只调用一次,回执目录已删除。正常 owner 对照可返回释放 ID。该实验验证了重试状态丢失,没有模拟实际文件系统故障或远程容器释放。

容量账目虽然没有提前退款,但已提交 reservation 也就永远无法退休,暂时的确认失败变成不可恢复的 Group 清理失败,与本 PR 声明的后续重试行为不符。请在预算内保留绑定原 Session/nonce 的验证状态及凭据,让 drop/shutdown 能重验,确认前继续保留欠额;不需要延长已过期的 deadline。

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.

已确认 d562c20 修复本线程所指的预算内重试:runner 保留原 owner/lease/凭据并重验,Session 在必需释放仍未知时保留记录和 resources。确认前不发布终态或归还容量,确认后的精确回执可重放且只退款一次;源码中的截止时间仍沿用首次清理预算,超期不接受迟到确认。

仅运行新增回归的两个用例:test_unknown_confirmation_retries_original_lease、test_drop_retry_retains_session_and_capacity_until_confirmation,结果 2 passed(Linux、Python 3.12.3,4.49 秒)。测试使用真实 Unix launcher/本地进程组,控制回执可用性并替代 Ray 传输;没有注入真实文件系统故障,也不构成远程容器或多节点 GPU 验证。

Powered by Nyanpasu with gpt-6.1-sol xhigh, 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

With Session capacity enabled, temporary pauses can stall protected multi-turn Sessions until timeout, while outdated shard-binding and rollout-eligibility fixtures also break regression tests.

3 open issues
What changed in this PR

This PR improves Relax’s agentic rollout throughput by separating physical Session capacity from logical Group concurrency, allowing ready members to generate and released slots to be reused earlier.

Changes:

  • Add per-node Session accounting, incremental admission, and identity-bound resource-release receipts.
  • Move Mini SWE to a Python client and supervised workers; enable capacity management in PD examples and add a fully async Blackwell configuration.
  • Strengthen cancellation and cleanup handling, skip recipient-free checkpoint synchronization, and adjust Mooncake ports.
File Description
relax/​utils/​arguments.py Add resource-owner and Session-capacity options.
relax/​distributed/​ray/​rollout.py Set Mooncake RPC port defaults.
relax/​distributed/​checkpoint_service/​backends/​device_direct.py Skip synchronization when no recipients exist.
relax/​agentic/​session/​service.py Support incremental startup, eager generation, and cleanup retries.
relax/​agentic/​runner/​resources.py Define resource ownership and release-receipt contracts.
relax/​agentic/​runner/​ipc.py Integrate release verification and bounded process termination.
relax/​agentic/​rollout.py Update step closure and expose capacity metrics.
relax/​agentic/​pipeline/​session_capacity.py Track per-node reservations, grants, and confirmed releases.
relax/​agentic/​pipeline/​runtime.py Coordinate node-aware placement and Session accounting.
relax/​agentic/​pipeline/​prepare.py Release prepared streams during discard and shutdown.
relax/​agentic/​pipeline/​__init__.py Extend Session specifications and progress data.
examples/​mini_swe_agent/​session_process.py Supervise workers, descendants, and container cleanup.
examples/​mini_swe_agent/​run_mini_swe_agent_pd.sh Enable capacity management and external release receipts.
examples/​mini_swe_agent/​run_mini_swe_agent_pd_blackwell.sh Add a four-training/four-rollout GPU launch configuration.
examples/​mini_swe_agent/​pd-hicache-cpu-1p1d-tp2-blackwell.yaml Configure separate prefill/decode engines and CPU HiCache.
examples/​mini_swe_agent/​agent_server.py Manage supervised Sessions and publish release status.
examples/​mini_swe_agent/​agent_client.sh Delegate execution to the Python client.
examples/​mini_swe_agent/​agent_client.py Handle HTTP retries, cancellation, and release receipts.
docker/​patch/​sglang-router/​v0.3.2-9daabcd-pd-dp-aware.patch Coordinate paired cancellation before request-ID reuse.

Review effort: Balanced

Comment thread relax/agentic/pipeline/runtime.py Outdated

actor_name: str
handle: Any
node_id: str
Comment thread relax/agentic/rollout.py Outdated
if self.args.fully_async and not context.final_backfill:
# With zero staleness, Actor cannot clear an incomplete partition;
# keep generation open until its debt is paid.
if self.args.fully_async and not context.final_backfill and getattr(self.args, "max_staleness", 0) > 0:
Comment thread relax/agentic/session/service.py Outdated
Comment on lines +1883 to +1896
or not self._group_generation_open(group)
or session.session_id not in group.first_ir_seen_session_ids
or session.phase is not SessionPhase.ACTIVE
or session.result_cell.terminal
):
return
if session.resources is None:
raise RuntimeGroupError("Eager member has an IR without its process owner")
if not session.eager_timeout_active:
await session.resources.process.set_timeout_active(True)
session.eager_timeout_active = True
if self._group_generation_open(group) and session.phase is SessionPhase.ACTIVE:
self._mark_group_timing(group, "group_generation_open_at")
self._dispatch_queued_irs_locked(session)
yuanlehome added a commit to yuanlehome/Relax that referenced this pull request Nov 11, 2026
Document recipe integration, resource release receipts, per-node session
capacity, and compatibility with resident rollout modes in both languages
and the Agentic skill.

Include the existing session scheduling, cleanup, Mini SWE, and async
regressions. Update legacy runtime fixtures for resource reservations and
keep cold backend imports outside the OPD test's async progress deadline.

Validate the 24 CPU cases that failed on PR redai-studio#628 with no skips, along with
the previously run targeted regressions, docs build, and all pre-commit
checks. Keep validation reports and experimental artifacts outside git.

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

复审完成

已完成 1831212 的增量复审;两项原回归用例通过,未确认新的阻塞问题,现有非阻塞意见保留。新增测试覆盖容量账目与协议边界;真实容器、多节点 GPU 和 Router 重建尚未验证。

完整结果与改进建议

Powered by Nyanpasu with gpt-6.1-sol xhigh, 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.

复审通过

已完成 d562c20 的增量复审,修复符合原清理预算及确认后退款契约,两项定向回归通过;本轮未发现其他需阻止合入的问题。真实容器、多节点 GPU 和 Router 重建尚未在本轮验证,非阻塞改进建议保留。

完整结果与验证范围

Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.

@apex-mochen apex-mochen mentioned this pull request Nov 16, 2026
2 of 18 tasks
Migrate the shared agentic fixes from
48b92ee. Track physical Session
capacity using identity-bound release receipts, admit Group members
incrementally, and run ready members before the first-request barrier
while preserving complete Group export and drained fixed-step epochs.

Add a Blackwell Mini SWE HiCache recipe with GBS256, 128K context,
100 agent turns, 128 physical Sessions and checkpoint saving disabled.
Include Native Replay support and load-aware SessionShard placement.

Supervise external Session cleanup, serialize adapter event publication,
and close Ray Serve polling and background event loops during shutdown.
Retain reward-timeout failure and whole-Group replacement semantics.

Validation: both control and migrated configurations completed 20
rollout/optimizer steps with 5120 accepted samples and 5144 confirmed
physical releases each. Useful fleet rollout throughput was
4203.56 -> 4439.33 tokens/s (+5.61% observed in one A/B pair).
Both runs saved no checkpoints and restored all eight GPU occupants.
CPU regressions, real Ray lifecycle probes and pre-commit passed.
Preserve eager sessions and member capacity across rollout windows, repay
partition debt before admitting new training data, and drain surplus work
on synchronous completion and final shutdown. Fence late startup and
registration tasks so cancellation cannot leak session resources.

Add a Mini SWE 4-train/4-rollout GPU recipe with resumable model requests
and optional per-session cgroup memory isolation. Keep reward timeout
failures and whole-group replacement unchanged.

Validate with CPU regressions, real Apptainer cleanup/OOM probes, and
matched 20-step runs at 128K context and max_turns=100 without checkpoints.
The complete A/B observed +10.97% effective rollout tokens/s and +11.15%
end-to-end tokens/s; this is one measured pair, not a cross-task guarantee.
Surface bounded finalization join failures through shard progress so Runtime
collectors and protected pauses can fail without publishing a result or
refunding resources before cleanup completes.

Allow failed pre-cleanup finish owners and failed group drops to retry while
preserving the original fatal outcome. Keep successful cleanup idempotent
and consume confirmed resource receipts once.

Add CPU regressions for late backend permit-release completion, eager and
non-eager collectors, protected pause, concurrent drops, cancellation, and
shutdown receipt replay.

Validation: 139 agentic CPU tests passed and full pre-commit passed. All five
new regressions fail against a0fef0f at the original blocked wait or cleanup
retry paths.
Restore the Mini SWE README, machine-specific YAML/launch recipes and all
test changes to upstream/main in the committed tree. Preserve their full
versions outside Git and restore them locally after committing.

Drop the legacy SGLang 0.5.17 compatibility patch from the PR; the current
installed SGLang source already contains the Mamba H2D/COW ordering fix.
Keep the agent_client.sh resource-protocol entry point and runtime code.

Validation: all 16 pre-commit hooks pass. The restored upstream rollout
and observability tests report 169 passed and 18 failed; their interface
and expectation adaptations remain local as requested.
Remove native replay recording and its configuration and lifecycle hooks
from the committed runtime. Keep the complete implementation locally.

Move Ray-specific router and async-loop shutdown compatibility out of
the PR while preserving nonzero exits for cleanup errors and watchdog
timeouts. Session finalization retries and release accounting are unchanged.

Validation: 323 related CPU regressions passed using the locally retained
test adaptations; seven Ray shutdown hook tests were deselected and the
removed recorder/router modules were outside this core suite. All 16
pre-commit hooks passed. No GPU or end-to-end run was performed.
Confirm Session resource release through case-independent owner contracts.
Provide managed process-group and identity-bound external receipt owners,
validate custom adapters before admission, and never refund uncertain launches
or failed/timed-out cleanup.

Remove fixed-step and standalone eager branches. Keep one eager lifecycle
with synchronous drain fences and fully-async resident-state retention.

Always run Mini SWE through the Python client and supervised workers. Keep
the shell as an exec wrapper, remove both legacy selection switches, and
publish queued cancellation and release proof atomically.

Validation: 361 core CPU tests, 16 Mini SWE tests, 5 delegated-cgroup fault
tests, and 11 local recipe checks passed; all 16 pre-commit hooks passed.
Seven local-only Ray compatibility cases were outside the core suite.
Regression tests and tuned recipes remain local as requested; no GPU run.
Let per-node train Session capacity enable incremental startup and eager
generation together. Preserve ordinary evaluation and no-capacity paths,
fully async retention, physical release accounting and unsupported-mode
validation. Remove the redundant scheduling flags and mode branches.

Remove the optional Mini SWE cgroup memory extension from tracked code
while retaining supervision and verified container/descendant cleanup.

Validation: 306 core and 22 Mini SWE regressions passed against the
simplified source. Regression tests and experimental extensions remain local.
Remove hot-path experiment logs and unreachable scheduling branches.
Keep the global training exit policy outside the agentic change.
Retain configurable Mooncake RPC defaults in the reserved upper port
range to avoid overlap with rollout HTTP port allocation.

Bound client failures through cancellation, reject mismatched receipts,
and release empty allocations when preparation fails before launch.
Keep diagnostic I/O from replacing completed supervised results.

Validation: 324 core and 33 Mini SWE regressions plus full pre-commit.
Tests and optional experiment extensions remain local.

Amend validation: 111 rollout CPU regressions and full pre-commit passed.
Support incremental Session startup and ready-member generation with partial
rollout, prelaunch and dynamic global batches under their existing constraints.
Preserve partial Session ownership across epochs, retain only never-leased
Prepare owners at synchronous boundaries, and seal dynamic surplus before
discarding final preparation.

Track submitted leases conservatively and recheck launch decisions and owners
after capacity waits to prevent duplicate Group startup across steps. Keep
confirmed resource-release accounting and cleanup failures authoritative.

Validation: 350 CPU core regressions; 442 with preserved local extensions;
full pre-commit passed. Regression tests remain local as requested. GPU
training and performance validation are deferred to the agreed experiment scope.
Preserve exact Session release receipts across failed registration, transient
client transport errors and late supervisor exits. Validate the Session owner
before dropping a resident Group, and retain unresolved capacity for cleanup.

Settle paired PD cancellation and its control responses before reusing a RID.
Skip actor_fwd/reference synchronization when the topology has no recipients.

Add a four-train/four-rollout fully async 128K PD + HiCache recipe with Session
capacity enabled, full CPU optimizer offload and block recomputation, without
checkpoint or rollout dumps. Enable Session capacity in the existing PD example
too.

Validation: 504 CPU/HTTP tests plus 21 subtests; native argument parser; pinned
Router patch replay; all-file pre-commit. Tests and experiment reports remain
local as requested.
Document recipe integration, resource release receipts, per-node session
capacity, and compatibility with resident rollout modes in both languages
and the Agentic skill.

Include the existing session scheduling, cleanup, Mini SWE, and async
regressions. Update legacy runtime fixtures for resource reservations and
keep cold backend imports outside the OPD test's async progress deadline.

Validate the 24 CPU cases that failed on PR redai-studio#628 with no skips, along with
the previously run targeted regressions, docs build, and all pre-commit
checks. Keep validation reports and experimental artifacts outside git.
Keep the original resource owner and receipt directory when release
confirmation is unknown. Preserve the Session record and capacity debit
until cleanup can be confirmed, reusing the first cleanup deadline for
every retry and rejecting late proof after it expires.

Add real-launcher regressions for retry success, no early capacity refund,
and a fixed timeout budget. Complete the observability process fixture's
group-close evidence without weakening its cleanup assertions.
A cancellation could terminate the session supervisor before it installed
signal handlers, leaving no release report and blocking capacity recovery.

Pass cancellation through a private pipe so EOF survives supervisor startup.
Skip worker launch when already cancelled, retain strict release confirmation
and the original cancellation deadline, and close owned descriptors safely.
Add regressions for startup cancellation and descriptor/process cleanup.

Validation: 94 tests and 19 subtests passed; all-file pre-commit passed.
Mini SWE capacity ON/OFF runs each completed five training updates with
aggregate functional validation.
@yuanlehome
yuanlehome force-pushed the feat/agentic-fully-async-oversampling branch from d562c20 to 838d515 Compare November 17, 2026 03:10
Keep Session generation independent within the original Group lease. Publish
results and release logical capacity before best-effort background cleanup.
Remove per-node placement, resource-owner APIs and cleanup-fatal state, with
their dependent flags, examples, documentation and tests.

Preserve main's LoRA binding, routing and release bookkeeping. Keep heartbeat
retry ownership when release fails or cleanup times out during binding.

Validation: focused Session/LoRA CPU regressions and full pre-commit passed.
No Ray/GPU or Linux subreaper validation on macOS.
Launch the configured executable directly with shlex argument parsing.
Send SIGTERM to its root first, allow its cleanup handler to run, then use
the same descendant fallback after natural or requested root exit. Treat
connection-close failures as warnings without replacing execution results.

Adapt shell-dependent example commands to explicit bash scripts.
Document the signal target, command-owned cleanup and Relax's fallback.

Validation: native supervisor and process-result CPU tests passed; Linux-only
subreaper cases skipped on macOS. Full pre-commit passed.
Keep a per-Session startup timer until its first usable IR, independent of
the active generation timeout. Early exit or startup timeout follows the
existing whole-Group drop and replenishment path for both train and Eval.

Validation: focused runtime/observation CPU tests: 233 passed, 1 optional
router case deselected. Full pre-commit passed.
Connect SIGTERM to the existing DeepEyes V2 and WebShop exit paths. Let the
Codex example notify its sandbox and wait before escalating. Keep special
resource handling inside the examples and add no Relax logging dependency.

Validation: example termination and NeMo gateway CPU tests: 14 passed.
Full pre-commit passed. Real sandbox services were not exercised.

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

初步复审意见

当前变更已移除物理配额和回执接口,但 PR 说明仍按旧设计介绍配置与保证。核心生命周期及命令根进程清理的复核尚在进行。

审查看板

非行级:PR 描述的 How、兼容范围及参数示例。

Medium severity P2 · 同步移除 PR 说明中的旧配额与回执保证

正文仍要求 --agentic-session-capacity-per-node、ReceiptResourceOwner,并用“256 个逻辑成员、128 个物理槽位”说明容量;当前实现已删除这些接口。新指南 明确 --agentic-concurrency 只限制逻辑 Group,后台清理可以晚于逻辑退休,物理配额由外部服务负责。读者照正文配置会引用不存在的参数,也会得到错误的资源占用预期。

请将正文改为当前的独立 Session 生成、完整 Group 交付、1800 秒首请求期限,以及命令根进程负责清理的契约;删除旧配额/回执用法,并标明历史吞吐和验收数据对应的旧版本。

Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.

Replace the stale _assert_epoch_drained helper call with explicit checks that
all tool groups have retired and their tasks have completed. Preserve the
cleanup assertions after simplifying the runtime test double.

Validation: reproduced all three CI failures before the change; all 17 async
progress and eager session generation tests pass afterward on Linux CPU.
Full pre-commit checks pass.

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

复审通过

已完成 5d101c7 复审,PR 说明已同步当前契约;异步进度测试保留原有行为断言,当前 CPU CI 确认三个原失败用例通过。本轮未确认新的代码缺陷;真实沙箱、多节点训练及 Router 重建尚未独立验收。

完整结果与验证范围

Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.

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

Reviewed at 5d101c7. 未发现新的阻塞性代码问题。重点检查了 Session 独立生成后的完整 Group 交付、首请求与跨步暂停恢复、逻辑退休与后台清理,以及 Mini SWE 客户端的重试和取消路径。

本地定向回归:30 passed、17 skipped,另有 19 个 subtests 通过。两个核心调度测试文件因本地依赖未齐未能运行;当前 head 的 GitHub CPU/GPU/NPU CI 均通过。真实容器回收、多节点训练和 Router 补丁未独立验证。

确认当前契约:agentic-concurrency 约束逻辑 Group,物理容量由外部执行器控制;agent-command 不再隐式启动登录 Shell。

@yuanlehome
yuanlehome merged commit 043d7a2 into redai-studio:main Nov 17, 2026
15 checks passed
dirtyDan0 added a commit to dirtyDan0/Relax that referenced this pull request Nov 29, 2026
Remove the managed, immutable multi-version LoRA publication introduced by
redai-studio#475 and redai-studio#476, and connect Agentic generation to the existing fixed-name
single-adapter path. This removes the version control subsystem, its public
configuration APIs, its Session ownership protocol, and its custom SGLang
control endpoints. Keep the original LoRA training and weight-transfer
paths together with the independent correctness fixes carried by those PRs.

1. The capability Relax already had

Before redai-studio#475 and redai-studio#476, Relax could train LoRA with either merge mode or
adapter mode. Merge mode folds the learned delta into the base weights
before transferring them to inference. Adapter mode sends the frozen base
once and subsequently transfers the adapter under the fixed name
relax_policy_lora. Colocate uses the existing in-memory tensor loading
path. Fully asynchronous training uses the existing bucketed NCCL path.
Ordinary rollout generation selects that adapter by sending its name as
lora_path in the native SGLang request.

That single-adapter transport is useful on its own. It reduces the amount
of weight data sent at each synchronization point. It already existed
before the version-publication PRs and remains the serving contract after
this removal. The inference engine can use its existing pause, cache
flush, same-name replacement, and resume sequence when weights change.

2. The concurrency problem that motivated the original feature

The reference was Miles #3127. Its motivating example has adapters A, B,
and C sharing a frozen base. They represent separate training identities
with their own data and training progress. When A finishes an update and
publishes A@2, existing generation using B or C should be able to continue.
An engine-wide pause and cache flush interrupts those independent tasks.
Miles addresses this by staging a fresh adapter name, transferring its
complete weights, validating the update, and opening it for sampling after
commit. The weight-update session in that path is a begin/send/end
transfer transaction.

Relax also has a possible overlap window in fully asynchronous training.
A new snapshot of its single training policy can be transferred while
requests using an earlier snapshot are still generating. The distinction
between separate training identities and successive versions of one
policy matters when choosing which parts of the reference to adopt.
Relax's integration continued to train one adapter with one current
optimizer state. It did not introduce independent A/B/C training jobs.

3. How the Relax requirement became substantially stronger

Task 7 explicitly required an Agent Session to bind a version on its first
generation and keep it through later tool turns, retries, and abort/resume.
RFC redai-studio#418 made that requirement concrete through a central version owner,
Session registrations, capacity accounting, and periodic reconciliation.
redai-studio#475 supplied the immutable identity and state machine. redai-studio#476 connected
that state to training export, engine loading, and resident Agent Sessions.
The broader contract was already present in the task and RFC before the
implementation was integrated.

The important change in scope was the lifetime of the version reference.
An inference request needs its selected weights while it can still be
forwarded, retried, queued, or executing. Whole-Session binding also keeps
the weights alive while an Agent has no inference request and is waiting
on a tool. A slow tool can therefore keep an old version resident across
several training updates. At the configured version limit, publication
must wait or skip until those Sessions release their references.

Whole-Session consistency is an additional sampling policy that needs its
own algorithmic or workload justification. The existing full-weight path
can use updated weights after rollout interruption and resumption. LoRA
training also continues to optimize the current adapter, including when
its batch contains samples produced by older versions. Keeping a Session
on an old inference version does not select that old adapter for its
training forward pass or make the batch automatically on-policy.

The managed publication mode made this stronger policy inseparable from
its concurrent-update mechanism. As a result, ordinary Agent execution
became an owner of inference-weight retention and cleanup.

4. How subsequent upstream work inherited the LoRA contract

The compatibility history helps explain the selective removal. The later
commits generally carried the Session-binding rules through changes to
shared infrastructure. Their fixes have value independently of the
sampling policy that originally required the version manager. The
following observations come from the upstream history through eb0ec97.
They describe observable code and test changes. Benefit and cost still
require a separate workload evaluation.

- redai-studio#628, 043d7a2, reworked Agentic admission and resource reuse. It kept
  lora_key, lora_binding, and the existing Session version selection. It
  changed finalization so a logical result could be published before the
  physical cleanup completed. To make that work with managed LoRA,
  _release_lora_session recorded a pending release before waiting for a
  binding task. If cleanup timed out during the wait, heartbeat still had
  responsibility for retrying the release. Its revised test explicitly
  allowed a terminal Session result while the old version's session_count
  remained one, then expected zero after background cleanup completed.
  This is a compatibility repair around an existing Session reference.
  Retain independent Session progress, result publication, background
  cleanup, and unconfirmed-request ownership. Withdraw the additional
  version reference and its pending-release/heartbeat protocol.

- redai-studio#655, d0e00f3, developed ordinary Qwen3.8 LoRA training and repaired the
  fixed-name adapter update failure path. The pre-existing managed branch
  remained alongside it. The important correction was that one rank's
  adapter-push failure had to reach all training ranks before any of them
  resumed generation or marked the new weights loaded. Keep that failure
  agreement and the ordinary model/adapter support. It does not depend on
  storing immutable versions or binding an Agent Session.

- redai-studio#720, 0f6dac5, addressed ordinary policy-sample and weight-sync
  consistency, including the effective checkpoint and quantization used by
  inference receivers. Its new sender and quantization tests were added to
  test_actor_lora_publication.py, which already hosted the managed LoRA
  tests. This made a file created for version publication contain useful
  ordinary synchronization coverage. Retain those tests in the original
  file and retain the receiver/configuration checks. Remove cases whose
  contract requires the deleted publication service.

- redai-studio#761, 21b3662, introduced shared router and multimodal replay ownership.
  It kept both the managed direct-engine transport and the normal router
  transport, wrapping them with post_generation_request. It added
  _BackendAttempt with the actual wire RID, target set, and send_done state.
  An abort acknowledgement arriving before a delayed generate request
  settled could not release ownership. _pending_backend_cleanups kept a
  Session alive while backend cleanup was unconfirmed. Managed tests also
  held session_count until a failed abort or release was safely retried.
  These changes show how a Session-bound weight reference had to follow
  the newer request-ownership model. Keep wire-RID tracking, replay leases,
  abort ordering and pending backend cleanup. Remove the separate managed
  transport, Session version reference, and LoRA release RPCs.

- redai-studio#791, 7354e4f, moved post-training inference coordination out of training
  ranks into the Actor component and inference_sync.py. It preserved the
  managed bypass of ordinary rollout-update readiness and completion
  handshakes. To select that behavior, the component queried
  get_lora_training_config and passed _managed_lora_publication through the
  shared coordinator. A feature-specific assumption therefore moved into
  the component-level orchestration API. Retain the once-per-group
  coordination, evaluation and metric settlement. Delete the old
  configuration lookup, managed parameter, and handshake bypasses.

- redai-studio#705, 50eb517, added local inference recovery around that coordinator.
  rebind_rollout_manager refreshed the managed configuration when replacing
  an inference target, and RecoveryGate supplied settlement and retry
  boundaries around training and weight synchronization. This continued
  the compatibility contract at a new lifecycle entry point. Keep rebind,
  RecoveryGate, waiting for all participating ranks, and verification of
  the expected replacement receivers. Rebinding the normal manager can
  proceed through these mechanisms after the version configuration query
  is removed.

- redai-studio#804, 8c11399, hardened ordinary multimodal IPC and request cleanup. Its
  interaction with the managed-LoRA test file was an additional fixture
  binding for _finish_ipc_dispatch. Preserve the production IPC lifecycle
  corrections and their ordinary tests. The fixture-only increment
  disappears with the removed feature test file. While rebasing the
  retained SGLang patch, keep the required IPC method bindings and use one
  consistent fixture adaptation where the old and new patch sections
  address the same lifecycle fields. Verify the resulting patch by
  applying it to the actual pinned source.

- redai-studio#805, 198f9a6, replaced the router infrastructure while keeping the LoRA
  branches around it. redai-studio#828, 250eca5, converted fault-tolerance and health
  arguments to direct reads inside the managed configuration checks. Keep
  the native routing and ordinary argument handling. The configuration
  checks that belonged exclusively to the removed version service are
  removed together with that service.

The version manager, runtime, training publisher, and managed engine
client under relax/engine/lora_versions and lora_client.py have identical
contents at redai-studio#476 and upstream eb0ec97. The repository's managed
configuration calls still occur in definitions and tests, with no training
script or example adding an automatic activation path. This establishes
how the in-repository integration evolved. External callers and deployments
are outside this source inspection.

The resulting pattern is that shared scheduling, replay, synchronization,
and recovery improved while continuing to honor a strong existing
Session contract. Maintaining that contract required repeated work in
surrounding systems even as the version-control core remained fixed.
A compatibility test demonstrates that a refactor respected its existing
contract. The justification for keeping whole-Session version pinning also
needs evidence that its sampling semantics and retention cost fit Relax's
workloads.

This removal follows those responsibility boundaries. Preserve each
independent correction at its existing owner and preserve the ordinary
single-adapter update path. Withdraw the version owner, cross-Session
weight-retention policy, dedicated transport and control APIs that caused
those systems to depend on managed publication. Reversing the original
PRs mechanically would also discard later useful work, so each affected
path is reduced to its ordinary behavior and its independent protections.

5. The concrete initialization conflict exposed by first-step prelaunch

The integration assigned a SessionKey in start_group only when a LoRA
runtime had already been installed. set_lora_runtime rejected a Shard with
any existing Groups. RolloutManager first synchronized and published the
initial adapter, then injected the runtime into the Shard fleet.

First-step prelaunch deliberately constructs PREPARE Groups before engine
initialization is complete. Their first inference requests remain queued
behind Runtime admission. Those Groups are safe to prepare before weights
are available, but the separate empty-Group configuration invariant still
rejects them. Merely deleting that check would also be unsafe. A Session
created before configuration could lack its key, and the old dispatch
branch used the presence of that key to select managed generation.

The implementation actually bound weights at the first permitted
inference dispatch. Nevertheless, its earlier key-allocation and runtime
injection rules imposed a stricter construction order. This coupled Agent
startup to initial weight publication and prevented the intended overlap
between preparing Agents and initializing inference engines.

This affected runs that explicitly configured managed publication. The
ordinary training scripts did not automatically enable that API-only mode.

6. Why the managed subsystem is removed

The additional policy required a dedicated LoRAVersionRuntime Ray actor,
SessionKey allocation, per-Session binding tasks, Shard registration,
release retries, heartbeats, sequence watermarks, engine inventory,
publication attempts, capacity states, and shutdown calls back into Shards.
Generation also acquired a LoRA-specific route directly to a verified
engine. Those responsibilities crossed training, rollout orchestration,
Agent lifetime management, and inference transport.

The integration further introduced shared-file snapshot publication and
an extra training control path alongside the working IPC/NCCL adapter
updates. Its automatic publication required a fixed Agentic/Megatron
fully-async pool and disabled recovery and several engine configurations.
These restrictions and ownership rules made the feature expensive to
maintain and exposed the initialization conflict described above.

The existing Agentic rollout-step boundary still pauses and aborts active
requests according to its scheduling rules. Resuming a Session on its old
adapter preserves weight identity across that interruption. It does not
establish uninterrupted execution for the entire Agent. Concurrent adapter
publication has a valid narrower purpose, but retaining the complete
Session-bound subsystem requires evidence for its stronger contract and
its integration cost. The feature is withdrawn here with that boundary
made explicit.

7. What this commit removes and restores

- Delete relax/engine/lora_versions, including immutable snapshot identity,
  shared-file artifacts, the version state machine, publisher, training
  publication coordinator, and the dedicated Ray actor.
- Delete the managed SGLang LoRA client and the Relax-specific inventory,
  load, fencing, and reclamation control protocol from the 0.5.17, 0.5.20,
  and 0.5.21 dependency patches.
- Remove RolloutManager's managed configuration, publication and actor-handle
  APIs, the publication concurrency group, and feature-specific fixed-pool
  restrictions on normal lifecycle operations.
- Remove Agentic runtime injection, SessionKey and version state, binding
  tasks, heartbeats, release watermarks, version metadata overrides, and
  LoRA-specific direct-engine generation and endpoint tracking.
- Remove the training publication configuration, topology lease, publication
  result handling, and the managed bypasses of normal weight-update
  readiness and completion handshakes. Retain the shared inference-sync
  implementation and its later recovery integration.
- Delete tests whose product contract disappears with the version manager,
  managed configuration, immutable publication, or whole-Session binding.
  Adapt mixed tests to exercise ordinary router, replay and request cleanup.
  Keep their original file names and their independent assertions.

SGLang's native ability to load named adapters remains available. The
removed API is Relax's additional managed publication and Session-binding
layer. Manual users of configure_lora_training, configure_lora_versions,
or get_lora_version_runtime must move to the ordinary adapter-mode path.

8. What is kept, and why each part remains useful

The fixed name relax_policy_lora, existing adapter export and gather,
colocated tensor transport, fully asynchronous NCCL buckets, merge mode,
and ordinary rollout request construction all remain in place. Ordinary
LoRA updates retain the existing scheduling and synchronization contract.
The later PRs also contain independent changes that were integrated around
the publication code. Retain those changes through their ordinary paths.

- redai-studio#655 keeps Qwen3.8 LoRA training and adapter export support. In the normal
  DeviceDirectBackend update, all training ranks reduce the adapter-push
  failure flag. A failed push raises before continue_generation, and only
  a confirmed successful push sets adapter_loaded and base_sync_done. This
  prevents rollout from using a partially updated adapter.
- redai-studio#628 keeps independent progress of Sessions within a Group and publishes
  the logical Session result before scheduling process and backend cleanup.
  _pending_backend_cleanups retains ownership of unconfirmed requests so
  cleanup can finish safely after logical retirement. The empty
  actor_fwd/reference-group gate also remains, avoiding communication to
  recipients that do not exist. Remove the separate LoRA Session-release
  and heartbeat work from this cleanup path.
- redai-studio#640 keeps synchronization of same-checkpoint NEXTN draft weights. The
  normal model and draft synchronization path continues to determine which
  inference weights are transferred.
- redai-studio#720 keeps effective receiver-checkpoint and quantization configuration
  during weight conversion and transfer. Its ordinary quantization cases
  remain in test_actor_lora_publication.py under the original file name.
  The file name alone does not make these cases publication-specific.
- redai-studio#761 keeps router and multimodal replay, response manifests, and cleanup
  using the actual wire request ID. Mixed replay tests use the ordinary
  router transport after removal of the LoRA-specific direct-engine path.
  Their success, lost-response, and late-publication expectations remain.
- redai-studio#791 keeps post-training inference coordination in the Actor component
  and inference_sync.py. Readiness checks, weight synchronization,
  evaluation completion, and metric settlement still run through the shared
  coordinator. Remove the managed flag and its handshake bypasses.
- redai-studio#705 keeps local inference recovery, RolloutManager rebinding,
  RecoveryGate settlement, and checks that the expected replacement engine
  actors actually received their weights. Rebinding no longer queries the
  deleted managed LoRA configuration API.

Keep unrelated image and model support already integrated around the
SGLang patches, including the CUDA 12/0.5.21 image work from redai-studio#503 and the
0.5.17 DeepStack correction from redai-studio#788. The dependency version pins and
existing platform patch application paths remain the basis of validation.

The following fixes introduced with the version feature also remain
because their failure modes are reachable without multi-version serving.

- Keep Megatron Bridge wrapper forwarding of *args and **kwargs in
  _make_adapter_splice_wrapper. Upstream adapter export can pass additional
  arguments such as exclude_adapter_base_prefixes. Dropping those arguments
  breaks ordinary adapter export as well. Its existing regression remains.
- Keep max_staleness > 0 in Agentic _step_can_close. With zero staleness,
  training must consume the current partition before a later rollout can
  proceed. Closing the current partition with missing samples can leave
  training waiting for rows that a blocked next rollout would have to
  produce. The existing zero-staleness regression remains.
- Keep ordinary LoRARegistry acquire and cancellation handling. Hold the
  registry lock while looking up an adapter and incrementing its request
  count so unregister cannot pass between those operations. If acquisition
  is cancelled after incrementing part of a batch, roll those increments
  back. This protects ordinary single-adapter load/unload as well.
- Keep ordinary SGLang request cleanup fixes. Requests dispatched to the
  scheduler retain their adapter reference until terminal output or abort
  acknowledgement. Parallel-sampling children share the parent's lease and
  keep it alive until all owners finish. A retired logical parent can still
  cancel its running children. These rules protect a single adapter during
  replacement as well as any normal named-adapter request.
- Keep the request lifecycle identity checks in the 0.5.21 patch. A delayed
  abort waiter or failed handler must not delete a new request that reused
  its RID. Validate a complete batch for RID conflicts before adding states
  so a later duplicate cannot leave an earlier half-registered request.
  Preserve the associated ordinary tokenizer lifecycle tests. The other
  supported SGLang patches retain their version-appropriate cleanup fixes.
- Keep the global Bridge parameter-name initialization and its regression
  for the first synchronization. That test also exercises a non-LoRA
  configuration and protects the normal weight-transfer path.

These retained pieces have explicit behavior and failure cases independent
of the removed version manager. Their presence is intentional, so this is
a selective removal that preserves independently useful fixes.

9. The small Agentic single-adapter connection

Ordinary rollout already sent lora_path=relax_policy_lora before redai-studio#475/redai-studio#476.
The earlier Agentic native /generate request did not carry that field.
After removing managed binding, enabling the engine's LoRA support alone
would still let such a request select the base model.

Add the same mode check and fixed-name field directly where the Agentic
SGLang payload is built. The implementation adds four nonblank lines and
reuses LORA_ADAPTER_NAME. Adapter mode selects the already loaded policy
adapter. Merge mode and full-weight requests retain their existing payload.
The existing router, request ID, admission, pause/resume, abort, replay and
cleanup paths carry the request. This closes the separate single-adapter
integration gap with a local request-field change.

10. Validation and evidence limits

During this removal, the retained dependency patches were applied to fixed
SGLang 0.5.17 29481685, 0.5.20 94602c9c, and 0.5.21 e00930c5 sources. All
three normal combinations, the 0.5.21 CUDA 13 two-stage application, and
the ROCm exclusion/overlay sequence applied successfully. The retained
0.5.21 embedded ordinary request regressions passed 13 cases after adapting
their existing fixture to the preserved lifecycle registration contract.
Those checks validate source transformation and CPU request behavior.

Final targeted CPU verification passed 34 existing eager Agentic generation,
backend abort-target, checkpoint-resume and Bridge forwarding tests. Three
temporary payload checks exercise the actual Agentic request construction
with controlled HTTP for full-weight, merge and fixed-adapter requests.
Full pre-commit checks passed against the complete tree. Temporary payload
checks are removed after execution. No permanent test file is added by this commit.

CUDA devices are unavailable in the local environment. Real Megatron
training, GPU numerical equivalence, multi-node execution, and rebuilt
training images remain unverified. No throughput or latency improvement is
claimed. The removed publication GPU tests are retired with their removed
feature contract, and the ordinary LoRA training tests remain available for
hardware validation.

References

radixark/miles#3127
https://github.com/redai-studio/community/blob/main/contributor-program/2026-cohort-2/official-task.md#task-7
redai-studio#418
redai-studio#475
redai-studio#476

BREAKING CHANGE: Remove Relax's managed multi-version LoRA publication APIs
and whole-Session version-pinning behavior. Ordinary LoRA merge and
fixed-name adapter serving remain supported, with fixed-name selection
also connected to Agentic generation.
SigureMo added a commit that referenced this pull request Nov 30, 2026
#841)

## What

将 Relax 自编 SGLang Router 的上游 HTTP 连接池空闲超时统一为 4 秒,覆盖普通模式和 PD 模式。

Mini-SWE session supervisor 兼容未启用 `CONFIG_PROC_CHILDREN` 的 Linux 节点。

## Why

SGLang 的 HTTP worker 默认在连接空闲 5 秒后开始关闭。普通模式的 Router 此前允许连接在池里保留 50
秒。新请求如果恰好复用了正在关闭的连接,`/generate` 会收到连接重置,Router 将这次请求报为 `500
call_upstream_request_error`。

#495 已针对 PD 模式把空闲超时缩短到 4 秒。这次把相同的设置用于普通模式。

- [SGLang #20851](sgl-project/sglang#20851) 在
SGLang 0.5.9 上报告了同样的 5 秒 worker keep-alive 与 50 秒 SMG 连接池超时冲突。报告者随后建议由
Router 处理 reset,并关闭了 issue。
- 旧版 SGLang Model Gateway 后续通过
[#24329](sgl-project/sglang#24329) 增加了
`SMG_POOL_IDLE_TIMEOUT_SECS` 和对应的 `--pool-idle-timeout-secs` 参数,默认值为 50
秒。
- 官方新版 `sgl-router` 通过
[#44075](sgl-project/sglang#44075) 直接把连接池空闲超时设为
3 秒,让 Router 先于 worker 的 5 秒超时淘汰连接。

8 卡 H20 回归还遇到了独立的 Agent 启动故障。会话管理代码从 #628 起直接读取
`/proc/self/task/<pid>/children`。这个可选接口在调试节点的内核中未启用,supervisor 收到
`FileNotFoundError` 后在 `finally` 中向自己的 worker 发送 `SIGKILL`。worker 来不及写出
`release.worker.json`,外层因此反复报 `exit -9` 并丢弃样本。

## How

在现有 Router Rust 补丁中移除按路由模式区分超时的分支,直接给 `reqwest` 的 `pool_idle_timeout` 传入
4 秒。下次构建 Relax 镜像时,现有构建脚本会用这份补丁重编 `sglang-router` wheel。

Mini-SWE supervisor 用 `os.waitid(..., WNOWAIT)` 查看已退出的子进程,再用
`os.waitpid` 回收已收养的后代,并把主 worker 的退出状态留给 `Popen`。Supervisor 和 Agent
Server 共用子进程枚举逻辑。默认使用 `psutil.Process().children()`。遇到读取权限错误时,逐个用 psutil
核对子进程关系,跳过已退出或不可读的 PID。Supervisor 清理仍存活的后代后,继续以 `waitpid` 的 `ECHILD`
确认资源释放。Mini-SWE 独立虚拟环境的安装清单加入 `psutil`,已有环境也需补装。

## Testing

- [x] `pre-commit run --all-files` passes
- [ ] Tests pass (`pytest tests/`)
- [x] New tests added (if applicable)
- [x] Documentation updated (if applicable)

- 在锁定的 Router 源码 `9daabcd` 上通过 `git apply --check`,并核对应用后生成的 Rust 源码。
- `cu12`(Linux x86_64)镜像构建并推送成功,现有构建流程重新编译了 Router
wheel,并通过镜像内的原生模块导入检查。
- 在该 `cu12` 镜像中验证普通模式 Router 的真实连接复用行为。空闲 0.5 秒后复用原连接,空闲 4.5 秒后建立新连接。
- 原 supervisor 在关闭 `CONFIG_PROC_CHILDREN` 的节点复现 `FileNotFoundError →
SIGKILL → exit -9`。
- 权限回归用例只对一个无关 PID 注入读取错误。旧版 `ea756081` 复现
`psutil.AccessDenied`,`a6371406` 在 Linux H20 环境通过 14 个资源清理测试及 28 个 Agent
Server 测试。
- `ea756081` 用真实 Apptainer SIF 启动实例并执行命令。测试确认实例已停止、脱离 worker
进程组的子进程已回收,且 supervisor 返回 `resources_released=true`。
- 使用 `ea756081`、原 PR 的 cu12 镜像和 `psutil==7.2.2` 提交 8 卡 H20 的 CE 回归。加载
Qwen3.5-35B-A3B 真权重后,完成了 `rollout 0/20` 至 `rollout 3/20`。使用同一 Mini-SWE
脚本、模型、数据和 8 卡规模的两次旧跑次分别在第 2 和第 4 轮报
`call_upstream_request_error`。本次前四轮日志中 `Agent session failed`、`exit -9`
和 `call_upstream_request_error` 均为 0。验证范围为已完成的前四轮。

## Type of Change

- [x] 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

故障抓包显示 worker 空闲约 5 秒后发出 `FIN`,Router 随后在同一个 TCP 连接上发送新请求,收到 `RST`。

Mini-SWE 原版 supervisor 的调试日志记录了读取可选 procfs 文件失败,并从 `finally` 向该会话的
worker 发送 `SIGKILL`。

<div align="right">
    <sup>This PR is co-authored with @codex (gpt-6.2-sol xhigh)</sup>
</div>

---------

Co-authored-by: Codex <[email protected]>
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.

5 participants