Skip to content

fix(rollout): preserve policy and weight-sync consistency - #720

Merged
Yangruipis merged 12 commits into
redai-studio:mainfrom
Yangruipis:fix/rollout-weight-sync-consistency
Nov 19, 2026
Merged

Yangruipis merged 12 commits into
redai-studio:mainfrom
Yangruipis:fix/rollout-weight-sync-consistency

Conversation

@Yangruipis

@Yangruipis Yangruipis commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What

修复普通同步 rollout 的旧策略样本跨轮复用,以及权重同步时发送端未采用接收端有效配置的问题。

  • 普通同步模式在本轮补采 aborted group,丢弃超出目标 batch 的结果;显式 async/partial rollout 保留原有跨轮复用。
  • 权重发送根据实际接收组的 checkpoint、量化模式和 overrides 决定 tensor 格式,提前拒绝不兼容的接收组组合。
  • 同时修复 routing replay 的 abort 处理、FP8 排除规则对父模块的匹配、新版 Torch collective API 适配,以及 DAPO 答案末尾的 assistant 结束符清理。

Why

同步训练可能意外用了旧策略生成的样本。 rollout 过采样会产生超出本轮 batch 大小的完整结果。原逻辑可能将这些结果缓存到下一轮;但下一轮开始前已经更新了 rollout 权重,因此 batch 中会混入上一版本策略的样本。普通同步模式需要在本轮补采被中断的组,并丢弃多余结果。显式 async、partial rollout 的复用行为保持原样。

训练端转换权重时,可能没有采用接收端真正生效的配置。 例如 checkpoint 自带 FP8 配置,但某个 rollout 引擎通过 override 关闭了量化。旧发送逻辑仍可能依据原 checkpoint 做 FP8 转换,导致发送的 tensor 格式、scale 参数与接收模型不匹配。发送端需要先解析实际接收组及其最终配置,再决定权重转换格式;多个接收组要求不兼容时,在传输前报错。

这些修复位于框架的 rollout、量化配置解析和权重同步路径,适用于不同模型。

How

  • 同步模式在当前 step 补采 aborted group;主循环产生的 surplus 和 abort 收尾期间完成的多余结果均不回存下一轮。routing replay 在修改响应前缀前处理 abort,并给出 expert 尺寸错误信息。
  • 两个发布入口在 MegatronTrainRayActor 内共用 _resolve_push_quantization_config() 私有方法。删除独立的 relax/distributed/ray/rollout_weight_config.py 文件;YAML 路径继续局部导入原配置解析器,量化 metadata/布局解析仍归 utils.quant_cast。
  • 普通 tensor/distributed 更新覆盖首个模型的实际引擎;DCS 覆盖共享 rollout role 的所有 YAML 模型引擎,排除 placeholder。组级 JSON 整字段覆盖全局配置,显式 null 不被原 checkpoint 值重新覆盖;保留 text_config 字段更新、compression fallback 和单次分片扫描。
  • 区分运行时量化模式与 checkpoint 源布局,按实际布局比较接收组。例如 modelopt_fp4 的密集层也可能加载 serialized block FP8 源权重,不能仅因模式名称不同拒绝。未支持的 serialized NVFP4 仍由真实 sender dispatch 在传输前拒绝。
  • 沿用现有 process-group wrapper,兼容 single-tensor collective API,并覆盖直接调用、coalescing 及已导入别名。

此 PR 独立基于 main,不包含模型实现、专用 FP8 kernel 或 fused CE。

Testing

当前修订 7d73129b7,基于 main 43fa07d5e。

  • 维护者指定的 CUDA 12 / SGLang 0.5.21 镜像隐藏 GPU 后,六个相关 CPU 文件 160 passed,零 skip。覆盖真实 SGLang loader/linear、同步样本处理、FP8 转换,以及 DCS client 实际接收的量化配置。
  • 真实 SGLang 0.5.17 布局回归 1 passed /1 skipped /22 deselected;YAML FP8 继续执行,唯一 skip 是该版本不支持的 ModelOpt 组合。ROCm 仅跳过不支持的 ModelOpt 参数;sender NVFP4 拒绝回归保留。受控 HIP detector 探针不构成 AMD 实机验证。
  • 纯元数据与真实 loader 用例直接调用 resolve_receiver_quantization_config;接收组选取、YAML/global overrides、DCS 发布范围及 sender dispatch 放入已有 actor 测试文件,使用其既有依赖检查并直接调用实际私有方法。原断言和 SDK/HIP 条件保留,无新增 skip。
  • 屏蔽 Megatron 后,utils 配置文件全量 24 passed、零 skip;此前显式 null 三例在该条件下失败,修正后 3 passed。共享 fixture 显式导入复用,不重复实现测试逻辑。
  • arch-expert 只读复核、新独立 Codex session 完整增量复核均无剩余可行动问题。完整 pre-commit run --all-files --show-diff-on-failure 通过。
  • 当前 head 7d73129b7c80ac048a66ddfc00b7ad992c4d4810 的7项必需CI全部通过:pre-commit、完整CPU、H20单卡/四卡、VL GPU集成、异步GPU集成、异步NPU集成。完整CPU 10260 passed /115 skipped、31 subtests passed;这些均为当前head实际结果。
  • 指定镜像此前完整 CPU 范围为 10081 passed /185 skipped /9 failed,29 subtests passed。这9项在同镜像纯 main 43fa07d5e 完全复现,涉及 hybrid CPU optimizer、QSA MTP 边界和 PLE checkpoint state;未计为全套通过。
  • 历史两卡 Gloo/NCCL 2 passed。当前未专项验证完整 GPU 在线量化发布、MoE 在线转换、远程 S3 下载或多节点训练。
CUDA_VISIBLE_DEVICES='' python -m pytest -q \
  tests/cpu/utils/test_rollout_quantization.py \
  tests/cpu/backends/megatron/test_actor_lora_publication.py \
  tests/cpu/backends/megatron/weight_conversion/test_quantizer_fp8.py \
  tests/cpu/engine/rewards/test_math_dapo_utils.py \
  tests/cpu/engine/rollout/test_sglang_rollout_dynamic_filter.py \
  tests/cpu/engine/rollout/test_weight_sync_499.py
  • pre-commit run --all-files passes
  • Tests pass (pytest tests/)
  • New tests added (if applicable)
  • Documentation updated (if applicable)

Type of Change

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

Screenshots / Logs

当前 7d73129b7:指定 SGLang0.5.21镜像六文件160 passed、零skip;屏蔽Megatron后的utils全量24passed、零skip;0.5.17布局回归1passed/1skipped;完整pre-commit通过,arch-expert及新独立Codex复核无剩余可行动问题。当前head全部7项必需CI通过,CPU10260passed/115skipped、31subtests通过;所有review threads已核对解决,GPU在线量化与多节点验证限制保留。

Reject incomplete routing replay metadata before mutating samples, and
replace aborted groups within synchronous updates. Keep completed surplus
only in explicitly off-policy modes.

Honor effective rollout quantization overrides, match FP8 parent ignore
modules, exclude hybrid auto-routing and wrap newer collective APIs.
Normalize assistant end markers before DAPO answer extraction.

Validation: 183 CPU tests passed, one hardware-dependent test skipped.
Three focused regressions fail against main and pass with these fixes.
pre-commit --all-files passed.
@Yangruipis
Yangruipis requested review from a team and Lemon-412 November 18, 2026 07:59
@rai-studio-bot

rai-studio-bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @Yangruipis! 感谢你为 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 · 已审批:yuanlehome
团队审批(relax-block-reviewers) ✅ 1/1 · 已审批:yuanlehome
CI ✅ 已通过

@rai-studio-bot

rai-studio-bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: ✅ 已通过

审查版本: 7d73129

目标分支: main

纯配置回归已独立于 Megatron Actor。接收组选择和 DCS 参数覆盖保留,评审意见均已解决。

审查阶段进度范围与结果
常规审查 ✅ 已完成 增量只涉及两个测试文件。生产代码沿用上一轮评审证据。
深度审查 ✅ 已完成 核对了移动后的七个测试函数及配置工具调用。当前提交 CPU CI 的配置文件 24 例和 Actor 文件 28 例全部通过。GPU 在线量化发布仍未专项验证。

审查发现

待处理
编号 严重性 问题状态规则来源
暂无待处理的记录。
已解决或已取代
编号 严重性 问题状态规则来源
F1 Medium severity 用无盒装的答案覆盖 DAPO 结束符清理 ✅ 已解决 —
F2 Medium severity 复用已有 NCCL reload 测试进程
精简建议(非阻塞)
✅ 已解决 —
F3 High severity 按实际接收引擎解析权重发送格式 ✅ 已解决 SGLang 引擎组的覆盖配置优先于 CLI
F4 Medium severity 保留量化配置显式 null 的语义 ✅ 已解决 —
F5 Medium severity 对收尾阶段的完成组应用相同的跨步复用规则 ✅ 已解决 普通同步的超采样完成组在步末丢弃
F6 Low severity 删除 colocated updater 中不可达的 hybrid 判断
精简建议(非阻塞)
✅ 已解决 —
F7 High severity 用已准备的本地 checkpoint 解析同一 S3 来源 ✅ 已解决 Relax 将 S3 checkpoint 映射为节点本地路径
F8 Medium severity 按有效格式比较接收组 ✅ 已解决 —
F9 Low severity 将接收组选择留在 rollout 配置层
精简建议(非阻塞)
✅ 已解决 —
F10 Medium severity 识别接收端的 compressed-tensors 元数据 ✅ 已解决 —
F11 Medium severity 每个 checkpoint 只扫描一次权重分片头
精简建议(非阻塞)
✅ 已解决 —
F12 High severity 按 SGLang 实际解析结果处理嵌套量化覆盖 ✅ 已解决 —
F13 Medium severity 将有效的空量化配置作为 BF16 发送 ✅ 已解决 —
F14 High severity 按加载器选取显式 FP8 的嵌套元数据 ✅ 已解决 —
F15 Medium severity 比较接收端实际使用的权重格式 ✅ 已解决 —
F16 Medium severity 为 ModelOpt FP4 回归限定版本和后端 ✅ 已解决 —
F17 Medium severity 让纯配置回归独立于 Megatron Actor ✅ 已解决 —

改进建议(非阻塞)

拆分

💡 1 个拆分方案

13 个文件共 926 行改动可按六项行为拆分。路由回放中断处理依赖同步补采,其余部分可独立基于 main 提交。

箭头表示前置部分 → 后续部分;目标分支为 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
F["PR F"]
target --> F
Loading
部分PR 主题内容与范围验证
A 同步 rollout 本轮补采 保留 sglang_rollout.py 的 generate_rollout_async 改动与 test_sglang_rollout_dynamic_filter.py。同步模式仅计入已提交的完整组,普通同步在本轮补采中断组,只有 fully async 或 partial rollout 才跨轮保留中断组、过采样余量和收尾受保护组。 用动态过滤回归核对本轮补采、返回样本与实际入队一致,以及 partial 开关下的余量和收尾结果回存。
B 路由回放中断处理 保留 sglang_rollout.py 的 generate 两段改动与 test_weight_sync_499.py,训练 routing replay 收到 abort 时在写入前缀前走现有 GenerationAborted 路径,并补充专家路由形状诊断。A 保证由此标为 ABORTED 的组在普通同步下由本轮补齐。 用 499 套件的 replay 用例核对前缀保留、信号量释放、后续重试成功及非 abort 的异常仍抛错。
C 按接收端选择权重布局 合并 actor.py 的 tensor/distributed 与 DCS 接线和 quant_cast/__init__.py 的有效元数据、分片扫描与布局兼容逻辑。test_rollout_quantization.py 保留直接调用解析器的元数据及真实 loader 用例和两个共享 fixture,test_actor_lora_publication.py 复用 fixture 并覆盖接收组选取、YAML 与全局覆盖、DCS 接线及 sender 分派,四个文件一并落地。 纯配置回归直接调用解析器,Actor 测试验证发布范围、DCS 接线参数和发送端分派。当前提交 CPU CI 中配置文件 24 例、Actor 文件 28 例全部通过,真实 GPU 在线量化权重发布仍待验证。
D FP8 父模块排除 将 quantizer_fp8.py 按点分模块祖先匹配排除项的改动与 test_quantizer_fp8.py 一同提交,沿用基线已有的 modules_to_not_convert 契约。 验证父模块排除覆盖子模块和专家权重,同名前缀的兄弟模块仍会量化。
E 可重载组支持 single collectives 将 reloadable_process_group.py 对两个 Torch single collective API 的条件包装和 tests/gpux4/utils/test_reloadable_process_group.py 的扩展放在一起。 用现有 Gloo/NCCL 多进程回归验证重载前后旧别名,双卡 NCCL 路径另验证新 API 直调及 coalescing。
F DAPO 清理回答结束符 将 math_dapo_utils.py 的 assistant 结束符清理与 test_math_dapo_utils.py 的参数化评分回归一起提交。 验证新增结束符及已有结束符下的正确和错误答案评分、准确率与提取结果。
如何按依赖提交(stack)

已核实当前 PR 来自 Yangruipis/Relax。沿用已确认的 fork 提交路径。

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

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

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

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

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

文件结论仓库维护必要性依据替代去向或方案
relax/engine/rollout/sglang_rollout.py
接收 中止处理、同步补采和缓冲属于 rollout。 PR 说明及原审查 F5。 沿用现有生成和批次流程。
relax/backends/megatron/actor.py
relax/backends/megatron/weight_conversion/processors/quantizer_fp8.py
relax/utils/quant_cast/__init__.py
接收 调用入口、接收组选择、格式比较和导出都服务于权重一致性。 PR 说明及原审查 F7–F10。 由实际发布入口共用接收组选择,沿用量化工具处理元数据和格式。
relax/engine/rewards/math_dapo_utils.py
relax/utils/reloadable_process_group.py
接收 终止符与新版 collective 对应现有模块职责。 PR 中的答案清理和 PyTorch 兼容需求。 沿用已有实现。
tests/cpu/backends/megatron/test_actor_lora_publication.py
tests/cpu/backends/megatron/weight_conversion/test_quantizer_fp8.py
tests/cpu/engine/rewards/test_math_dapo_utils.py
tests/cpu/engine/rollout/test_sglang_rollout_dynamic_filter.py
tests/cpu/engine/rollout/test_weight_sync_499.py
tests/cpu/utils/test_rollout_quantization.py
接收 在对应 CPU 测试验证量化元数据、异常组、DAPO 和配置选择。 原审查及 PR 测试说明。 复用真实解析与文件边界,硬件行为由 CI 验证。
tests/gpux4/utils/test_reloadable_process_group.py
接收 生产重载需 NCCL 和至少两张 CUDA 卡。 既有双进程测试与 F2。 在现有 worker 扩展。
Powered by Nyanpasu with gpt-6.2-sol xhigh, please check the suggestions carefully.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

需要修改

已审阅 7b8be35。当前发送端会绕过引擎组的量化覆盖配置,使 BF16 rollout 接收 FP8 权重和 scale。这个配置在基线可以正确同步。其余行为和测试意见已附在对应代码行。

审查看板

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

Comment thread relax/backends/megatron/actor.py Resolved
Comment thread relax/engine/rollout/sglang_rollout.py Resolved
Comment thread relax/backends/megatron/actor.py Resolved
Resolve sender quantization from the actual receiver groups, preserve
explicit null overrides, and reject conflicting formats before publication.
Apply synchronous carry-over policy to protected groups completed at drain.
Strengthen DAPO coverage and reuse the existing NCCL reload worker.

Validation: full pre-commit; 36 DAPO tests; 11 quantization regressions
with production configuration-parser definitions isolated from runtime
imports. Full Ray/SGLang and GPU/NCCL verification remains for CI.

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

需要修改

已核对 5fc4af9a 的六项原审查意见。两条发送路径现在遵守组级 JSON 覆盖,但新解析器仍会使已支持的 S3 checkpoint 配置在启动时失败,也会漏掉接收端支持的 compression_config,导致 INT4 权重未按接收格式打包。

审查看板

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

Comment thread relax/utils/quant_cast/__init__.py Resolved
Comment thread relax/utils/quant_cast/__init__.py Resolved
Comment thread relax/utils/quant_cast/__init__.py Resolved
Comment thread relax/backends/megatron/actor.py Resolved
Comment thread relax/utils/quant_cast/__init__.py Resolved
Normalize known FP8 defaults for receiver compatibility checks. Resolve
model-source aliases through the prepared local checkpoint before reading
metadata or scanning compressed shards. Apply JSON overrides before the
compression_config fallback, including explicit null and empty configs.

Move recipient selection into the rollout configuration layer so quant_cast
only resolves receiver metadata and compares formats.

Validation: full pre-commit; 51 direct CPU tests pass with 7 runtime-dependent
cases skipped; all 22 configuration cases pass with the production YAML
parser definitions isolated from Ray/SGLang imports. S3 and compression
regressions exercise real local safetensors headers; no GPU tests run.
@Yangruipis
Yangruipis requested a review from RexFlux as a code owner November 18, 2026 09:33

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

需要修改

已确认同源 S3 路径、FP8 等价默认值和接收组职责划分的修复。局部 text_config 覆盖仍可能使发送端丢失接收端保留的 FP8 格式,影响首次权重同步。

评审看板

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

Comment thread relax/utils/quant_cast/__init__.py Resolved
Comment thread relax/utils/quant_cast/__init__.py Resolved
Comment thread relax/utils/quant_cast/__init__.py Resolved
Comment thread relax/utils/quant_cast/__init__.py Resolved
Preserve nested text configuration on partial overrides, normalize empty formats to BF16 passthrough, and use each receiver group quantization method when metadata omits it. Reuse shard headers within one resolution while keeping group ignore rules independent.

Regression controls fail before the fix (7 failed); the six relevant CPU files pass after the fix (151 passed). Real SGLang config probes cover nested FP8, compressed-tensors method fallback and empty target maps. Full pre-commit passes.

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

需要修改

局部覆盖 use_cache 时两端已保留 block FP8。仅清空嵌套量化字段时,发送端仍会丢失 SGLang 保留的顶层 FP8 格式,导致首次权重发布漏发 scale。

评审看板

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

Sync current main, then mirror receiver metadata promotion before JSON overrides. Compare sender format with real Qwen3-VL and SGLang ModelConfig for nested-only clear, double clear, partial override and explicit root null. Related CPU regressions: 153 passed; full pre-commit passes.
Resolve the effective receiver format only from promoted root fields after overrides, while retaining nested fallback for raw checkpoint readers. Independent Codex review found root-only null could otherwise re-enable nested FP8. Real SGLang/Qwen3-VL controls reproduce two mismatches before the fix and pass after it; 155 related CPU regressions pass.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

需要修改

自动检测下只清空嵌套量化字段的场景已修复。显式指定 FP8 且顶层量化字段为 null 时,发送端仍会漏掉 SGLang 加载器使用的嵌套元数据,导致首次权重发布缺少 block FP8 的 scale。

评审看板

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

Comment thread relax/utils/quant_cast/__init__.py Resolved
Separate automatic quantization detection from the selected loader's
checkpoint metadata. Explicit FP8 can load nested Qwen3VL metadata even
when the root config is null; publish the corresponding FP8 weights.
Reject metadata incompatible with the selected receiver method.

Validate actual SGLang get_quant_config for automatic and explicit modes.
The two explicit-mode regressions fail before the fix; 157 related CPU
tests pass in the requested CUDA 12 image. Full pre-commit checks pass.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

原阻塞项已修复

显式 FP8 下,发送端已与 SGLang 加载器读取同一份嵌套配置。当前提交还有一条非阻塞的兼容性意见,涉及相同 FP8 权重布局的不同配置写法。

评审看板

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

Comment thread relax/utils/quant_cast/__init__.py Resolved
Normalize explicit receiver mode names as SGLang does and preserve the
checkpoint source layout selected by its loader. Runtime modes can share
a source layout: modelopt_fp4 dense layers still load serialized block
FP8. Remove the mode-name equality check that rejected these receivers.
Keep receiver layout comparison and the sender's unsupported-format error.

Real ModelConfig/get_quant_config/LinearBase regressions for YAML FP8
and global modelopt_fp4 fail before this fix. Unsupported serialized
NVFP4 still fails in the actual sender dispatch. All 160 related CPU
tests and full pre-commit checks pass in the requested image.

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

评审意见

已确认 YAML FP8 和密集 Qwen3 的 modelopt_fp4 都继续使用接收端预期的 block FP8 格式。剩余一条非阻塞意见,涉及新增 ModelOpt 测试在 CUDA 12 镜像上的版本条件。

评审看板

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

已复核 380d3625,ModelOpt 回归测试已按 SGLang 版本和后端限定执行,相关评审意见均已解决。评审面板

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

Move receiver selection into a private Megatron actor method shared by
the existing tensor/distributed sender and DCS client setup. Retain the
conditional YAML import and the quantization parser in quant_cast.

Adapt existing tests to execute the actual actor method while preserving
their dependency, SGLang version and backend guards.

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

评审意见

两条发布路径仍使用相同的接收组选择与格式解析。新增一条非阻塞意见,涉及搬迁后配置回归的 Megatron 导入依赖。评审面板

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

Run metadata and loader checks directly against the receiver parser.
Keep receiver selection, publication wiring and sender dispatch in the
existing actor suite with its established dependency guard.

Reuse fixtures and retain the previous assertions and SDK/backend guards.

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

已复核 7d73129b。纯配置回归可以独立执行,Actor 发布覆盖已保留,当前评审意见均已解决。评审面板

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

@Yangruipis
Yangruipis merged commit 0f6dac5 into redai-studio:main Nov 19, 2026
23 checks passed
NINGBENZHE pushed a commit to NINGBENZHE/Relax that referenced this pull request Nov 19, 2026
…io#720)

## What

修复普通同步 rollout 的旧策略样本跨轮复用,以及权重同步时发送端未采用接收端有效配置的问题。

- 普通同步模式在本轮补采 aborted group,丢弃超出目标 batch 的结果;显式 async/partial rollout
保留原有跨轮复用。
- 权重发送根据实际接收组的 checkpoint、量化模式和 overrides 决定 tensor 格式,提前拒绝不兼容的接收组组合。
- 同时修复 routing replay 的 abort 处理、FP8 排除规则对父模块的匹配、新版 Torch collective API
适配,以及 DAPO 答案末尾的 assistant 结束符清理。

## Why

**同步训练可能意外用了旧策略生成的样本。** rollout 过采样会产生超出本轮 batch
大小的完整结果。原逻辑可能将这些结果缓存到下一轮;但下一轮开始前已经更新了 rollout 权重,因此 batch
中会混入上一版本策略的样本。普通同步模式需要在本轮补采被中断的组,并丢弃多余结果。显式 async、partial rollout
的复用行为保持原样。

**训练端转换权重时,可能没有采用接收端真正生效的配置。** 例如 checkpoint 自带 FP8 配置,但某个 rollout 引擎通过
override 关闭了量化。旧发送逻辑仍可能依据原 checkpoint 做 FP8 转换,导致发送的 tensor 格式、scale
参数与接收模型不匹配。发送端需要先解析实际接收组及其最终配置,再决定权重转换格式;多个接收组要求不兼容时,在传输前报错。

这些修复位于框架的 rollout、量化配置解析和权重同步路径,适用于不同模型。

## How

- 同步模式在当前 step 补采 aborted group;主循环产生的 surplus 和 abort
收尾期间完成的多余结果均不回存下一轮。routing replay 在修改响应前缀前处理 abort,并给出 expert 尺寸错误信息。
- 两个发布入口在 `MegatronTrainRayActor` 内共用
`_resolve_push_quantization_config()` 私有方法。删除独立的
`relax/distributed/ray/rollout_weight_config.py` 文件;YAML
路径继续局部导入原配置解析器,量化 metadata/布局解析仍归 `utils.quant_cast`。
- 普通 tensor/distributed 更新覆盖首个模型的实际引擎;DCS 覆盖共享 rollout role 的所有 YAML
模型引擎,排除 placeholder。组级 JSON 整字段覆盖全局配置,显式 `null` 不被原 checkpoint 值重新覆盖;保留
text_config 字段更新、compression fallback 和单次分片扫描。
- 区分运行时量化模式与 checkpoint 源布局,按实际布局比较接收组。例如 `modelopt_fp4` 的密集层也可能加载
serialized block FP8 源权重,不能仅因模式名称不同拒绝。未支持的 serialized NVFP4 仍由真实 sender
dispatch 在传输前拒绝。
- 沿用现有 process-group wrapper,兼容 single-tensor collective
API,并覆盖直接调用、coalescing 及已导入别名。

此 PR 独立基于 main,不包含模型实现、专用 FP8 kernel 或 fused CE。

## Testing

当前修订 `7d73129b7`,基于 main `43fa07d5e`。

- 维护者指定的 CUDA 12 / SGLang **0.5.21** 镜像隐藏 GPU 后,六个相关 CPU 文件 **160
passed,零 skip**。覆盖真实 SGLang loader/linear、同步样本处理、FP8 转换,以及 DCS client
实际接收的量化配置。
- 真实 SGLang **0.5.17** 布局回归 **1 passed /1 skipped /22 deselected**;YAML
FP8 继续执行,唯一 skip 是该版本不支持的 ModelOpt 组合。ROCm 仅跳过不支持的 ModelOpt 参数;sender
NVFP4 拒绝回归保留。受控 HIP detector 探针不构成 AMD 实机验证。
- 纯元数据与真实 loader 用例直接调用
`resolve_receiver_quantization_config`;接收组选取、YAML/global overrides、DCS
发布范围及 sender dispatch 放入已有 actor 测试文件,使用其既有依赖检查并直接调用实际私有方法。原断言和 SDK/HIP
条件保留,无新增 skip。
- 屏蔽 Megatron 后,utils 配置文件全量 **24 passed、零 skip**;此前显式 null
三例在该条件下失败,修正后 **3 passed**。共享 fixture 显式导入复用,不重复实现测试逻辑。
- arch-expert 只读复核、新独立 Codex session 完整增量复核均无剩余可行动问题。完整 `pre-commit run
--all-files --show-diff-on-failure` 通过。
- **当前 head `7d73129b7c80ac048a66ddfc00b7ad992c4d4810`
的7项必需CI全部通过**:pre-commit、完整CPU、H20单卡/四卡、VL GPU集成、异步GPU集成、异步NPU集成。完整CPU
**10260 passed /115 skipped、31 subtests passed**;这些均为当前head实际结果。
- 指定镜像此前完整 CPU 范围为 **10081 passed /185 skipped /9 failed,29 subtests
passed**。这9项在同镜像纯 main `43fa07d5e` 完全复现,涉及 hybrid CPU optimizer、QSA MTP
边界和 PLE checkpoint state;未计为全套通过。
- 历史两卡 Gloo/NCCL 2 passed。当前未专项验证完整 GPU 在线量化发布、MoE 在线转换、远程 S3 下载或多节点训练。

```bash
CUDA_VISIBLE_DEVICES='' python -m pytest -q \
  tests/cpu/utils/test_rollout_quantization.py \
  tests/cpu/backends/megatron/test_actor_lora_publication.py \
  tests/cpu/backends/megatron/weight_conversion/test_quantizer_fp8.py \
  tests/cpu/engine/rewards/test_math_dapo_utils.py \
  tests/cpu/engine/rollout/test_sglang_rollout_dynamic_filter.py \
  tests/cpu/engine/rollout/test_weight_sync_499.py
```

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

## 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
- [x] Refactoring (no functional changes)
- [ ] Performance improvement
- [ ] CI/CD or build changes

## Screenshots / Logs

当前 `7d73129b7`:指定 SGLang0.5.21镜像六文件160
passed、零skip;屏蔽Megatron后的utils全量24passed、零skip;0.5.17布局回归1passed/1skipped;完整pre-commit通过,arch-expert及新独立Codex复核无剩余可行动问题。当前head全部7项必需CI通过,CPU10260passed/115skipped、31subtests通过;所有review
threads已核对解决,GPU在线量化与多节点验证限制保留。
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.
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.

3 participants