Skip to content

fix: harden rollout and multimodal lifecycles - #804

Merged
yuanlehome merged 7 commits into
redai-studio:mainfrom
yuanlehome:integrate/unified-general-fixes-20261125
Nov 26, 2026
Merged

yuanlehome merged 7 commits into
redai-studio:mainfrom
yuanlehome:integrate/unified-general-fixes-20261125

Conversation

@yuanlehome

@yuanlehome yuanlehome commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

改动内容

修复 rollout、TransferQueue 和多模态处理的生命周期问题,并为 Qwen PLE 引入带适用条件检查的变长序列卷积。

背景与问题

取消请求或局部失败可能导致同组任务继续运行、存储写入错误未及时上报,或已派发的写入被中断。TransferQueue 首次响应丢失后的重试可能重复分配数据;轮询和已清理分区的状态处理也可能阻塞生产者确认或流式任务结束。

多模态预处理还存在 JPEG 通道不一致、CUDA OOM 后无法回退,以及缓存和 IPC 资源未正确释放的问题。

实现方式

  • 同组请求失败时取消并等待其余任务结束,及时传播传输错误;在重复取消时仍等待已派发的存储写入完成,覆盖 partial rollout 中额外完成样本的写入路径。补充已清理分区的完成判断、空轮询退避和组级 reward 耗时统计,保留自定义 reward 字典及 reward_key 的读取行为。
  • 保证 TransferQueue 插入重试的幂等性,并在清理及 checkpoint 恢复后保留终态。合并固定版本的依赖补丁,构建带源码、补丁和包内容完整性校验的 wheel。
  • 在 scheduler 子进程中应用可配置的模型加载屏障超时,并补充远程 Ray Job 到 engine 的环境变量传播说明;没有消费者时,跳过原始 PLE 权重的收集与物化。
  • 将 Qwen JPEG 输入统一为 RGB;GPU 预处理 OOM 后回退 CPU;根据处理器实际使用的 GPU 释放缓存;取消媒体等待或尚未运行的预处理,并回收未派发的 IPC 租约以及运行中线程延迟返回的结果。
  • 为 PLE 增加 packed-varlen 卷积路径,并保留原有 decode、verify 和回退路径。

TransferQueue 的修复在本阶段通过 Relax 内的 patch 和训练镜像构建分发。全异步训练使用包含这些补丁的镜像;本 PR 合入后,计划单独向 TransferQueue 提交上游化 PR,待上游可用后再清理 Relax 中的依赖安装方式和本地 patch。

验证

当前提交 8029588 修正了 replay 预取测试的时序假设:先等待当前预取窗口完成,再验证下一批预取不会阻塞缓存层读取。已用受控线程交错复现旧失败并验证修复;本次 CPU CI 为 10980 passed、115 skipped、31 subtests passed,原失败用例明确通过。

此前已验证提交 7183084 的 Unit Tests、Integration Tests、pre-commit 和文档构建均已通过。

CI 测试集 Passed Skipped Subtests passed
CPU 10980 115 31
H20 单卡 780 176 19
H20 四卡 46 27 —
  • 自定义 reward 字典与 reward_key 保留用例、四项媒体等待/执行器取消用例均实际执行并通过。
  • 真实 CUDA 后台线程取消后的 IPC 租约回收,以及另外四项 IPC 生命周期实例均实际通过。
  • GPU async、GPU VL、NPU async 三项集成训练全部成功。
  • 实际构建并验证补丁后的 TransferQueue wheel;完整 SGLang 补丁可在固定上游版本干净应用,核对全树后仅本次预期的三个生产文件变化。
  • 本地全部 pre-commit run --all-files --show-diff-on-failure 检查通过;中英文 Ray 环境变量示例已验证保留既有配置并将超时传到服务运行环境。

表中的跳过项按 CI 环境条件保留。四卡 Qwen artifact device 的首次处理/缓存命中两项仍因缺少 RELAX_TEST_MODEL_PATH 跳过,不作为通过证据;本次 IPC 取消回归不依赖模型路径,已在单卡执行。

  • pre-commit run --all-files 通过
  • 完整测试套件通过(CI 分 CPU、1 GPU、4 GPU 执行)
  • 已新增回归测试
  • 已更新相关文档

变更类型

  • Bug 修复(兼容现有接口)
  • 新功能(兼容现有接口)
  • 不兼容变更
  • 文档更新
  • 重构(不改变功能)
  • 性能优化
  • CI/CD 或构建变更

日志与性能结果

PLE 算子测试的数值结果与参考实现一致,状态写回精确匹配:

输入 优化前 优化后 额外峰值显存:优化前 / 优化后
不等长序列 [2048] + [32] * 15,2048 通道 1.164 ms 0.073 ms 405.5 / 20 MiB
等长序列 [256] * 8,1024 通道 0.103 ms 0.073 ms 20.375 / 8 MiB

以上为算子级微基准结果,不代表端到端训练吞吐提升。

Integrate reusable changes from agent_as_judge_unified (525a9dc9) onto
main c9c3997, excluding business judge capabilities and fixes already
covered by main.

- Drain failed rollout siblings, settle dispatched writes through cancellation,
  surface transfer failures promptly, and finish retired data partitions.
- Add optional reward timing and back off empty advantage polling.
- Apply the model-loading barrier timeout in scheduler subprocesses and skip
  raw PLE weight materialization when there are no consumers.
- Make TransferQueue insert retries idempotent, preserve retired terminal
  state across checkpoints, and keep polling from blocking producer ACKs.
  Build the consolidated pinned patch into a verified dependency wheel.
- Normalize Qwen JPEG inputs to RGB, recover preprocessing OOMs on CPU,
  release the correct device cache, and reclaim undispatched or late IPC
  leases when requests fail or are cancelled.
- Add the guarded Qwen PLE varlen convolution and reference/state regressions.

Validation includes before/after behavioral reproductions, real ZMQ and Gloo
protocols, 289 passing CPU tests plus two subtests, 21 passing GPU cases,
and exact-output/state PLE comparisons with measured latency and memory.
The complete SGLang patch applies to the pinned pristine source and matches
the tested tree. TransferQueue and unchanged router wheels were built and
tested. Full Docker images were not built because Docker is unavailable.

All repository pre-commit hooks pass. GPU occupancy is restored after testing.
@yuanlehome
yuanlehome requested review from a team and NINGBENZHE and a balanced review from Copilot November 25, 2026 15:50
@rai-studio-bot

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

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Complete stream-drain, IPC cleanup, and Qwen processor fixtures used by CPU CI. Exercise the real rollout wrapper and settlement helper when checking storage acknowledgements after generation failures.
@rai-studio-bot

rai-studio-bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

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

审查版本: 8029588

目标分支: main

README 已记录长期移除条件,仍需涵盖 WholePack 的 assignment_transform。预取测试同步改动已在 CPU CI 通过,其他原意见仍适用。

审查阶段进度范围与结果
常规审查 ✅ 已完成 已复核两个变更文件和八条未结意见。现有预取回归在当前 CPU CI 通过。 https://github.com/redai-studio/Relax/actions/runs/45770243350/job/139740952341
深度审查 ✅ 已完成 已核对窗口完成后再调度下一微批的时序和 WholePack 的 sampler 契约。Codenip 无新增意见,已在原讨论更正补丁移除条件。

审查发现

待处理
编号 严重性 问题状态规则来源
F2 Low severity 合并同组任务的取消和排空
精简建议(非阻塞)
🚧 未解决 —
F4 Medium severity 让已清理的任务在窗口查询和取数中保留终态 🚧 未解决 —
F5 Medium severity 让源码安装的 fully-async 用户获得生命周期补丁 🛠️ 部分解决 —
F7 Medium severity 让 barrier 用例适配 SGLang 0.5.17 🚧 未解决 —
F8 Low severity 移除 KV 获取路径中不可达的插入重放处理(非阻塞)
精简建议(非阻塞)
🚧 未解决 —
F9 Medium severity 让 CUDA 缓存回收符合按卡预期 🚧 未解决 —
F15 Low severity [experimental · REF012] 统一 CUDA IPC 租约的状态更新
精简建议(非阻塞)
🚧 未解决 —
F16 Low severity [experimental · DOC005] 保留可长期使用的补丁移除条件 🛠️ 部分解决 —
已解决或已取代
编号 严重性 问题状态规则来源
F1 Medium severity 保持自定义奖励字典原样 ✅ 已解决 自定义奖励与全局 reward-key
F3 Medium severity 让正超时下的轮询用例检出原缺陷 ✅ 已解决 测试须能检出具体生产错误
F6 Low severity 说明远程 Ray Job 如何传递模型加载超时 ✅ 已解决 —
F10 Medium severity 只保护可能已产生本地 IPC 租约的工作 ✅ 已解决 —
F11 Medium severity 让无需模型的五项 IPC 回归在 GPU CI 运行 ✅ 已解决 GPU 用例按实际运行依赖检查资源
F12 Low severity [experimental · TST002] 捕获 rollout-only 意外调用 raw sender ✅ 已解决 保留外部边界的必要交互断言
F13 Low severity [experimental · TST004] 在真实屏障入口确认超时已传入 ✅ 已解决 用受控交错验证竞态
F14 Low severity 给首批写入的测试等待设置上限 ✅ 已解决 测试并发路径应有超时和清理边界

改进建议(非阻塞)

精简

💡 生产代码 · 3 条建议

可合并同组任务的重复排空与 IPC 租约的重复状态更新,并移除 KV 路径不可达的错误处理。

范围建议保留的行为与验证依据
普通 SGLang rollout 同组请求失败后的清理 合并
排空一次并将已完成结果传给 replay 清理。
先等待同组任务结束,再释放原始组和已完成结果的 replay 引用。
_cancel_after_error 已等待所有任务,唯一调用方随后让 discard_failed_generation 对同一批任务再次执行 cancel 和 gather。 https://github.com/redai-studio/Relax/pull/804#discussion_r4698319283
TransferQueue KV_RETRIEVE_META 客户端和 Controller 删除
删除 KV 收发两侧新增的 InsertReplayError 处理。
按 key 创建或找回 KV 元数据。GET_META 才按插入请求 ID 重放。
固定上游的 KV 创建不走插入重放,当前补丁也没有分区数量上限。 https://github.com/redai-studio/Relax/pull/804#discussion_r4698397178
SGLang TokenizerManager 与 BaseMultimodalProcessor 的 CUDA IPC 租约归还 合并
由现有 IPC 池或代理统一跟踪派发及归还的状态转换。
共享代理只能移交或归还一次,失败保留原状态并记录错误。
两条路径分别读写同一个代理的租约标记。 https://github.com/redai-studio/Relax/pull/804#discussion_r4704590144

拆分

💡 1 个拆分方案

保留原有四部分及 TransferQueue 到 rollout 的依赖。既有 Replay 预取测试同步修复可单独验收。

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

flowchart LR
    target["目标分支"]
A["PR A"]
target --> A
B["PR B"]
A --> B
C["PR C"]
target --> C
D["PR D"]
target --> D
E["PR E"]
target --> E
Loading
部分PR 主题内容与范围验证
A TransferQueue 镜像交付 TransferQueue 补丁、构建脚本、两份 CUDA Dockerfile 构建与安装段、镜像分发指引和中英文安装说明及相应回归。Advantages 空轮询退避及 test_stream_completion.py 的对应测试归此部分。 按固定上游构建 wheel,用正超时验证轮询,执行丢首个回复、清理和 checkpoint 恢复的定向测试。
B Rollout 取消、写入与完成判断 Rollout 的取消、写入结算、完成判断和计时,以及对应测试。test_stream_completion.py 中清理后终态用例归入此部分。 基于 A 的终态语义运行 rollout 和恢复 CPU 回归,覆盖重复取消时已派发写入、失败传递以及最后一个分区被清理的情况。
C SGLang 服务启动和多模态生命周期 v0.5.21.patch 中 TokenizerManager、Qwen/Base processor、JPEG 及 IPC 测试片段,加入 Relax 的 scheduler 加载超时入口和配置,随附 barrier、JPEG、GPU 图像、缓存和 IPC 测试及相关 fixture 调整。 随附中英文远端 Ray 环境变量指南和新的 tokenizer/executor 取消回归。 在固定 SGLang 源码应用对应补丁,运行 Gloo barrier、真实 CUDA IPC 回归,提供模型配置后运行 JPEG、OOM、缓存和双卡测试。
D Qwen4 PLE 与 DCS 权重同步 v0.5.21.patch 中 PLE kernel 注册、模型调用、状态写回与算子测试,可同批验收 CMake 的 SM103 构建目标。加入 DCS 无 raw 接收方优化、Gloo PLE 同步回归及对应生命周期 fixture。 验证固定 SGLang 补丁和 SM103 构建目标,比较 packed/padded 数值与状态,并用真实模型检查 prefill 后的 decode/verify。运行 Gloo 权重同步用例检查两种接收方拓扑。
E Replay 预取测试同步 仅拆分 test_reference.py 中等待当前窗口完成的变更。既有生产代码已在基线中具备该行为。 在目标基线运行 test_reference_prefetches_next_microbatch_without_blocking_cached_layers,确认下一微批预取及缓存层非阻塞读取。
如何按依赖提交(stack)

作者从 fork 提交并显示为组织成员,尚未独立确认其对上游仓库的写权限。

先按表重组混合提交,每部分携带对应测试和文档;逐层验证,并核对顶层最终树与原 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 使用说明。

Fork 贡献者: 分支保留在 fork,先将底层向上游目标分支提交;上层暂留本地,或在 fork 内以其前置分支为 base 开 draft PR。底层合入后,只将上层独有提交 rebase 到更新后的上游目标分支,再提交下一层;若底层被 squash,注意排除其旧提交。

Fork 内 PR 只用于增量审阅;上游 PR 的 base 不能指向 fork 独有分支。多个累计 PR 同时指向上游目标分支会包含重复差异。GitHub 原生 stack 要求所有分支位于同一仓库。

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

阶段性审查意见

已核对更新后的 PR 正文和提交 76099e1f。Rollout 奖励兼容性与同组任务清理的意见已标在相应改动行。TransferQueue、SGLang 补丁、权重同步及拆分分析仍在进行。

审查面板

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment thread relax/engine/rollout/sglang_rollout.py Outdated
for reward in rewards:
if isinstance(reward, dict):
for key in ("genrm_time", "genrm_calls"):
value = reward.pop(f"_perf_{key}", None)

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 · 保持自定义奖励字典原样

这里在写入 Sample.reward 前原地删除了两个自定义奖励字段。现有批量奖励接口允许返回字典,Sample.get_reward_value() 按配置的 reward_key 直接取值。如果用户把其中一个同名字段用作奖励键,原来能训练的配置会在取值时抛出 KeyError。内建 GenRM 没有返回这两个字段,目前只有新增测试提供它们。建议只保留组耗时统计,等 GenRM 有真实生产者时从独立的指标通道上报。 批量奖励入口 · 奖励取值 · 内建 GenRM 返回值

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已核对 7183084。组计时只记录时间区间,奖励字典原样用于 Sample.reward。回归通过 Sample.get_reward_value() 读取同名奖励字段,也检查了自定义元数据保留。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

if references_enabled() and not evaluation:
await discard_failed_generation(replay_data_manager, tasks, group, error)
try:
await _cancel_after_error(error, tasks)

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.

Low severity P3 · 合并同组任务的取消和排空(非阻塞)

引用模式下,_cancel_after_error 已取消并等完所有同组请求,discard_failed_generation 紧接着又对同一批任务调用 cancel 和 gather,才能拿到成功结果供 replay 清理。建议让第一次排空直接提供成功结果,由 replay helper 负责释放这些结果和原始组的引用。普通模式依然能取消同组请求,引用模式也保留清理所需的样本和顺序。 现有 replay 清理实现

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

补充审查意见

已复核 TransferQueue wheel、窗口完成协议、SGLang 启动和 DCS 接收方路径。新增行级意见覆盖依赖行为与测试兼容性。多模态补丁、PLE 算子及拆分分析仍在进行。

审查面板

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

worker_timeout = _configure_timeout(monkeypatch)
controller_type = module.TransferQueueController.__ray_metadata__.modified_class
controller = object.__new__(controller_type)
controller.polling_mode = True

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 · 让正超时下的轮询用例检出原缺陷

这个用例的 _configure_timeout() 会把 Controller 模块的超时从 3 改为 -1。固定时钟下,旧实现也会在执行 sleep() 前返回。同一个 pending 用例分别用固定上游 9784ad0 和新 wheel 执行,两边各通过一次。请保留旧启动兜底的验证,并用实际 Controller 的正超时单独验证轮询分支,让移除补丁里的提前返回时用例失败。 旧启动兜底

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已在 8a51595c 验证。启动兜底和正超时轮询已拆成两个用例。同一 [pending] 用例在裸上游 9784ad0 上按预期命中禁止休眠的断言,在补丁 wheel 上通过。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

+ with self._lifecycle_lock:
+ partition = self._get_partition(partition_id)
+ if partition is None:
+ return task_name in self._retired_completed_tasks.get(partition_id, ())

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 · 让已清理的任务在窗口查询和取数中保留终态

相同的已消费任务在清理分区后会得到 check_stream_drained=True、check_window_drained=False,token-budget fetch 也只返回普通空包。用新 wheel 的真实 Controller 验证了清理前后和 checkpoint 恢复后的结果。现有窗口查询约定整分区 drain 即可结束,取数端也依赖 stream_end 区分结束与等待。建议复用这份终态记录,使迟到查询读到结束,同时让未知任务、未来分区及同名重建继续返回未完成。 窗口查询消费方 · 取数循环

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.


## Reproducible wheel

Both CUDA Docker recipes build an isolated wheel from the same `TRAIN_IMAGE`

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 · 让源码安装的 fully-async 用户获得生命周期补丁

CUDA 镜像会安装此 wheel,但源码启动的缺依赖提示仍推荐直接安装裸 9784ad0,且该版本可以通过 fully-async 检查。这样按现有提示安装后,插入 RPC 丢首个响应时仍可重复分配,已清理的分区也没有这里新增的终态。建议将源码安装说明和提示指向带补丁的产物,并按实际能力校验依赖。ROCm 对同一版本原地打补丁,单看版本字符串无法区分。 启动依赖检查 · ROCm 安装路径

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

镜像分发和诊断已在 7183084 统一,原来指向裸上游的安装命令也已移除。Ascend 仍使用现有全异步入口,但它的 Dockerfile 安装裸 9784ad0,该版本仍能通过启动检查,也缺少本次插入重试和终态修复。请给 Ascend 镜像应用同一份补丁,或在安装说明中明确哪些镜像提供这些保障,以及 Ascend 当前的边界。 Ascend 镜像 · 全异步 CI 入口

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment thread relax/utils/env.py
RELAX_REPLAY_CAPACITY_MB = EnvProperty("RELAX_REPLAY_CAPACITY_MB", int, 16384)
RELAX_OPTIMIZE_ROUTING_REPLAY = EnvProperty("RELAX_OPTIMIZE_ROUTING_REPLAY", bool, False)
# Post-load TP straggler barrier in SGLang; zero keeps the upstream timeout.
RELAX_MODEL_LOADING_TIMEOUT_S = EnvProperty("RELAX_MODEL_LOADING_TIMEOUT_S", int, 0)

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.

Low severity P3 · 说明远程 Ray Job 如何传递模型加载超时

从集群外用常规 Ray Job 脚本提交时,仅在提交端导出 RELAX_MODEL_LOADING_TIMEOUT_S 不会把它放进脚本生成的 runtime_env.env_vars。远端 engine 因而读到默认 0,scheduler 不安装覆盖。请在配置说明给出合并到 runtime_env.env_vars 的用法,或沿已有启动渠道转发显式值。 Ray Job 环境构造 · 现有 Ray Job 环境变量说明

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已核对 7183084 的中英文指南。示例在入口初始化之后和实际提交之前把超时及转发列表送到远端 driver。现有 post_process_env() 会将该值传给服务,scheduler 启动日志可以确认覆盖。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

patch.object(load_model_utils, "UNBALANCED_MODEL_LOADING_TIMEOUT_S", 0.1),
patch.object(
load_model_utils,
"get_parallel",

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 · 让 barrier 用例适配 SGLang 0.5.17

0.5.17 也提供 load_model_utils,但它通过 get_tp_group().cpu_group 获取 TP 组,0.5.21 才使用这里的 get_parallel()。在 0.5.17、隐藏 GPU 的环境实跑 [ordinary],两个子进程均在安装这个 fixture 时抛出 AttributeError,还没到 Gloo barrier。请在测试里按实际版本替换对应 accessor,保留真实 spawn 和 Gloo 验证。 0.5.17 的 barrier 实现

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

+ try:
+ metadata = self.kv_retrieve_meta(keys=keys, partition_id=partition_id, create=create)
+ response_body = {"metadata": metadata}
+ except InsertReplayError as error:

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.

Low severity P3 · 移除 KV 获取路径中不可达的插入重放处理(非阻塞)

固定上游的 kv_retrieve_meta(create=True) 直接调用 create_partition 并按 key 分配索引。新补丁的 InsertReplayError 只从 GET_META 的 _get_insert_metadata 抛出,KV 路径没有注释所说的分区上限。建议删除这里的捕获和 KV 客户端对应的 error 分支,保留 KV 按 key 重取及 GET_META 插入重放的现有行为。 固定上游 Controller

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

审查完成

已按更新后的 PR 正文审查 76099e1f。行级意见覆盖奖励兼容性、TransferQueue 的完成协议、SGLang 的取消与设备缓存,以及回归测试覆盖。当前检查无失败,新增的多模态 GPU 用例因缺少模型路径被跳过。PLE 的端到端数值等价性仍缺独立验证。

审查面板

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

+ with torch.cuda.device(device):
+ idle_bytes = torch.cuda.memory_reserved() - torch.cuda.memory_allocated()
+ if idle_bytes > _PREPROCESS_CACHE_RELEASE_BYTES:
+ torch.cuda.empty_cache()

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 · 让 CUDA 缓存回收符合按卡预期

切换当前设备能限定这里的显存统计,但 PyTorch 原生 allocator 的 empty_cache() 会遍历进程内所有 GPU。GPU 1 超阈值时,GPU 0 的空闲块也会被释放,后续分配需重新申请。现有双卡测试在为 GPU 1 预留空间时会先清掉 GPU 0 的测试缓存,最后也只断言 GPU 1。若目标是按卡隔离,请使用预处理专用池并保留 GPU 0 的空闲块断言。若采用全进程回收,请明确该策略。 PyTorch allocator · 双卡测试

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment thread docker/patch/sglang/v0.5.21.patch Outdated
+ # processor result alive until ownership can be transferred or returned.
+ processing = asyncio.create_task(self.mm_processor.process_mm_data_async(**kwargs))
+ try:
+ return await asyncio.shield(processing)

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 · 只保护可能已产生本地 IPC 租约的工作

这里 shield 整条多模态协程。取消发生在媒体 I/O 或 executor 排队时,请求状态已释放,但它仍可启动 JPEG 解码和 HF 处理。CPU 或 CUDA VMM 路径没有本地 IPC 池,也会继续消耗处理队列。建议无本地池时保留直接 await,并将迟到结果回收缩到可能已产出本地 IPC 代理的执行边界。现有测试保护已开始运行的线程,可另用受控 I/O 检查取消后不会启动后续预处理。 迟到线程回归

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已核对 7183084。TokenizerManager 恢复直接 await,尚未运行的 executor 工作可以取消,运行中线程的晚到 IPC 结果仍会被回收。四项 CPU 取消用例及单卡真实 IPC 回归已通过。这里确认的是 Python 任务取消路径。 CPU CI · 单卡 CI

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment thread tests/backends/sglang/conftest.py Outdated

@pytest.fixture
def sglang_cuda() -> None:
if not os.environ.get("RELAX_TEST_MODEL_PATH"):

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 · 让无需模型的五项 IPC 回归在 GPU CI 运行

manager_pool 用 dummy ServerArgs 构造 TokenizerManager 和真实 CUDA 池,全程无需模型。单卡 CI 因共用的 RELAX_TEST_MODEL_PATH 门禁跳过了四项租约测试和一项迟到线程测试。请把模型路径检查留在已检查它的 qwen_processor_context,让共享 fixture 只检查 CUDA 和 SGLang 依赖,并移除闲置的 os 导入。 单卡 CI · 处理器 fixture

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已核对 8a51595c。共享 fixture 只检查 CUDA 和 SGLang,模型路径仍由 Qwen 处理器 fixture 检查。五项 IPC 用例现在可在无需模型的 GPU 环境执行,本次 GPU CI 结果仍待确认。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment on lines +363 to +365
assert rank == 0
if not expect_raw:
return

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.

Low severity P3 · [experimental · TST002] 捕获 rollout-only 意外调用 raw sender

测试包含有 raw 接收方但显式 rollout_only=True 的情况。这里静默返回会让意外调用 raw sender 加空批次通过,真实 sender 在有接收方时仍会发出一条权重元数据。请让禁止 raw 发送的场景在收到该调用时失败。 真实 sender

Suggested change
assert rank == 0
if not expect_raw:
return
assert rank == 0 and expect_raw, "raw sender called when raw transfer is disabled"
Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已核对 8a51595c。即使调用传入空批次,禁用 raw 传输时断言也会直接失败。保留了 Gloo 拓扑和实际权重形状的原有断言。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

if references:
assert replay_initialized == [True], "reference scheduler initialization was bypassed"
if rank == 0:
entered.set()

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.

Low severity P3 · [experimental · TST004] 在真实屏障入口确认超时已传入

rank 0 在调用屏障前就发出信号。如果在信号后被抢占超过 0.4 秒,rank 1 会先获准进入,两者可能在上游的 0.1 秒内会合,漏检超时未被覆盖。建议在 monitored_barrier 边界记录实际收到的 timeout,再委托给真实 Gloo 屏障,同时从该边界同步延迟 rank。 现有释放顺序

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已核对 8a51595c。用例在真实 monitored_barrier 边界记录传入值,并断言每个 rank 都收到 5 秒超时,即使调度碰巧掩盖延迟也能检出配置丢失。0.5.17 的 accessor 兼容性仍在原讨论跟踪。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

await asyncio.wait_for(scoring[index].wait(), 2)
clock[0] = 4.0
finish[0].set()
while not harness.writes:

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.

Low severity P3 · 给首批写入的测试等待设置上限

如果第一个组完成后未及时派发写入,例如误改成等所有组完成再写,这个循环就会一直等待,而第二个组要等它退出才会放行。请用写入事件和有界等待替换循环,并在失败时释放事件、收尾 runner,让故障在用例内报告。 待完成组与等待顺序

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已核对 8a51595c。首批写入通过事件通知,等待有 2 秒上限。异常时会释放测试事件并取消、收尾 runner,避免原先的无限等待。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Exercise polling with a positive controller timeout while preserving the replay startup override check. Let model-free IPC tests run on GPU CI, reject disabled raw sends, observe the real loading-barrier timeout, and bound rollout timing-test waits with cleanup.
Keep custom reward dictionaries intact while recording group timing. Allow cancellation during media loading and cancel queued preprocessing, retaining only running IPC worker results for lease cleanup.

Document the patched TransferQueue source installation and artifact verification, and the complete Ray Job environment propagation for the model-loading barrier timeout.

Add cancellation regressions and extend the reward timing test. Validate clean application of the full SGLang patch, actual executor cancellation, TransferQueue wheel installation, documentation examples, and all pre-commit checks.
@yuanlehome
yuanlehome requested a review from SigureMo as a code owner November 26, 2026 05:48
Ship the TransferQueue fixes through Relax's patched training image for this change. Direct users to that image instead of a standalone source installation.

Document the planned separate TransferQueue upstreaming PR and subsequent Relax dependency and patch cleanup. Keep the current dependency pins, build logic and patches unchanged.

Validation: Python syntax checks, git diff --check, and all pre-commit checks passed.

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

补充审查意见

已完成 7183084 的增量复核。奖励字典、远端超时说明和多模态取消的修复已在原讨论确认。TransferQueue 镜像仍有平台差异,新增行级意见说明了可简化的 IPC 租约状态和分发文档。CPU 与单卡 IPC 回归通过。

审查面板

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

+ and not isinstance(proxy, CudaVmmTensorTransportProxy)
+ )
+ for proxy in proxies:
+ if getattr(proxy, "_tokenizer_ipc_lease_closed", False):

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.

Low severity P3 · [experimental · REF012] 统一 CUDA IPC 租约的状态更新

新增的晚到结果清理与 TokenizerManager._finish_ipc_dispatch() 分别检查和写入同一个代理的 _tokenizer_ipc_lease_closed。两个位置都需要维护成功归还才标记、异常时保留原状态的规则。建议把这段状态转换收回到现有的 IPC 代理或池,两条调用路径分别传入已派发或需归还的结果。这样可保留并行采样共享代理的语义和现有失败诊断。 派发路径

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment thread docker/patch/transferqueue/README.md Resolved
yuanlehome and others added 2 commits November 26, 2026 14:28
A progressive layer can become ready before its prefetch window completes. The next-microbatch test could consume that layer early and then wait for work that only a subsequent consumer read schedules.

Wait for the real first-window future before triggering the next-microbatch read. Keep the second window blocked while asserting cached-layer reads remain nonblocking, with all value and cache-budget checks intact.

Validation: a controlled real-thread interleaving reproduces the old failure and passes with the new ordering; 47 locally runnable reference tests and all pre-commit checks pass. Full CPU coverage runs in CI because the local environment lacks SGLang router and imageio.
@yuanlehome
yuanlehome merged commit 8c11399 into redai-studio:main Nov 26, 2026
19 checks passed
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 reformatted docker/patch/transferqueue/9784ad0-assignment-transform.patch
(whitespace/context-header rewrite, same + lines) and get_data_iterator now reads
args.partial_rollout / args.use_dynamic_global_batch_size. Update the pinned patch
hash and manifest self-hash, and set the new args in the p3p4/p45 CPU fixtures so
the No.16 suite exercises the real merged data path.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
Gclk500 pushed a commit to Gclk500/Relax that referenced this pull request Nov 27, 2026
Upstream redai-studio#804 serialized blank context lines as truly empty lines instead
of the leading-space form; unified-diff semantics treat both as blank
context, so the applier now accepts both and preserves the pinned patched
output byte-for-byte.
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.
nianliunian pushed a commit to nianliunian/Relax that referenced this pull request Dec 1, 2026
Resolve two conflicts against main's rollout lifecycle hardening (redai-studio#804):

- device_direct.py: main's empty-actor_fwd fast path returns early when the
  receiver topology is empty. Keep it ahead of the version advance, but still
  count the attempt, so a skipped actor_fwd sync neither publishes an ordinal
  nor goes uncounted.
- test_weight_sync_lifecycle.py: keep both fixtures' attributes.

test_dcs_ple_weight_sync.py asserted `weight_version == step + 1` for every
case, including the actor_fwd-only ones. That expectation encoded the old
always-increment behaviour this branch fixes; assert per case instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants