Skip to content

fix(klx): fix deepeyes_v2_agentic_klx oom and tms mismatch - #421

Merged
NINGBENZHE merged 2 commits into
redai-studio:mainfrom
grootZ:mr_master
Oct 9, 2026
Merged

NINGBENZHE merged 2 commits into
redai-studio:mainfrom
grootZ:mr_master

Conversation

@grootZ

@grootZ grootZ commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What

  1. deepeyes_v2_agentic rollout tp2->tp4 and select-offload add extra tensors offload to avoid oom
  2. fix grad_norm nan when using tms instead of select-offload

Why

How

Testing

  • 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

@rai-studio-bot

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @grootZ! 感谢你为 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

@rai-studio-bot

rai-studio-bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

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

审查版本: ed278ea

目标分支: main

常规审查已完成:三个文件(共 9 行)均已检查调用方、消费模式与运行时校验路径,未发现可确认的代码缺陷。train_offload 新增 5 个 MoE dispatcher 缓存属性沿用现有 clear-if-present 模式(属性缺失时安全跳过);runtime-env-klx.sh 新增两个 CUDA_FAKE_UVA_H2D_FIXUP_* 环境变量符合该入口脚本的既有职责;示例脚本 tp2->tp4 与训练侧 --tensor-model-parallel-size 4 对齐,且 rollout_validation.py 会在运行时校验对齐。遗留两点限制:5 个属性名与 2 个环境变量名均为仓库外契约(Megatron-LM 检出与 KLX 运行时),无法在仓库内验证,拼写错误将静默失效而非报错;本 PR 的 Testing 清单未勾选,KLX 硬件行为无法由 CI 验证。已向作者提出验证证据问题(COMMENT,非阻塞)。

审查阶段进度范围与结果
常规审查 ✅ 已完成 已核对 pinned merge-base 815de3a 的完整 diff(3 文件 +8/-1,与 inventory 一致);追踪 _MOE_DISPATCHER_CACHE_ATTRS 的唯一消费者 _clear_moe_dispatcher_caches(clear-if-present,缺失属性安全跳过);确认 --rollout-num-gpus-per-engine 为真实参数、colocate 模式下 rollout_num_gpus 由 actor GPU 数派生(relax/utils/arguments.py:4270);确认仓库内 Megatron patch 与全部 .py/.patch 均不含这 5 个属性名,两个环境变量在仓库内亦无消费者。
深度审查 ➖ 无需执行 无适用深度范围:变更仅 9 行,常规审查已覆盖全部接受文件的机制、调用方与校验路径;剩余不确定性均为仓库外契约(Megatron-LM dispatcher 内部属性、KLX 运行时环境变量语义),独立深度子任务无法在仓库内解决,且需要 KLX 多机 GPU 硬件做运行时验证(仓库规则要求显式说明跳过原因)。

本次没有需要列入看板的问题。

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

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

文件结论仓库维护必要性依据替代去向或方案
relax/backends/megatron/weight_update/train_offload.py
接收 PR 声明的 OOM 修复核心:扩展现有 _MOE_DISPATCHER_CACHE_ATTRS clear-if-present 机制,新增 5 个 MoE dispatcher 缓存属性名。 PR 描述 'select-offload add extra tensors offload to avoid oom';同文件 _clear_moe_dispatcher_caches 为既有消费者。 保留:替代方案需改动仓库外 Megatron-LM 检出;扩展现有元组是已就位的最小机制。
scripts/entrypoint/runtime-env-klx.sh
接收 KLX 运行时环境入口脚本已向 RUNTIME_ENV_JSON 导出 CUDA/NCCL 变量;新增两个 CUDA_FAKE_UVA_H2D_FIXUP_* 变量属既有职责。 PR 描述 'fix grad_norm nan when using tms instead of select-offload';脚本已导出 CUDA_DEVICE_MAX_CONNECTIONS 等。 保留:要求用户手动按集群设置会分散配置;该入口脚本是 KLX 运行时环境变量的既有来源。
examples/deepeyes_v2_agentic/run_deepeyes_v2_agentic_klx.sh
接收 deepeyes_v2 agentic KLX 工作流的用户示例;tp2->tp4 是描述中 OOM 修复的必要部分,并与训练侧 --tensor-model-parallel-size 4 对齐。 PR 描述 'deepeyes_v2_agentic rollout tp2->tp4';该示例是此工作流的文档化运行入口。 保留:无更简单替代;文档化示例中的配置值变更是工作流不 OOM 运行所需。
精简审查与验证依据
审查范围进度结论
生产代码 ✅ 已完成 三处变更均复用既有机制(缓存清理元组、RUNTIME_ENV_JSON 导出、示例参数),未发现重复状态、并行回退路径或可移除的包装层;均建议保留。
测试 ➖ 无需执行 本 PR 未改动任何测试,仓库内也无覆盖 _MOE_DISPATCHER_CACHE_ATTRS 的现有测试;因真实 dispatcher 属性无法在仓库内实例化验证,仅断言元组内容的测试与实现同义重复,无法检出拼写错误的属性名,故无适用的测试范围。

生产代码的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
relax/backends/megatron/weight_update/train_offload.py 的 _MOE_DISPATCHER_CACHE_ATTRS 扩展 _clear_moe_dispatcher_caches 遍历元组,对每个 dispatcher 句柄及其 _comm_manager 执行 clear-if-present;调用方为同文件 offload()。 改由 dispatcher 提供统一的缓存清理 API,或在 Megatron-LM 检出中修改。 保留 扩展现有元组是最小变更;clear-if-present 模式使缺失属性静默跳过,不引入新分支或新状态。替代方案需要改动仓库外 Megatron-LM。
scripts/entrypoint/runtime-env-klx.sh 的两个 CUDA_FAKE_UVA_H2D_FIXUP_* 导出 写入 RUNTIME_ENV_JSON 的 env_vars,随运行时环境注入;与既有 CUDA_DEVICE_MAX_CONNECTIONS 等导出并列。 要求用户在集群配置中手动设置环境变量。 保留 该入口脚本已是 KLX 运行时环境变量的既有单一来源;手动设置会分散配置且无仓库内先例可复用。
examples/deepeyes_v2_agentic/run_deepeyes_v2_agentic_klx.sh 的 tp2->tp4 示例脚本向训练入口传递 --rollout-num-gpus-per-engine;rollout_validation.py 运行时校验 --rollout-num-gpus、per-engine 与 server_groups 对齐。 保持 tp2 并依赖卸载机制缓解 OOM。 保留 作者报告 tp2 触发 OOM;tp4 与训练侧 --tensor-model-parallel-size 4 对齐(同文件 MEGATRON_ARGS),是描述中修复的必要部分,无更简单的替代。
Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

审查结论:常规审查完成,无阻塞问题

本 PR 修改 3 个文件共 9 行,已按 pinned merge-base 815de3aa 完整核对。三处变更均沿用仓库既有机制:_MOE_DISPATCHER_CACHE_ATTRS 的新增属性沿用 clear-if-present 模式(属性缺失时安全跳过);runtime-env-klx.sh 的两个环境变量导出符合该入口脚本的既有职责;示例脚本 tp2→tp4 与训练侧 --tensor-model-parallel-size 4 对齐,且 rollout_validation.py 会在启动时校验 GPU 对齐。未发现可确认的代码缺陷,详细依据与限制见审查看板。

一个非阻塞的确认请求:本 PR 的 Testing 清单尚未勾选,且新增的 5 个 dispatcher 属性名与 2 个 CUDA_FAKE_UVA_H2D_FIXUP_* 环境变量均为仓库外契约(Megatron-LM 检出与 KLX 运行时),仓库内无法验证——若名称与实际不符,会静默失效而非报错。方便时请在描述中补充一次 KLX 硬件上的验证记录(OOM 与 grad_norm 是否恢复),便于后续维护者确认契约。

Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.

@NINGBENZHE NINGBENZHE left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@NINGBENZHE
NINGBENZHE merged commit 64cd546 into redai-studio:main Oct 9, 2026
12 checks passed
Mukayi added a commit to Mukayi/Relax that referenced this pull request Oct 12, 2026
…er-profiler

Brings in upstream/main 653c43c..dce533b (redai-studio#257, redai-studio#258, redai-studio#285, redai-studio#323, redai-studio#330,
redai-studio#335, redai-studio#408, redai-studio#409, redai-studio#412, redai-studio#414, redai-studio#416, redai-studio#417, redai-studio#419-redai-studio#421, redai-studio#424, redai-studio#426, redai-studio#427,
redai-studio#430, and 42 commits synced on 10-12 without PR numbers).

The only conflict is relax/utils/env.py: cc4b052 adds the DeepSeek-V4
MXFP4 QAT variables at the same spot where this branch adds the straggler
profiler variables. Resolved by keeping both blocks, straggler first.
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