Skip to content

build(sglang): upgrade CUDA 13 runtime to 0.5.21 - #459

Closed
yuanlehome wants to merge 2 commits into
redai-studio:mainfrom
yuanlehome:upgrade/sglang-0.5.21
Closed

yuanlehome wants to merge 2 commits into
redai-studio:mainfrom
yuanlehome:upgrade/sglang-0.5.21

Conversation

@yuanlehome

@yuanlehome yuanlehome commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Upgrade the CUDA 13 training runtime from SGLang 0.5.17 to 0.5.21, with versioned ports of Relax's existing SGLang patches and the required build/runtime compatibility updates.

Recipe SGLang baseline Patch selection
docker/Dockerfile.cu13 0.5.21 Versioned 0.5.21 main and per-position top-K patches
docker/Dockerfile 0.5.17, frozen Explicitly pinned 0.5.17 patch pair

Why

SGLang 0.5.21 changes server-argument records, MoE weight-loading paths, routing capture, and logprob/multimodal internals. Relax's existing rollout and training integration needs a version-specific patch port and compatibility updates for the target PyTorch/CUDA stack.

How

  • Port the existing Relax 0.5.17 main and per-position top-K patches onto 0.5.21. Keep canonical patches under docker/patch/sglang/, point both latest aliases to 0.5.21, and retain the 0.5.17 per-position patch for the frozen CUDA 12 image.
  • Adapt ServerArgs field inspection, routing-replay guards, and reloadable process-group forwarding to the updated SGLang and PyTorch APIs.
  • Port MoE/Kimi weight-reload handling while preserving parameter storage used by CUDA graphs, update-session state, and failure handling.
  • Preserve original multimodal token IDs through native load_mm_data(); migrate per-position OPD query validation, chunk handling, and Base64 logprob transport.
  • Preserve Relax's decode timeout through the native PD failure/cleanup path shared across ranks, along with paused HiCache polling and deferred checkpoint backup.
  • Update TileLang to 0.1.12 and adapt SM103 build/import helpers. Add Transformer Engine's FA4 head-dimension fallback and Kimi packed-sequence API compatibility.
  • Refresh OPD documentation for 0.5.21 and switch MOPD logprob-chunk settings to the canonical SGLang environment variables.

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

N/A

Port Relax's SGLang patches to the 0.5.21 APIs and select versioned patches
in the CUDA 13 image. Update Blackwell dependencies and compatibility for
Kimi, multimodal OPD, routing replay, weight reload, disaggregated serving,
and reloadable process groups.

Keep versioned SGLang patches together and point both latest aliases at
0.5.21. Freeze the CUDA 12 image and its matching patches at 0.5.17, and
retain the legacy per-position patch. Update OPD documentation for 0.5.21.

Add regression coverage for the migrated SGLang patches and runtime
compatibility changes.

Validation: pre-commit run --all-files --show-diff-on-failure passed.
End-to-end accuracy and performance validation remains in progress.
@yuanlehome
yuanlehome requested review from a team and a balanced review from Copilot October 21, 2026 07:16
@rai-studio-bot

rai-studio-bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @yuanlehome! 感谢你为 Relax 做出贡献!

📚 Contribution guide / 贡献指南

Describe the problem, your changes, and how you validated them. Keep each PR focused and run pre-commit run --all-files before submitting.

请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行 pre-commit run --all-files。

English contribution guide · 中文贡献指南

🛠️ CI commands / CI 指令
Command / 指令 Usage / 用途
/rerun Retry failed CI / 重跑失败的 CI
/rerun <target> Rerun a workflow or check / 重跑指定 workflow 或检查
/cancel <workflow> Cancel an entire workflow / 取消整个 workflow
/help Show commands and targets / 查看指令和 target
/review Request a code review / 请求代码 review

Put one command on the first line of a new PR comment. Rerun/cancel require PR authorship or repository write access.

在新 PR 评论的首行写一条指令。PR 作者或有仓库写权限的贡献者可以重跑、取消 CI。

CI usage and targets · CI 用法与 target

🔎 Merge requirements / 合入条件

GitHub:❌ 存在冲突

Requirement / 条件 Status / 状态
审批人数 ⏳ 0/1 · 至少 1 位有仓库 write 或更高权限的人 Approve
团队审批(relax-block-reviewers) ⏳ 0/1 · 可联系:Aurelius84, Yangruipis, SigureMo, NINGBENZHE
CI ⏳ 等待通过

@rai-studio-bot

rai-studio-bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: 🚧 需要修改

审查版本: 5d27116

目标分支: main

已完成 5d27116 的增量审查及独立反证。新增 F6:默认 cuda_ipc 阻断单个引擎跨节点启动,冻结的 0.5.17 与升级后的 0.5.21 均受影响;新增 F5 为两层示例的转换命令错误。原 F1–F4 仍未解决,两个原 P1 线程已补充本轮证据。审查结论:https://github.com/redai-studio/Relax/pull/459#pullrequestreview-5614676335

Rust HiCache/native extension、GC 启动和 TE 筛选增量未发现其他明确缺陷;此结论限于源码及已记录的限定检查。没有可用的镜像构建工具或 GPU 环境,未执行完整 CUDA13 镜像构建、Blackwell/多节点 GPU 或端到端精度性能验证。文档中的 GPU 结果为作者报告;当前 CI 仅有三个维护流程成功项,不构成训练回归通过证据。

审查阶段进度范围与结果
常规审查 ✅ 已完成 复用 aae75cf 的已完成覆盖,复核本轮 10 个变更文件及受影响调用链;TE 2.18 补丁零 fuzz 应用检查与 shell 语法检查通过。保留原 F1–F4,发布 F5、F6;未重复运行未变代码的测试。
深度审查 ✅ 已完成 已核对 Rust 原生绑定、延迟备份锁与清理顺序、构建安装 ABI/加载路径;多模态默认值按 0.5.17/0.5.21 实际启动链路独立反证,确认跨节点启动回归 F6。新增测试仅验证参数转发,未覆盖真实跨节点参数解析;完整镜像及 GPU 行为仍未执行验证。

审查发现

待处理
编号 严重性 问题状态规则来源
F1 High severity GenRM 卸载模式需禁用不兼容的默认 prefill graph 🚧 未解决 —
F2 High severity MXFP4 重载仍读取已移除的 Triton precision scale 字段 🚧 未解决 —
F3 Medium severity 确定性 reduce-scatter 分支需保留 FP32 累加 🚧 未解决 —
F4 Medium severity 冻结版 0.5.17 的新增 Qwen 测试调用不存在的 API(已复核原线程) 🚧 未解决 —
F5 Medium severity 修正两层示例的模型转换命令 🚧 未解决 —
F6 High severity 保留跨节点推理引擎可用的传输默认值 🚧 未解决 —
已解决或已取代
编号 严重性 问题状态规则来源
暂无已解决或已取代的记录。
提交范围 · 接收 41 · 建议移出 0 · 待确认 0

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

文件结论仓库维护必要性依据替代去向或方案
docker/Dockerfile
docker/Dockerfile.cu13
docker/patch/latest/sglang.patch
docker/patch/latest/sglang_per_pos_topk.patch
docker/patch/megatron/kimi-packed-sequence-api.patch
docker/patch/sglang/v0.5.17_per_pos_topk.patch
docker/patch/sglang/v0.5.21.patch
docker/patch/sglang/v0.5.21_per_pos_topk.patch
docker/patch/transformer_engine/2.18.0-blackwell-fa4-head-dim.patch
docker/scripts/build_flashinfer_sampling.py
docker/scripts/check_gpu_imports.py
docker/scripts/ensure_sgl_kernel_sm103.py
docker/scripts/validate_blackwell.py
relax/backends/sglang/routing_replay_patch.py
relax/backends/sglang/sglang_engine.py
relax/utils/reloadable_process_group.py
docker/scripts/build_sglang_tree_core.py
relax/backends/sglang/arguments.py
接收 CUDA 13 SGLang 0.5.21 镜像、版本化补丁与运行时兼容属于现有实现层。 PR #459 描述:升级 CUDA 13 至 SGLang 0.5.21,冻结 CUDA 12 于 0.5.17,并迁移运行时补丁、示例及回归覆盖。 沿用现有目录和版本化补丁布局;无需另设维护位置。
tests/backends/megatron/test_blackwell_flash_attention.py
tests/backends/megatron/test_kimi_packed_sequence_compat.py
tests/backends/sglang/test_bf16_moe_weight_reload.py
tests/backends/sglang/test_disaggregation_timeout_consensus.py
tests/backends/sglang/test_dp_moe_reduce_scatter.py
tests/backends/sglang/test_fused_moe_routing_capture.py
tests/backends/sglang/test_kimi_k3_weight_reload.py
tests/backends/sglang/test_mxint4_weight_reload.py
tests/backends/sglang/test_opd_request_validation.py
tests/backends/sglang/test_reduce_scatterv_gpu.py
tests/backends/sglang/test_relax_patch_migration.py
tests/utils/test_reloadable_process_group.py
tests/backends/sglang/test_mm_feature_transport_defaults.py
接收 在对应后端和工具测试目录保留迁移后的回归覆盖。 PR #459 描述:升级 CUDA 13 至 SGLang 0.5.21,冻结 CUDA 12 于 0.5.17,并迁移运行时补丁、示例及回归覆盖。 沿用现有目录和版本化补丁布局;无需另设维护位置。
examples/diffusion/README.md
examples/on_policy_distillation/README.md
examples/on_policy_distillation/mopd/run-mopd-qwen3-vl-2b-8xgpu-colocate.sh
examples/on_policy_distillation/mopd/run-mopd-qwen35-35ba3b-16xgpu-colocate.sh
examples/on_policy_distillation/mopd/run-mopd-qwen35-9b-8xgpu-colocate.sh
scripts/models/kimi-k2.6.sh
scripts/training/text/run-kimi-k2.6-2layers-8xgpu-int4.sh
接收 示例命令和模型配置须适配升级后的依赖与行为。 PR #459 描述:升级 CUDA 13 至 SGLang 0.5.21,冻结 CUDA 12 于 0.5.17,并迁移运行时补丁、示例及回归覆盖。 沿用现有目录和版本化补丁布局;无需另设维护位置。
skills/opd-tuning/references/baselines.md
skills/opd-tuning/references/teacher-knobs.md
接收 维护现有 OPD 操作参考中的版本与参数说明。 PR #459 描述:升级 CUDA 13 至 SGLang 0.5.21,冻结 CUDA 12 于 0.5.17,并迁移运行时补丁、示例及回归覆盖。 沿用现有目录和版本化补丁布局;无需另设维护位置。
docs/draft/sglang-0.5.21-upgrade-plan.md
接收 记录版本迁移决定、保留行为及验证限制,供后续升级复用。 sglang-upgrade skill 第 8 节要求在 docs/draft/sglang-<ver>-upgrade-plan.md 记录迁移决策及验证清单。 沿用现有 skill 指定的迁移日志位置;具体实验结论按作者报告核对。
Powered by Nyanpasu with gpt-6-astra xhigh, please check the suggestions carefully.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Unresolved compatibility and synchronization issues remain, and end-to-end multi-GPU accuracy and performance validation is still pending.

2 open issues
What changed in this PR

Upgrades Relax’s CUDA 13 runtime to SGLang 0.5.21 while retaining the CUDA 12 baseline at 0.5.17.

Changes:

  • Selects versioned patches and updates Blackwell dependencies.
  • Adapts runtime APIs, weight reload, routing capture, and multimodal processing.
  • Adds regression coverage and updates OPD documentation.
File Description
tests/​utils/​test_reloadable_process_group.py Tests collectives across group reloads.
tests/​backends/​sglang/​test_relax_patch_migration.py Covers migrated patch behavior.
tests/​backends/​sglang/​test_reduce_scatterv_gpu.py Adapts distributed GPU tests.
tests/​backends/​sglang/​test_opd_request_validation.py Tests multimodal token preservation.
tests/​backends/​sglang/​test_mxint4_weight_reload.py Tests MXINT4 reload lifecycle.
tests/​backends/​sglang/​test_kimi_k3_weight_reload.py Updates Kimi test compatibility.
tests/​backends/​sglang/​test_fused_moe_routing_capture.py Tests fused routing capture.
tests/​backends/​sglang/​test_dp_moe_reduce_scatter.py Updates distributed test fixtures.
tests/​backends/​sglang/​test_disaggregation_timeout_consensus.py Tests distributed timeout handling.
tests/​backends/​sglang/​test_bf16_moe_weight_reload.py Tests BF16 reload and repacking.
tests/​backends/​megatron/​test_kimi_packed_sequence_compat.py Tests Kimi packing compatibility.
tests/​backends/​megatron/​test_blackwell_flash_attention.py Tests Blackwell attention and gradients.
skills/​opd-tuning/​references/​teacher-knobs.md Updates chunking variable names.
skills/​opd-tuning/​references/​baselines.md Updates tuning search commands.
scripts/​models/​kimi-k2.6.sh Allows layer-count overrides.
relax/​utils/​reloadable_process_group.py Forwards newer collective methods.
relax/​backends/​sglang/​sglang_engine.py Supports record-based server arguments.
relax/​backends/​sglang/​routing_replay_patch.py Preserves native asynchronous capture.
examples/​on_policy_distillation/​README.md Documents versioned OPD patches.
examples/​on_policy_distillation/​mopd/​run-mopd-qwen35-9b-8xgpu-colocate.sh Updates chunking environment variables.
examples/​on_policy_distillation/​mopd/​run-mopd-qwen35-35ba3b-16xgpu-colocate.sh Updates chunking environment variables.
examples/​on_policy_distillation/​mopd/​run-mopd-qwen3-vl-2b-8xgpu-colocate.sh Updates chunking environment variables.
examples/​diffusion/​README.md Documents the frozen diffusion baseline.
docker/​scripts/​validate_blackwell.py Checks expected SGLang version.
docker/​scripts/​ensure_sgl_kernel_sm103.py Recognizes compatible kernels and source layout.
docker/​scripts/​check_gpu_imports.py Validates SGLang imports and version.
docker/​scripts/​build_flashinfer_sampling.py Discovers the installed sampling cache.
docker/​patch/​transformer_engine/​2.18.0-blackwell-fa4-head-dim.patch Adds fallback for unaligned training heads.
docker/​patch/​sglang/​v0.5.21_per_pos_topk.patch Ports per-position logprob support.
docker/​patch/​sglang/​v0.5.17_per_pos_topk.patch Retains the legacy versioned patch.
docker/​patch/​megatron/​kimi-packed-sequence-api.patch Adapts Kimi packing and return handling.
docker/​Dockerfile.cu13 Upgrades runtime and applies compatibility patches.
docker/​Dockerfile Pins CUDA 12 to matching legacy patches.

Review effort: Balanced

async def test_qwen_uncached_image_prefill_preserves_sampled_ids(
monkeypatch, image_count, repeats, avoid_retokenize, use_legacy_fallback
):
from sglang.srt.multimodal.processors import base_processor, qwen_vl

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.

已在固定提交 aae75cf7 的 SGLang 0.5.17 环境复核:单个测试 test_qwen_uncached_image_prefill_preserves_sampled_ids[False-True-1-1] 在第 288 行报 AttributeError,缺失的正是 _process_mm_data_uncached。安装的 Qwen processor 文件与官方 0.5.17 源码一致。可按这里的建议仅限定新增测试的版本,或选择旧版 process_mm_data_async 入口;保留原有 0.5.17 测试覆盖。此检查使用模拟媒体处理,未运行 GPU 推理。

Comment on lines +15 to +19
+ preprocess_packed_seqs(
+ inputs_embeds,
+ saved_attention_mask,
+ pre_process=True,
+ )[0]

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

需要修改

已确认 CUDA 13 升级会导致启用显存卸载的 dense GenRM 启动失败,需补齐新版 prefill graph 的兼容处理。其余迁移范围仍在核查,检查进度和后续结论见审查面板。当前未执行多节点 GPU 验证。

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

# not recognized by the installed SGLang ServerArgs are dropped with a
# warning rather than causing a TypeError at ServerArgs(**kwargs).
server_arg_fields = {f.name for f in dataclasses.fields(ServerArgs)}
server_arg_fields = {f.name for f in _server_args_fields(ServerArgs)}

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.

High severity P1 · 为 GenRM 卸载配置禁用不兼容的 prefill graph

CUDA 13 升级后,普通 dense GenRM(如 Qwen3)在 --colocate / offload_rollout=True 下会启动失败:这里保留 enable_memory_saver=True,而 GenRMManager._build_engine_env_vars() 固定设置 SGLANG_MEMORY_SAVER_CUDA_GRAPH=true;0.5.21 默认使用 breakable prefill graph,其构造函数会直接抛出 NotImplementedError("Breakable CUDA graph is not compatible with memory saver mode")。_compute_server_args() 已有禁用默认 prefill graph 的兼容分支,_compute_genrm_server_args() 缺少相同处理。请在应用 GenRM 配置覆盖后补上该兼容处理,并覆盖 dense GenRM 的卸载配置。

依赖依据:默认 prefill backend、memory saver 拒绝分支。

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.

补充复核:dense、PP=1 且未显式关闭 prefill graph 的 GenRM 不会命中新版的 PP/KDA/多模态自动禁用分支,启动仍会进入上述拒绝检查。升级环境可暂时在 --genrm-engine-config 中设置 "cuda_graph_backend_prefill": "disabled" 规避;默认配置仍需与 rollout 的 memory-saver 兼容处理对齐。

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.

本轮新增的 GC 修补只控制 HTTP warmup 后的 freeze_gc 调用,无法修复这里发生在模型初始化阶段的 prefill graph 拒绝。当前 GenRM 参数构造仍未包含 rollout 已有的 memory-saver 兼容分支;请保留此问题为未解决,并将默认 dense GenRM 卸载配置纳入修复验证。

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

需要修改

已完成固定提交的源码审查和限定边界验证。升级引入的启动、权重重载阻断及精度回归仍需修复;另已在原线程补充确认冻结版运行时的测试兼容问题。完整结论与验证限制见审查面板。尚未执行 CUDA 13/Blackwell 镜像构建、多节点 GPU 或端到端精度/性能验证;GPU 单元测试 CI 的失败日志正在单独核对。

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

Comment on lines +1809 to +1810
+ precision.weight_scale.storage.data,
+ getattr(self, f"{prefix}_precision_config").weight_scale.storage.data,

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.

High severity P1 · 更新 MXFP4 重载中的 Triton scale 字段

使用 triton_kernel MoE backend 的 MXFP4 模型在首次权重重载时会抛出 AttributeError:0.5.21 的 _process_mxfp4_weights_after_loading() 已构造 PrecisionConfig(b_mx_scale=...),此处仍读取旧接口的 weight_scale。镜像所带 Triton 3.7.1 的 PrecisionConfig 没有该字段,因此初次加载能完成,下一次 restore/load/postprocess 无法恢复 rollout。请同步更新这两个字段访问,并让重载测试使用新版 precision config 契约。限定的 API 边界复现已得到该异常;未执行 GPU swizzle。

依赖依据:SGLang 构造新版 PrecisionConfig、Triton 3.7.1 字段定义。

Suggested change
+ precision.weight_scale.storage.data,
+ getattr(self, f"{prefix}_precision_config").weight_scale.storage.data,
+ precision.b_mx_scale.storage.data,
+ getattr(self, f"{prefix}_precision_config").b_mx_scale.storage.data,

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.

本轮新增的两层 Kimi INT4 示例声明走 compressed-tensors 重量化路径;它的运行结果不能覆盖这里 mxfp4.py 的 Triton PrecisionConfig 重载接口。当前补丁仍在两处读取 weight_scale,请按原建议更新为 b_mx_scale,并用目标 Triton 版本的对象验证第二次权重装载。

+ # the fixed-size DP combine. Write back into the original buffer.
+ reduce_input = input_
+ reduce_output = output
+ if input_.dtype == torch.bfloat16:

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 · 为确定性 reduce-scatter 分支保留 FP32 累加

开启 SGLANG_ENABLE_DETERMINISTIC_INFERENCE=true 后,新版 reduce_scatterv() 会在这些转换之前返回 _deterministic_reduce_scatterv(input_, output, sizes);该 helper 直接对 BF16 clone 调用 all_reduce()。旧版补丁始终把此处的 BF16 MoE 部分和转为 FP32,因此在使用 NCCL fallback 的拓扑上,升级会重新引入 BF16 中间舍入/抵消误差。请也在确定性分支执行 FP32 reduction,再一次性写回原 dtype/output。边界复现确认 all-reduce 收到 BF16;未在真实 NCCL 上测量误差幅度。

依赖依据:确定性 helper 与提前返回。

# not recognized by the installed SGLang ServerArgs are dropped with a
# warning rather than causing a TypeError at ServerArgs(**kwargs).
server_arg_fields = {f.name for f in dataclasses.fields(ServerArgs)}
server_arg_fields = {f.name for f in _server_args_fields(ServerArgs)}

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.

补充复核:dense、PP=1 且未显式关闭 prefill graph 的 GenRM 不会命中新版的 PP/KDA/多模态自动禁用分支,启动仍会进入上述拒绝检查。升级环境可暂时在 --genrm-engine-config 中设置 "cuda_graph_backend_prefill": "disabled" 规避;默认配置仍需与 rollout 的 memory-saver 兼容处理对齐。

async def test_qwen_uncached_image_prefill_preserves_sampled_ids(
monkeypatch, image_count, repeats, avoid_retokenize, use_legacy_fallback
):
from sglang.srt.multimodal.processors import base_processor, qwen_vl

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.

已在固定提交 aae75cf7 的 SGLang 0.5.17 环境复核:单个测试 test_qwen_uncached_image_prefill_preserves_sampled_ids[False-True-1-1] 在第 288 行报 AttributeError,缺失的正是 _process_mm_data_uncached。安装的 Qwen processor 文件与官方 0.5.17 源码一致。可按这里的建议仅限定新增测试的版本,或选择旧版 process_mm_data_async 入口;保留原有 0.5.17 测试覆盖。此检查使用模拟媒体处理,未运行 GPU 推理。

Build and install the patched Rust HiCache extension with ABI checks and
complete deferred backup/root handling and GC freeze startup ordering.
Preserve framework CUDA IPC defaults and support the SM103 CP/FA2 fallback.

Add the Kimi two-layer INT4 launcher, regression coverage, and validation
notes focused on train/rollout diff, output length, and raw reward.

## Validation

- Full pre-commit checks passed.
- Installed migration and GC regressions: 99 passed.
- CLI, default CUDA IPC, and HiCache regressions: 27 passed per stack.
- Paired short training results and validation limits documented.
#
# Prerequisite (one-time):
# Cast the original INT4 release to BF16 HF for the training side:
# python -m relax.tools.quant_cast.convert_moe_int4_to_bf16 \

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 · 修正两层示例的模型转换命令

按此处前置步骤准备 BF16 checkpoint 时,python -m relax.tools.quant_cast.convert_moe_int4_to_bf16 会报 ModuleNotFoundError: No module named 'relax.tools',因为仓库中的转换器位于 relax/utils/quant_cast/。这会使新增示例在训练启动前就无法完成模型准备;请与现有 256 卡 INT4 示例使用同一入口。

Suggested change
# python -m relax.tools.quant_cast.convert_moe_int4_to_bf16 \
# python -m relax.utils.quant_cast.convert_moe_int4_to_bf16 \

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

需要修改

已完成 5d271167 的增量审查:新增默认传输选择会阻断跨节点推理引擎启动,需要修复。完整发现、原有未解决问题与验证范围见审查看板。本轮未执行完整 CUDA 13 镜像构建或多节点 GPU 验证,当前 CI 成功项仅为维护流程。

Powered by Nyanpasu with gpt-6-astra xhigh, please check the suggestions carefully.


# Keep multi-process multimodal features on CUDA across SGLang versions.
# Explicit CLI values and per-engine config overrides retain priority.
parser.set_defaults(sglang_mm_feature_transport="cuda_ipc")

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.

High severity P1 · 保留跨节点推理引擎可用的传输默认值

这里将原先的自动选择改为显式 cuda_ipc,使未配置传输覆盖的跨节点引擎无法启动。例如现有 Qwen 128 卡脚本 设置每引擎 32 卡,按默认每节点 8 卡得到 nnodes=4;参数原样进入 SGLang,0.5.21 和冻结的 0.5.17 均抛出 ValueError: --mm-feature-transport=cuda_ipc only supports a single node.。0.5.21 在实际服务启动的 resolve_once() 阶段执行此校验,早于 tokenizer 初始化,纯文本模型也不会绕过。

请在确定每个引擎的最终拓扑后选择兼容的默认传输,同时保留显式配置的优先级。新增测试将 ServerArgs 替换为仅含传输字段的 dataclass,只验证参数转发;应补充 nnodes>1 的真实上游解析边界。此处针对单个引擎跨节点,不包括各引擎仍为单节点的集群部署。

# not recognized by the installed SGLang ServerArgs are dropped with a
# warning rather than causing a TypeError at ServerArgs(**kwargs).
server_arg_fields = {f.name for f in dataclasses.fields(ServerArgs)}
server_arg_fields = {f.name for f in _server_args_fields(ServerArgs)}

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.

本轮新增的 GC 修补只控制 HTTP warmup 后的 freeze_gc 调用,无法修复这里发生在模型初始化阶段的 prefill graph 拒绝。当前 GenRM 参数构造仍未包含 rollout 已有的 memory-saver 兼容分支;请保留此问题为未解决,并将默认 dense GenRM 卸载配置纳入修复验证。

Comment on lines +1809 to +1810
+ precision.weight_scale.storage.data,
+ getattr(self, f"{prefix}_precision_config").weight_scale.storage.data,

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.

本轮新增的两层 Kimi INT4 示例声明走 compressed-tensors 重量化路径;它的运行结果不能覆盖这里 mxfp4.py 的 Triton PrecisionConfig 重载接口。当前补丁仍在两处读取 weight_scale,请按原建议更新为 b_mx_scale,并用目标 Triton 版本的对象验证第二次权重装载。

@yuanlehome yuanlehome closed this Oct 27, 2026
yuanlehome added a commit that referenced this pull request Oct 28, 2026
## What

- CUDA 13 配方升级到官方 **SGLang 0.5.21**,迁移完整 Relax patch;CUDA 12 保持 0.5.17。
- 补齐 **PD + R3**:prefill 路由采集、decode 合并、CPU HiCache/retraction、多轮
Session 和 router 兼容性。

## Why

基于上游 0.5.20 重新迁移,保留 OPD、Qwen/Kimi、权重热更新能力,并参考 Miles 补齐 PD+R3。替代 #459。

## How

- 固定源码版本、重建 Rust tree core,适配权重更新与 Blackwell 注意力;P 端真实路由覆盖 D 端占位前缀,保留已接受
token 的路由。
- **审查修复**:按各引擎最终拓扑选择 multimodal transport,仅单节点默认 CUDA
IPC,保留显式配置;deterministic BF16 reduce-scatter 使用 FP32 累加,保留输出
dtype/buffer。
- **单测整理**:删除冗余参数组合,按权重更新、路由、引擎参数及 patch 兼容性归并,净减少 **5 个文件**;合并未丢失保留用例。

## Testing

- [x] `pre-commit run --all-files` passes
- [ ] Tests pass (`pytest tests/`) — 未跑全仓库,专项结果见下。
- [x] New tests added (if applicable)
- [x] Documentation updated (if applicable)

最新验证对应 `6cd6c9c`:**SGLang 0.5.21 / PyTorch 2.13.0+cu130 / CUDA 13.0 /
Blackwell SM103(compute capability 10.3)**。

- 合并后 CPU 回归 **343 passed / 7 skipped**;这 7 项已在 GPU
上全部通过,相关代码未变,沿用结果;合计覆盖 **350 项,无剩余跳过**。
- GPU 覆盖 NCCL/CUDA Graph、BF16 reduction、Qwen 权重重载、进程组重载,以及 FA2/FA4 前反向和
CP 后端选择。
- 完整 patch 干净应用到官方 0.5.21,89 个受影响 Python 文件编译通过。

## Type of Change

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

## Screenshots / Logs

升级阶段单机 8 GPU、各 **5 轮**端到端结果;本次审查修复后未重跑:

| 场景 | 样本数 | 平均训推 diff | 平均 assistant 输出 tokens | raw_reward |
| --- | ---: | ---: | ---: | ---: |
| Qwen3.5 regular + R3 | 1280 | 0.0086975 | 1564.1305 | 0.315625 |
| Qwen3.5 PD + R3 | 1280 | 0.0087124 | 1562.5563 | 0.3140625 |
| Mini-SWE PD + R3 + CPU HiCache | 80 | 0.0090159 | 7910.7 | 0.3375 |

Qwen 对照使用 router 后续修正前的成功请求路径;Mini-SWE 最后一轮验证最新 router。验收看上述指标,不要求
logprob 严格一致。使用隔离运行时,未重建完整 Docker 镜像,未覆盖多节点及其他 GPU 架构。
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