Repository navigation
feat(hybrid): 通过 DCS 同步权重并支持弹性 Rollout - #554
Conversation
|
Thanks for contributing to Relax, @RexFlux! 感谢你为 Relax 做出贡献! 📚 Contribution guide / 贡献指南Describe the problem, your changes, and how you validated them. Keep each PR focused and run 请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行 🛠️ CI commands / CI 指令
Put one command on the first line of a new PR comment. Rerun/cancel require PR authorship or repository write access. 在新 PR 评论的首行写一条指令。PR 作者或有仓库写权限的贡献者可以重跑、取消 CI。 🔎 Merge requirements / 合入条件GitHub:✅ 满足合入条件
|
Nyanpasu 审查看板审查状态: ✅ 已通过 审查版本: 8179ec8 目标分支: main 已完成当前版本审查:PLE 发送失败协调、Hybrid 握手失败后的评估门控,以及合入 main 后的 MOPD 收尾和完整评估组保护均已核对,未发现新增可操作问题。既有 F1 保持已解决。
审查发现待处理
已解决或已取代
改进建议(非阻塞)拆分💡 1 个拆分方案 可选边界为 C(PLE 分片与失败协调)先于或随 A(Hybrid DCS)交付,B(评估完整组)独立。2586 行中 1494 行为测试,无生成/锁文件膨胀;尊重作者单 PR 偏好,此方案仅供维护者需要分开评审时采用。 箭头表示前置部分 → 后续部分;目标分支为 flowchart LR
target["目标分支"]
A["PR A"]
C --> A
B["PR B"]
target --> B
C["PR C"]
target --> C
如何按依赖提交(stack)已核实 RexFlux 对 redai-studio/Relax 具有 write 权限;PR head 来自 RexFlux/Relax fork。 先按表重组混合提交,每部分携带对应测试和文档;逐层验证,并核对顶层最终树与原 PR 一致。独立部分各自向目标分支开普通 PR;只将有依赖的线性链组成 stack,分叉或多前置依赖按图分别安排提交。 有上游写权限: 将各层分支放在上游仓库,在已按依赖拆好的一条分支链上注册并提交(替换目标分支与分支名): gh stack init --base <target> <layer-1> <layer-2>
gh stack view
gh stack submit下层更新后用 相关 PR💡 实现与合入建议#554 与 #502 部分重叠,无当前硬依赖;建议在共享运行时收敛后保留 #502 独有的 9B CE 配方。#526 已关闭未合并。 https://github.com/redai-studio/Relax/pull/502 · https://github.com/redai-studio/Relax/pull/526 · 实现取舍: 共享 actor/client/backend 方法一致。优先采用 #554 的 PLE 全 TP 分片、stage 内发送失败传播、快照和接收端生命周期;#502 尚无等价 PLE 分流。#502 的 9B actor8 TP4/DP2 + rollout2 配方及双模式 argv 回归仍有独立用途。 当前 PR 调整: 当前 #554 保留完整运行时及对应回归,维持作者单 PR 交付意图;无需提前删除尚未合入的共享实现,也无需吸收 #502 的 9B 配方或重引已在 main 的 #555 observability。 合入顺序: 可先落地就绪的 #554,再让 #502 rebase、移除届时已覆盖的运行时增量,保留独有配方/文档/回归。若选择 #502 先合,应先补齐等价 PLE 与失败协调保护,再让 #554 去重。#526 无需合入;不据此关闭 #502。 依据与验证范围: 已按三 PR 固定 head/base 核对源码及讨论;[PLE 实现](https://github.com/redai-studio/Relax/blob/8179ec87ecfd816ffeb486918f235b1b8516036a/relax/distributed/checkpoint_service/backends/device_direct.py#L925)、[9B 配方](https://github.com/redai-studio/Relax/blob/fa7320ae08d1a85fe432c3f3bf3a6a3e77e0f551/scripts/training/text/run-qwen35-9B-elastic-rollout-hybrid.sh)、[#526 关闭说明](https://github.com/redai-studio/Relax/pull/526#issuecomment-6680093265)。此项仅静态协调分析;作者的训练记录不能证明同条件效果或性能等价。 提交范围 · 接收 30 · 建议移出 0 · 待确认 0接收 30 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。
Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rai-studio-bot
left a comment
There was a problem hiding this comment.
结论:需要修改(REQUEST_CHANGES)。
阻断问题:
- P1:Hybrid + Bridge + Qwen4Exp PLE + TP>1 的 DCS 更新存在 collective 参与失配,可能在首次权重同步时挂起。请修复为全 TP 参与的 PLE shard 导出/广播路径,或在该组合下明确拒绝启动,并补充多 rank 回归测试。详见行内线程。
审查范围已覆盖固定头的 29 个变更路径;当前 CI 检查通过。真实 GPU/NCCL 端到端验证未执行,因此该边界仍需在修复后由 GPU CI 或集群验证确认。拆分分析因服务模型容量失败,dashboard 已记录为未完成的非阻塞建议。
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查结论(15beb12c953e99fab0a471d5c637d5157f3fa8d2):APPROVE。
原先发现的 P1 已修复:DeviceDirectBackend 现在让所有 TP rank 进入 Bridge iter_ple_shards 的逐 shard collective,仅 PP source rank 发送转换后的 shard;actor_fwd/reference 仍使用完整表 gather。新增双进程 Gloo 回归覆盖 Hybrid、raw、actor_fwd-only、LoRA skip-base、多轮更新及融合桶边界,本地选定用例通过(1 passed,26.14s)。当前 CI 刷新无失败项。
未发现其他可行动问题。真实 GPU/NCCL、PP/VP、MoE/量化和多节点端到端验证未在本地执行,需依赖对应 CI/硬件环境。2433 行直接变更的非阻塞拆分建议已记录在审查看板中。
感谢建议,这次计划保留单个 PR。评估分组与 coverage 部分涉及 4 个文件、259 行增删,约占总改动的 10.6%;拆出后主体仍有约 当前六项 required CI 均已通过,也完成了真实 GPU 的 Hybrid 弹性 Rollout 验证,以及 PLE 修复后的 TP2/NCCL 定向验证,具体范围 |
Route hybrid rollout weight updates through DCS using actor snapshots that preserve Megatron TP metadata, with optional device-resident backups. Coordinate topology and receiver lifecycle across training ranks, retain complete evaluation prompt groups, and add an elastic hybrid recipe. Preserve current resident-SFT, score-centering, bucket assembly and recovery behavior while adapting the original merge delta to the GitHub mainline. (cherry picked from commit 55d145f) Co-authored-by: Codex <[email protected]>
Supply the parser's default weights-backuper setting in the manually built score-centering test arguments so Hybrid validation checks the intended configuration. Preserve the runtime rejection of disabled Hybrid backups. Co-authored-by: Codex <[email protected]>
Route Bridge PLE weights before the generic full-table TP gather. Consume TP-local shard exports on every rank and send each HF shard from the source rank, preserving pending fused pairs and releasing the export on failure. Keep the existing raw Megatron payload protocol for actor_fwd/reference. Add a two-process CPU/Gloo regression for collective participation, exact shard values, repeated updates, and raw/HF consumers. Related CPU tests: 65 passed, 10 skipped (Qwen4Exp Bridge is unavailable locally). Real Qwen4Exp GPU/NCCL validation remains outstanding. Co-authored-by: Codex <[email protected]>
15beb12 to
9a46e17
Compare
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查通过
已复核 9a46e171 相对 1bec680c 的 rebase,DCS/PLE、快照与评估冲突处理保留了原契约,未发现新的可行动问题。源码比较和两项隔离评估探针支持此结论;本轮未重跑完整 GPU/多节点集成。当前 CI 无失败项,部分必要检查仍在排队或运行,尚不能视为全部通过。
Share source-side preflush, raw-send and PLE shard-send errors with every TP/DP/CP rank of the same pipeline stage before the next collective. Keep other PP stages independent, preserve the original source exception, and close the shard iterator on every participating rank. When the Hybrid rollout handshake fails, retain metric flushing, the rank barrier and end-update cleanup while skipping evaluation for unpublished weights. Reuse the cleanup helper in the normal evaluation finally path. Add real four-process Gloo fault regressions for TP2/DP2 and a nonzero PP source, plus skipped-handshake lifecycle coverage. Related CPU regression: 401 passed, 10 skipped (Qwen4Exp Bridge unavailable), 3 subtests passed. Full pre-commit passed; no new GPU/NCCL validation was performed. Co-authored-by: Codex <[email protected]>
Merge upstream main at 957b418 while retaining both review fixes from 77adc13. Resolve the grouped-scoring conflict by preserving main's MOPD response-statistics cleanup and this PR's aborted evaluation-group guard. Related CPU regression after the merge: 497 passed, 10 skipped for the unavailable Qwen4Exp Bridge module, and 3 subtests passed. Full pre-commit passed. Historical GPU results remain bound to their original commits. Co-authored-by: Codex <[email protected]>
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查通过
已完成 8179ec87 的增量审查:PLE 发送失败传播和握手失败后的评估门控保持完整,合入 main 后也保留了 MOPD 收尾与评估完整组保护,未发现新增可操作问题。本轮复用原版本的定向 Gloo 证据,未重跑 GPU/NCCL 或多节点集成。
NINGBENZHE
left a comment
There was a problem hiding this comment.
已复核此前两条评论。双进程 Gloo 故障注入确认 PLE 发送异常会在当前分片传到对端。Hybrid 握手失败时会跳过本步评估并清理握手。6 项必需检查已通过,同意合入。
## What Add the Qwen3.5-9B hybrid elastic-rollout CE launch recipe. ## Why Hybrid DCS support is now available on main through #554. Add a dedicated 9B hybrid CE entrypoint so the two training recipes remain independent. ## How The standalone hybrid script uses actor8 (TP4/DP2), two initial rollout engines, and the existing autoscaler policy with a maximum of eight engines. Reference/forward/advantages run on the actor GPUs. The ClearML project, experiment prefix, and log filename identify hybrid runs. Following the launcher organization in #517, the hybrid script resolves its own checkout, dispatches through the standard Ray entrypoint, groups environment and training arguments, and supports trailing argument overrides and a side-effect-free JSON `DRY_RUN=1`. It preserves the existing CE script path, model/data root fallbacks, runtime setup hooks, and transport settings. The full-async script is byte-for-byte identical to main. This PR only adds the hybrid script; framework behavior comes from main. ## Testing - Ad hoc argument-capture validation: full-async matches main byte-for-byte; the hybrid training argv and runtime-env match the prior script, apart from experiment timestamps. The real CE argument-rewrite function preserves HF/ref checkpoint, ClearML project/name, and save-directory overrides. - `bash -n` passes for both scripts. - `pre-commit run --all-files --show-diff-on-failure`: passed. - Independent read-only review found no remaining blockers. - [x] `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) - [x] 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 An earlier run pinned to `fa7320ae08d1a85fe432c3f3bf3a6a3e77e0f551` completed 100 consecutive training steps, six scale-outs from 2 to 8 engines, and one automatic scale-in from 8 to 7, followed by a successful DCS update and normal completion. That is historical validation; this rebase onto `64ffb3f0214c815d4bd366215675d5129c4ae264` has not been rerun on GPUs. <div align="right"> <sup>This PR is co-authored with @codex (gpt-6)</sup> </div> --------- Co-authored-by: Codex <[email protected]>

What
--hybrid-weights-backuper-on-gpu,允许在显存充足时将 actor 快照常驻 GPU,默认仍保存在主机内存。Why
Hybrid 原先通过
UpdateWeightFromTensor推送权重,未复用 Fully Async 已有的 DCS 弹性拓扑和恢复后发布路径。训练模型还会在 actor、reference、actor_fwd 等角色之间切换,因此同步必须读取固定的 actor 快照;快照若丢失 TP 属性,会把分片误当成复制权重。本 PR 迁移源提交
55d145f31d4ee2c52574d313626e11f776ecba19相对第一父提交的净改动。该提交是 merge commit,因此采用第一父提交作为 mainline 提取功能增量,并在 GitHub 当前主线上解决冲突。How
finally中恢复 offload;成功同步后推进 old_actor 队列。GPU 快照按 device/dtype 复用连续 buffer。--disable-weights-backuper,同用时启动即报错。评估按原始 prompt 边界过滤缺失、aborted 或无 reward 的组,避免跨 prompt 计算 pass@k,并上报总数、有效数和 coverage。iter_ple_shards,仅源 rank 逐片发布,Hybrid 不聚合整张 PLE 表。actor_fwd/ref 的原始 Megatron 权重协议继续保留;未配齐的 fused pair 跨分片保留,导出中断时显式关闭迭代器。MODEL_DIR、DATA_DIR、SAVE_DIR,以稳定的${SAVE_DIR}/${EXP_NAME}保存和恢复,保留两个 checkpoint;默认启用 ClearML,Ray 提交默认阻塞。Testing
当前 head:
8179ec87ecfd816ffeb486918f235b1b8516036a。两条评审修复提交为77adc136;随后同步main@957b4180消除新产生的合并冲突,保留主线 MOPD teacher response 统计收尾与本 PR 的评估完整组保护。两条修复的生产代码与回归测试在同步主线前后无差异。同步后的扩展 CPU 回归:497 passed、3 subtests passed、10 skipped,涵盖下述 401 项回归及新增 MOPD、checkpoint/SFT 相关检查。全仓 pre-commit、PR 增量 diff 检查与独立合并审查通过。新提交的 CI 以当前 head 的检查记录为准;当前 head 已补充完成下述 4×B300 GPU/NCCL 定向复测,历史完整训练证据仍绑定原 SHA。
2026-11-10 当前 head 的补充 GPU 验收:4×B300,真实 NCCL,TP2×DP2 与 PP2×TP2 均通过(PyTorch 2.11.0+cu130、CUDA 13.0、NCCL 2.28.9)。
PLENGramEmbeddingMapping、BridgeConverter、生产 DCS 分发与实际 Megatron stage/TP 进程组。目标镜像缺少 Qwen4Exp Bridge 模块,完整模块从当前提交跟踪的 patch 原样还原到独立 overlay,未修改已安装依赖;生产源码、patch、overlay 和实际导入路径均按 SHA256 核对。2026-11-10 评审修复:提交
77adc136e8b6ff9238b2a682896cf498d6e16476处理两条新反馈,保留当前单 PR 交付。/end_update_weight清理仍执行。正常评估的 finally 复用同一清理 helper。2026-11-09 rebase 记录:提交
9a46e17133781b0533c00581fececc9e97fc982e已基于最新main(1bec680c)重新整理。评估分组冲突保留主线的 early return 和 OPD helper,并保留本 PR 对评估 aborted 分组的完整性保护;主线 observability 改动完整保留,PLE/DCS/快照实现相对 rebase 前未变。本次隐藏 GPU 的相关 CPU 回归:383 passed,3 subtests passed,10 skipped。覆盖 Hybrid 生命周期/参数、DCS/PLE、resident SFT、评估分组与 coverage、OPD 和 observability 隔离。10 项因本地缺少 Qwen4Exp Bridge 模块而跳过,未计为通过。全仓 pre-commit、
git diff --check、启动脚本 bash 语法检查均通过;独立只读审查未发现 rebase 引入的阻断问题。上述 rebase 的 CI 状态为历史记录;当前检查以本次评审修复的 head 为准。本次未重新占用 GPU 或运行集群训练;下方既有 GPU 证据仍按原 SHA 记录,不能视为新提交的重新实测结果。
本次评审修复的 CPU 定向回归:65 passed,10 skipped,隐藏 GPU 执行,全仓
pre-commit run --all-files --show-diff-on-failure通过。新增 3 个回归在修复前均失败;其中双进程用例明确阻止旧路径对 PLE 先做整表 gather,修复后全部通过。megatron.bridge.models.qwen.qwen4_exp_bridge,真实映射相关 10 项因此跳过,未计为验证通过。本地 CPU 轮次未覆盖 GPU/NCCL;后续定向 GPU 验证见下。真实 Qwen4Exp 整模型和多 rank 异常恢复仍未验证;raw actor_fwd/ref 路径仍保留整表 gather 的原有内存限制。CUDA_VISIBLE_DEVICES='' python -m pytest -q -rs \ tests/cpu/distributed/checkpoint_service/test_dcs_ple_weight_sync.py \ tests/cpu/distributed/checkpoint_service/test_weights_getter.py \ tests/cpu/distributed/checkpoint_service/test_weight_sync_lifecycle.py \ tests/cpu/distributed/checkpoint_service/test_dcs_fused_weight_buckets.py \ tests/cpu/backends/megatron/test_hybrid_weight_sync_lifecycle.py \ tests/cpu/backends/megatron/weight_update/test_bridge_ple_shards.py \ tests/cpu/backends/megatron/weight_update/test_bridge_ple_async_gather.py \ tests/cpu/backends/megatron/weight_update/test_bridge_converter_collectives.py补充在提交
15beb12c上完成 2×H20、真实 TP2/NCCL 的 PLE 定向验证(PyTorch 2.11.0+cu129、CUDA 12.9、NCCL 2.28.9):PLENGramEmbeddingMapping、BridgeConverter.iter_ple_shards、生产 DCS 分发方法及 NCCL collective。两个 rank 各完成 40 组组合/更新检查:FP32/BF16、直接 task 与 registry fallback、五种消费者/基础权重跳过标志、同一 mapping/converter/backend 连续两次不同权重。小表拆成三个分片,中间分片横跨 TP 行归属边界;逐元素精确一致,HF-only 无整表 gather,raw 消费者协议保留,仅源 rank 发布,正常结束及一致提前关闭后映射 group 恢复。以下为本次 PLE 修复之前的迁移验证,不能代替当前修复的真实 Qwen4Exp/GPU 验收。
在基线
551c4ff4dd598def1842e26147e125ece764e15c上完成迁移,并在隐藏 GPU 的环境运行相关回归:242 passed,3 subtests passed,11 skipped。跳过项需要真实 CUDA,用于快照分配、pinned memory、设备同步和 H2D 搬运;未将这些 skip 计为验证通过。覆盖 Hybrid 参数、初始化/连续训练/offload/checkpoint 后同步、拓扑与接收端错误传播、完整评估组、恢复引擎注册、权重行为比较工具,并复用 resident-SFT、DCS 分桶、初始权重同步及自动权重同步回归。新增测试用于防止权重来源、TP 属性和同步生命周期退化;不启动 Ray 集群或分布式 GPU 进程。
CUDA_VISIBLE_DEVICES='' python -m pytest -q \ tests/cpu/utils/test_arguments_hybrid.py \ tests/cpu/distributed/checkpoint_service/test_weight_sync_lifecycle.py \ tests/cpu/distributed/checkpoint_service/test_weights_getter.py \ tests/cpu/backends/megatron/test_hybrid_weight_sync_lifecycle.py \ tests/cpu/engine/rollout/test_weight_sync_499.py \ tests/cpu/tools/test_elastic_weight_fingerprint.py \ tests/cpu/utils/test_metric_utils_rloo.py \ tests/cpu/distributed/ray/test_recovered_engine_registration.py \ tests/cpu/backends/megatron/test_resident_sft_param_sync.py \ tests/cpu/distributed/checkpoint_service/test_dcs_fused_weight_buckets.py \ tests/cpu/core/test_initial_weight_sync.py \ tests/cpu/backends/megatron/weight_update/test_auto_weight_sync.py \ tests/distributed/checkpoint_service/test_weights_getter.py \ tests/utils/training/test_tensor_backper.py pre-commit run --all-files bash -n examples/elastic_rollout/run-qwen3-4B-8xgpu-elastic-hybrid.shCI 发现既有 score-centering 手写配置 fixture 缺少 parser 默认提供的
enable_weights_backuper字段;已补齐该默认值,保持运行时校验不变。相关 score-centering、Hybrid 和 RLOO 参数回归共 65 passed,全仓 pre-commit 再次通过。另外通过重复定义检查、Ruff F811、
git diff --check和新增内容的内部链接/私有路径检查;独立只读审查未发现阻断问题。rebase 前提交
15beb12c的六项 required CI 均通过:CPU Unit Tests、4×H20 Unit Tests、pre-commit、Qwen3-4B Async GPU/NPU,以及 Qwen3-VL GPU 集成。此前手写 fixture 的失败已修复并重新通过。另在单节点 8×H20、真实 Qwen3-4B、Actor TP2×DP2 上执行定向回归:
max(reference_logprob - policy_logprob)=26.5826,未出现 float32 exp 溢出输入。诊断 hook 只读取 detached 数值并原样调用生产损失,包含额外设备同步,因此此轮不作性能结论。compute_approx_kl(low_var_kl)存在先 exp 再 clamp 的可达反向 NaN 反例,但缺少原失败 batch 的极值证据,不能将该失败精确归因于此,也不能声称已修复。CPU/GPU 两轮学习率不同,不构成相同训练轨迹的 A/B 对比。简单算术样本曾出现等额 GRPO 奖励、零梯度,因此验证配方启用标准熵正则,以实际 optimizer 更新、live sampled hash 和发布后数值变化为验收条件。两种模式的四次短 eval 均限制输出 64 token,观测 reward=-1、truncated_ratio=1;这里只验收完整分组、覆盖率及生命周期,不能视为业务效果回测通过。本轮是权重同步/生命周期验证,不证明原零 entropy 配方的学习效果或收敛。旧路径基准仅采集 optimizer 前的初始状态,关闭旧源 train offload;未比较完整训练轨迹。
未单独运行完整
pytest tests/命令;未验证多节点、PP/VP、MoE、FP8/量化、LoRA、故障注入或 checkpoint resume。checkpoint 审计只证明落盘与元数据/引用范围可读,不能称为恢复训练通过。未构建 VitePress 文档站点,本地未安装文档构建依赖。最终独立审计共 93 项通过。合入仍需维护者审查。高学习率 GPU 轮次的未归因 NaN 保留为独立训练数值问题,不在本 PR 的 Hybrid + DCS 修复范围内。pre-commit run --all-filespassespytest tests/)Type of Change
Screenshots / Logs