Repository navigation
perf(agentic): pipeline session admission and resource reuse - #628
yuanlehome merged 20 commits into
Conversation
|
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 请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行 🛠️ CI commands / CI 指令
Put one command on the first line of a new PR comment. Rerun/cancel require PR authorship or repository write access. 在新 PR 评论的首行写一条指令。PR 作者或有仓库写权限的贡献者可以重跑、取消 CI。 🔎 Merge requirements / 合入条件GitHub:✅ 满足合入条件
|
Nyanpasu 审查看板审查状态: ✅ 已通过 审查版本: 5d101c7 目标分支: main 已完成当前版本复审,未确认未解决的代码缺陷。增量仅修复 async progress 测试收尾:原 FIFO/EOS/补采欠额断言保留,三个原失败用例在当前 head 的 CPU CI 均通过;PR 正文问题已解决。真实 Ray、远程执行器/Apptainer、多节点训练和 Router 重建未在本轮独立验证。
审查发现待处理
已解决或已取代
改进建议(非阻塞)拆分💡 1 个拆分方案 非阻塞建议维持七部分:完整 Group 生命周期保持原子,命令启动与必要示例迁移一起落地,Mini SWE 配套迁移;Router、DCS、端口修复独立,Blackwell 配方最后组装。固定差异共 68 路径、6724 行;仅静态核对拆分,未执行拆分后的测试或硬件验收。 箭头表示前置部分 → 后续部分;目标分支为 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
如何按依赖提交(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下层更新后用 提交范围 · 接收 68 · 建议移出 0 · 待确认 0接收 68 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。
Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||
| actor_name: str | ||
| handle: Any | ||
| node_id: str |
There was a problem hiding this comment.
这里新增必填 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 调用预期,恢复原有行为断言。这是已复现的回归验证问题;生产连接器会提供这些字段,当前证据不表明生产调度错误。
There was a problem hiding this comment.
已确认此问题在 1831212 修复:夹具补齐节点身份,关闭条件明确使用正 staleness,并新增零 staleness 场景;原有跨步 Session、teacher logprob 和 manager 调用断言均保留。
在该 head 仅重跑本线程列出的两个用例,结果 2 passed(Python 3.12.3,CPU,23.85 秒)。这确认了本线程的夹具修复,不代表完整套件或硬件集成通过。
| 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() |
There was a problem hiding this comment.
若已退出的进程拥有有效回执,但首次 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。
There was a problem hiding this comment.
已确认 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 验证。
There was a problem hiding this comment.
🟡 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
|
|
||
| actor_name: str | ||
| handle: Any | ||
| node_id: str |
| 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: |
| 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) |
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.
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.
d562c20 to
838d515
Compare
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.
feat: Simplify Agentic scheduling and make cleanup non-fatal
rai-studio-bot
left a comment
There was a problem hiding this comment.
初步复审意见
当前变更已移除物理配额和回执接口,但 PR 说明仍按旧设计介绍配置与保证。核心生命周期及命令根进程清理的复核尚在进行。
非行级:PR 描述的 How、兼容范围及参数示例。
正文仍要求 --agentic-session-capacity-per-node、ReceiptResourceOwner,并用“256 个逻辑成员、128 个物理槽位”说明容量;当前实现已删除这些接口。新指南 明确 --agentic-concurrency 只限制逻辑 Group,后台清理可以晚于逻辑退休,物理配额由外部服务负责。读者照正文配置会引用不存在的参数,也会得到错误的资源占用预期。
请将正文改为当前的独立 Session 生成、完整 Group 交付、1800 秒首请求期限,以及命令根进程负责清理的契约;删除旧配额/回执用法,并标明历史吞吐和验收数据对应的旧版本。
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.
NINGBENZHE
left a comment
There was a problem hiding this comment.
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。
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.
#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]>

What
Why
组内成员的环境准备、排队和收尾耗时不同。等待全组首请求到齐、等待物理清理完成后再交付结果和归还逻辑名额,会延迟后续任务进入,降低 rollout 吞吐。
How
Scope and compatibility
--agentic-concurrency仍限制逻辑 Group 数,--n-samples-per-prompt决定每组成员数。物理配额由执行器约束,后台残留不受逻辑并发数硬限制。--agent-timeout仍按活跃时间计时。--agent-command直接启动程序,不再隐式执行登录 Shell;环境激活、变量展开和管道需放入显式脚本。仓库相关 examples 已适配;各任务的实际吞吐收益仍需分别验证。Testing
713ddaea已完成 Mini SWE 5-step 验证:1,280 条样本、最终补采欠额为零,观测到的任务进程和容器完成释放。--fuzz=0重放一致;未据此宣称当前完整镜像已重新验证。保留此前 20-step 容量 ON/OFF 实验的性能对比:
两组采用相同模型、GPU 和 128 个物理槽位;ON 使用当时的容量 128/组并发 48,OFF 使用组并发 16,以适配旧组级屏障。速率按总有效 token/总 rollout 时间计算。两组均完成20次训练更新,最终资源和补采样欠额归零,奖励测试超时仍按失败并替换整组处理。
Type of Change
agent-commandno longer uses an implicit login shell