Skip to content

fix(sglang): sync same-checkpoint NEXTN draft weights - #640

Merged
Yangruipis merged 3 commits into
redai-studio:mainfrom
kkyyxhll:codex/fix-nextn-distributed-weight-sync
Nov 16, 2026
Merged

Yangruipis merged 3 commits into
redai-studio:mainfrom
kkyyxhll:codex/fix-nextn-distributed-weight-sync

Conversation

@kkyyxhll

@kkyyxhll kkyyxhll commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

同 checkpoint 的 NEXTN engine 在分布式权重更新时显式使用 selector="all"。适用于 SGLangEngine 直接发送和 full async 的 DCS 发送路径。

Why

SGLang 0.5.21 的兼容路径在省略 selector 且没有显式更新 session 时只加载 target。即使 NCCL 广播包含 mtp.* 权重和 FP8 scale,MTP draft 仍会停在旧权重。

How

  • 用每个 engine 的配置判断 target 和 NEXTN draft 是否共用 checkpoint 与 revision。外部 engine 使用已有的 server info 核对实际配置,识别 SGLang 将 NEXTN 归一化后的 EAGLE 名称。
  • 把同一个判定写入 DCS rollout 注册 metadata。DCS 组装 /update_weights_from_distributed 请求时按 rank 读取该 metadata,只对符合条件的 engine 附上 selector="all"。
  • SGLang 仍接收一次 NCCL 张量,再把同一批数据交给 target 和 draft 的 loader。独立 draft、不同 revision、非 NEXTN 和缺少该 metadata 的请求沿用原有行为。

Testing

  • 全仓 pre-commit 和 git diff --check 通过。
  • 207 项相关 CPU 回归通过,覆盖逐 engine 注册、混合 DCS 拓扑、权重同步生命周期、MTP 参数名与 FP8 转换。新增断言在原 PR 版本复现了 DCS 请求缺少 selector。
  • 双 H800 小张量验证使用 DCS 实际请求构造、HTTP、NCCL,以及安装的 SGLang 0.5.21 Qwen target 和 MTP loader。复测两轮由 DCS 生成 selector="all",两端的 FP8 权重字节和 FP32 scale 均逐项匹配。测试替换 Ray 调度与 tokenizer/scheduler IPC,覆盖请求和权重加载,不启动完整模型训练。
CUDA_VISIBLE_DEVICES='' python -m pytest -q \
  tests/cpu/backends/sglang/test_sglang_engine.py \
  tests/cpu/backends/megatron/weight_update/test_mtp_global_names.py \
  tests/cpu/backends/megatron/weight_conversion/test_quantizer_fp8.py \
  tests/cpu/distributed/checkpoint_service
  • 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

DCS 请求 Draft FP8 权重读回 Draft FP32 scale 读回
修前两轮,省略 selector 0.5 → 0.5 0.03125 → 0.03125
修后两轮,DCS 生成 selector=all 1.5 → 2.5 0.0625 → 0.09375
This PR is co-authored with @codex

Route distributed updates to both SGLang runners for same-checkpoint
NEXTN. The target runner receives the NCCL payload once and SGLang
dispatches those weights to both loaders.

Co-authored-by: Codex <[email protected]>
@kkyyxhll
kkyyxhll requested a review from a team November 11, 2026 12:56
@kkyyxhll
kkyyxhll requested a review from yuanlehome as a code owner November 11, 2026 12:56
@rai-studio-bot

rai-studio-bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @kkyyxhll! 感谢你为 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 / 状态
审批人数 ⏳ 0/1 · 至少 1 位有仓库 write 或更高权限的人 Approve
团队审批(relax-block-reviewers) ⏳ 0/1 · 可联系:Aurelius84, Yangruipis, RexFlux, yuanlehome, SigureMo, NINGBENZHE, Lemon-412
CI ✅ 已通过

@rai-studio-bot

rai-studio-bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: ✅ 已通过

审查版本: 8c226ca

目标分支: main

复审通过:8c226ca9 仅补齐恢复注册测试的 NEXTN 状态与 metadata 断言,修复已定位的 fixture 缺字段问题;生产代码与已审的 7f77523 相同,未发现新的可操作问题。原 F1 修复结论保留。

审查阶段进度范围与结果
常规审查 ✅ 已完成 接收范围共 6 个文件;本次逐行核对了相对 7f77523 的两行测试增量,复用其余未变更部分的审查证据。fixture 保留 actor_id 断言,并新增 sync_nextn_draft=False 断言;本轮未运行本地测试,当前 head CI 尚未完成。
深度审查 ✅ 已完成 此前已核对 engine 判定、DCS metadata 传递、逐 rank selector 及 SGLang 单次接收/双 loader 契约,本次生产代码未变化。完整 NEXTN/MTP GPU 或多节点训练仍未独立验证;作者双 H800 实验未复跑。

审查发现

待处理
编号 严重性 问题状态规则来源
暂无待处理的记录。
已解决或已取代
编号 严重性 问题状态规则来源
F1 Medium severity 补齐 DCS 直接请求的 NEXTN 同步覆盖(base 已有,非阻塞) ✅ 已解决 —
提交范围 · 接收 6 · 建议移出 0 · 待确认 0

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

文件结论仓库维护必要性依据替代去向或方案
relax/backends/sglang/sglang_engine.py
relax/distributed/checkpoint_service/backends/device_direct.py
接收 保留已审查的 NEXTN engine 判定、注册 metadata 与 DCS 逐 rank 请求修复,当前增量未改动生产逻辑。 PR #640 的同 checkpoint NEXTN 同步需求,以及 7f77523 已验证的调用链。 现有 engine 与 DCS 边界适合该协议修复。
tests/cpu/backends/sglang/test_sglang_engine.py
tests/cpu/distributed/checkpoint_service/test_dcs_fused_weight_buckets.py
tests/cpu/distributed/checkpoint_service/test_weight_sync_lifecycle.py
tests/cpu/distributed/ray/test_recovered_engine_registration.py
接收 前三处保留现有回归;恢复注册测试补齐新字段以修复已定位的 CPU fixture 失败。 既有 NEXTN 请求回归,以及当前 head 前的 CPU CI 失败和人类 review 指出的 fixture 缺字段。 直接扩展已有恢复注册测试,无需新增测试文件或生产默认值。
Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

审查完成:有非阻塞补充

已审查 0651644 的两处改动,未确认新增阻塞问题;记录一项 base 已有的 DCS 路径修复覆盖缺口。CPU CI 的新增请求回归已通过;完整 NEXTN/MTP 训练未独立验证。NPU CI 失败发生于未启用 NEXTN 的生成内核,具体证据见看板。

审查看板

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

if weight_version is not None:
payload["weight_version"] = weight_version
if self._sync_nextn_draft:
payload["selector"] = "all"

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 · 补齐 DCS 直接请求的 NEXTN 同步覆盖(非阻塞)

常规 Megatron --fully-async --enable-mtp-training(非 hybrid)经 CheckpointEngineClient → DeviceDirectBackend 更新 rollout;DCS 发送端使用自己的 HTTP 代理,既不调用这里的方法,也未开启 weight-update session。因此在仓库 patch 的 SGLang 0.5.21 上,该路径仍默认只加载 target,同 checkpoint NEXTN draft 的专属 MTP 权重及相应 FP8 scale 仍不会刷新。

这是 base 已有问题在本次修复中的覆盖缺口,非新增回归。建议后续在 DCS 发送边界按每个 engine 的有效配置采用同样的 selector 策略;当前 PR 说明也应明确修复限于经过 SGLangEngine 的请求。

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.

确认 7f775237 已补齐:engine 将同 checkpoint NEXTN 判定写入注册 metadata,DCS 从 topology 按 rank 生成 selector="all",不符合条件或缺少 metadata 的 engine 保留原请求。我核对了 client/coordinator 的 metadata 传递、实际发送方法及新增混合拓扑回归;原覆盖缺口已解决。本轮未重复执行本地测试,完整 NEXTN/MTP 训练仍未独立验证。

@kkyyxhll
kkyyxhll requested a review from NINGBENZHE as a code owner November 11, 2026 13:24

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

复审通过

已核对 7f775237 的 DCS metadata 传递、逐 rank 请求选择及回归覆盖,原 F1 已修复,未发现新的可操作问题。当前 head 的 pre-commit 已通过,其余 CI 尚在排队或运行;本轮未运行本地测试,也未独立验证完整 NEXTN/MTP 训练。原线程已回复修复确认,但当前账号无权将其标记为 resolved。

审查看板

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

@Yangruipis Yangruipis left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

已审查当前 head 7f775237dc47c6f431668d406db51bc836372e78 的全部 5 个变更文件,并在SGLang 0.5.21 测试环境中验证。

生产逻辑未确认新的可操作缺陷:已核对逐 engine 的 checkpoint/revision 判定、NEXTN→EAGLE 归一化、外部 engine 配置检查,以及 metadata 经 client/coordinator/topology 到 DCS 按 rank 生成 selector 的链路。原 DCS 覆盖缺口已经补齐。有 1 项 P2 测试回归需要补齐,见行级评论。

实际测试:

  • PR 描述的 engine、MTP name、FP8 quantizer、DCS 回归,再加 tests/cpu/distributed/ray/test_recovered_engine_registration.py,结果为 229 passed, 1 failed。唯一失败为 test_dcs_registration_carries_exact_engine_generation 缺 _sync_nextn_draft;同一测试环境中 base 325a4f84538d87c06f829d47dcb6b2b75690faab 的该用例通过,确认由本次改动触发。
  • 另将真实 DeviceDirectBackend._update_bucket_weights_from_distributed 生成的三种 rank payload,交给镜像内真实 UpdateWeightsFromDistributedReqInput 和 SchedulerWeightUpdaterManager.update_weights_from_distributed:注册 True 的 rank 为 selector=all,target/draft 各加载一次且使用同一份接收列表;注册 False 或缺 metadata 的 rank 保留 selector=None,只加载 target;每次仅接收一次。此项验证替换了 Ray/NCCL 传输和模型 loader,属于 CPU 控制流集成验证,不是 GPU 权重正确性验证。
  • git diff --check 通过。未运行 pre-commit,未修改代码。

验证限制:本轮没有可用的 GPU 测试环境,未复跑作者双 H800 FP8/NCCL 小张量实验,也未进行完整 NEXTN/MTP 训练;上述结论不代表这些路径已经过独立硬件验证。

Comment thread relax/backends/sglang/sglang_engine.py Resolved
@kkyyxhll
kkyyxhll requested a review from RexFlux as a code owner November 13, 2026 07:37

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

复审通过

已核对 8c226ca9:增量仅为恢复注册测试初始化 _sync_nextn_draft=False 并校验注册 metadata,与生产构造默认值一致,移除了此前已定位的 fixture 缺字段触发条件;生产代码未变化,未发现新的可操作问题。本轮未运行本地测试,当前 head CI 尚在运行,完整 NEXTN/MTP 训练仍未独立验证。

审查看板

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

@Yangruipis Yangruipis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

复审版本:8c226ca969e1dec68d6eee3cf2f40ad79058319c。此前 P2 测试回归已修复,当前未发现剩余可操作问题,建议通过代码审查。

相较上一轮 7f775237,本次仅修改恢复注册测试的两行:初始化 _sync_nextn_draft=False,并断言注册 metadata 中的值;生产代码未变。已核对原故障触发条件消除,原线程已更新并关闭。

本轮验证:

  • 在当前精确 head 重跑与上轮相同的 engine、MTP 参数名、FP8 quantizer、DCS 与恢复注册扩展回归:230 passed。上轮同一套件为 229 passed、1 failed,原失败用例本轮通过。
  • 再次将真实 DCS 方法构造的逐 rank payload 交给 SGLang 0.5.21 的真实请求类型和权重更新 manager:标记 True 的 engine 使用 selector=all,target/draft 共享同一接收列表,各加载一次;标记 False 或缺 metadata 的 engine 保持只更新 target。该 CPU 控制流验证替换了 Ray/NCCL 传输及模型 loader,不代表硬件权重正确性验证。
  • git diff --check 通过;已核对当前 head 的全部必需 CI 为通过,包括 CPU、单卡、四卡及 GPU/NPU 集成检查。未修改代码,未主动运行 pre-commit。

验证限制:未独立执行作者报告的双 GPU FP8/NCCL 实验或完整 NEXTN/MTP 训练;普通集成 CI 通过不能代替未覆盖的 NEXTN 专项硬件证据。

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

1. The capability Relax already had

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

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

2. The concurrency problem that motivated the original feature

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

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

3. How the Relax requirement became substantially stronger

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

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

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

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

4. How subsequent upstream work inherited the LoRA contract

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

6. Why the managed subsystem is removed

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

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

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

7. What this commit removes and restores

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

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

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

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

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

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

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

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

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

9. The small Agentic single-adapter connection

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

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

10. Validation and evidence limits

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

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

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

References

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

BREAKING CHANGE: Remove Relax's managed multi-version LoRA publication APIs
and whole-Session version-pinning behavior. Ordinary LoRA merge and
fixed-name adapter serving remain supported, with fixed-name selection
also connected to Agentic generation.
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