Skip to content

【No.3】feat(inference): Unified Inference Service - #368

Closed
oliver-0424 wants to merge 72 commits into
redai-studio:mainfrom
oliver-0424:unified_inference_service
Closed

oliver-0424 wants to merge 72 commits into
redai-studio:mainfrom
oliver-0424:unified_inference_service

Conversation

@oliver-0424

@oliver-0424 oliver-0424 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What

Rollout、GenRM 和 OPD Teacher 共用一套推理服务。共享 GPU 时,只有确认上一个角色已经释放显存,才会切换到下一个角色。

Why

Related to #321(Task No.3),设计依据是 RFC #71。原来各角色各自管理引擎,切换 GPU 时没有统一的准入,也不确认显存已经释放。

How

  • 每个角色的 InferenceManager 负责准入和引擎生命周期;LifecycleAuthority 决定哪个角色可以使用重叠的 GPU。
  • 释放显存之前,先关闭准入、排空请求,并由引擎确认空闲。确认不了时只隔离出问题的副本。
  • Breaking:删除 GenRMEngine,改用 SGLangEngine(..., profile="genrm")。

Testing

  • pre-commit run --all-files passes
  • Tests pass (pytest tests/):有 243 个环境失败,与 main 相同。
  • New tests added (if applicable)
  • Documentation updated (if applicable)

在 CPU 上对比 main 跑全量测试:本分支没有新增失败。GPU 和多节点没有运行。

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

无。

@oliver-0424

oliver-0424 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@Yangruipis @SigureMo I'm working on No.3 (#368). Before implementing the PlacementPlanner I'd like to confirm one conflict between the RFC and an existing feature: does "reject shared co-resident in the first version" include the GenRM Shared / Co-resident mode that is supported today?

Current behavior

  • The docs list Shared / Co-resident as an official GenRM colocate sub-mode. It is enabled automatically when rollout_num_gpus == genrm_num_gpus == actor_total, and Rollout and GenRM stay resident on the same bundles at the same time, split by mem_fraction_static (docs L29, L268-L275).
  • The mode is selected in arguments.py L4360-L4366 and flagged by _genrm_colocate_with_rollout.

What the RFC says

  • Decision table: Shared co-resident | Reject in the first version.
  • Acceptance checks: Shared co-resident layouts fail before startup.
  • The Compatibility section also says existing CLI flags are only converted to the internal spec, and the task acceptance criteria require the old interfaces to stay compatible.

Read literally, the planner would reject a released, documented configuration before startup. 🤔

Which would you prefer?

  1. Reject it. Existing co-resident configs fail before startup, and the docs mark the mode as no longer supported.
  2. Keep it as a compatibility exception. Allow only the existing Rollout + GenRM pair, and reject every other same-bundle, same-phase combination (for example Teacher with Rollout).

I lean toward 2: it doesn't break existing users, and the exception can be a single explicit rule in the planner with its own tests. I'll implement whichever you decide.

@oliver-0424
oliver-0424 force-pushed the unified_inference_service branch from 141f803 to 56f2dcf Compare October 8, 2026 12:43
@oliver-0424

Copy link
Copy Markdown
Contributor Author

@rai-studio-bot review

@SigureMo

SigureMo commented Oct 8, 2026

Copy link
Copy Markdown
Member

@rai-studio-bot 不会 review draft PR,如果 PR 已经 ready,可以转为非 draft PR

@oliver-0424
oliver-0424 marked this pull request as ready for review October 9, 2026 00:59
@rai-studio-bot

rai-studio-bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: 🔎 审查中

审查版本: 269dfaf

目标分支: main

已按固定 head 开始审查;常规代码、测试与拆分问题正在核对。

审查阶段进度范围与结果
常规审查 🔎 进行中 已完成仓库范围准入;正在检查统一推理服务的调用链、生命周期、路由和资源所有权。
深度审查 ⏳ 待开始 待拆分分析和针对性深审完成后更新。

CI 异常

检查版本: 6d082f1 · 🔎 分析中

失败检查原因与现状证据建议下一步
CPU Unit Tests 当前 head 的 CPU Unit Tests 检查失败,原因待从日志确认。 待确认 待分析
Qwen3-VL-4B-2xgpu 当前 head 的 Qwen3-VL-4B-2xgpu 检查失败,原因待从日志确认。 待确认 待分析
Qwen3-4B-4xnpu-async 当前 head 的 Qwen3-4B-4xnpu-async 检查失败,原因待从日志确认。 待确认 待分析
Qwen3-4B-4xgpu-async 当前 head 的 Qwen3-4B-4xgpu-async 检查失败,原因待从日志确认. 待确认 待分析

尚无已确认的问题记录;这不代表审查通过。

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

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

文件结论仓库维护必要性依据替代去向或方案
docs/draft/multimodal-gen-rl-design.md
docs/en/examples/generative-reward-model.md
docs/en/examples/on-policy-distillation.md
docs/en/guide/architecture.md
docs/en/guide/customize-training.md
docs/zh/examples/generative-reward-model.md
docs/zh/examples/on-policy-distillation.md
docs/zh/guide/architecture.md
docs/zh/guide/customize-training.md
接收 Documentation updates describe the unified inference behavior and preserve bilingual user-facing guidance. The PR documentation changes are under the repository docs tree and correspond to shipped inference APIs. Keep these pages in docs with the existing bilingual structure.
examples/generate_reward_model/post_process_genrm_swap.py
接收 The example post-processing change updates an existing GenRM example to the new inference API. The file is a maintained user example directly exercising the changed GenRM integration. Retain the change in the existing example directory.
relax/agentic/pipeline/runtime.py
relax/backends/fsdp/actor.py
relax/backends/megatron/actor.py
relax/backends/sglang/diffusion_engine.py
relax/backends/sglang/process_cleanup.py
relax/backends/sglang/sglang_engine.py
relax/components/genrm.py
relax/components/inference_gateway.py
relax/components/rollout.py
relax/core/controller.py
relax/core/service.py
relax/distributed/coordination.py
relax/distributed/ray/actor_group.py
relax/distributed/ray/engine_pool.py
relax/distributed/ray/genrm.py
relax/distributed/ray/inference_manager.py
relax/distributed/ray/multi_engine_manager.py
relax/distributed/ray/multi_instance_orchestrator.py
relax/distributed/ray/placement_group.py
relax/distributed/ray/placement_physical.py
relax/distributed/ray/placement_planner.py
relax/distributed/ray/rollout.py
relax/distributed/ray/teacher_manager.py
relax/distributed/ray/train_actor.py
relax/distributed/ray/training_phase.py
relax/engine/inference/__init__.py
relax/engine/inference/admission.py
relax/engine/inference/client.py
relax/engine/inference/deferred.py
relax/engine/inference/discovery.py
relax/engine/inference/gateway.py
relax/engine/inference/holder.py
relax/engine/inference/lifecycle.py
relax/engine/inference/messages.py
relax/engine/inference/ownership.py
relax/engine/inference/phase_client.py
relax/engine/inference/routing.py
relax/engine/rewards/__init__.py
relax/engine/rollout/on_policy_distillation.py
relax/engine/rollout/sglang_rollout.py
relax/engine/rollout/workload.py
relax/engine/sft/predict/runner.py
relax/utils/env.py
relax/utils/genrm_client.py
relax/utils/health_monitor.py
relax/utils/http_utils.py
relax/utils/opd/opd_utils.py
relax/utils/utils.py
接收 These are the production implementation changes for the unified inference lifecycle, routing, placement, engines, and callers. The PR requirement is implemented in the Relax runtime and its backend/component callers. Keep runtime changes in their existing relax subpackages, with cross-cutting inference code under relax/engine/inference.
tests/backends/sglang/test_cpu_hicache_args.py
tests/backends/sglang/test_deterministic_process_group.py
tests/backends/sglang/test_engine_profile.py
tests/backends/sglang/test_genrm_engine_characterization.py
tests/backends/sglang/test_genrm_offload_drain.py
tests/backends/sglang/test_process_cleanup.py
tests/backends/sglang/test_process_group_recovery.py
tests/backends/sglang/test_router_registration.py
tests/backends/sglang/test_server_incarnation.py
tests/backends/sglang/test_server_process_group.py
tests/backends/sglang/test_sglang_engine.py
tests/components/test_genrm_engine_pick.py
tests/components/test_genrm_gateway_endpoints.py
tests/components/test_inference_gateway_service.py
tests/components/test_rollout_chat_proxy_characterization.py
tests/components/test_rollout_gateway_endpoints.py
tests/core/test_control_plane_affinity.py
tests/core/test_controller_placement_preflight.py
tests/core/test_controller_sft_colocate.py
tests/core/test_controller_teacher_gateway.py
tests/core/test_pd_disposal.py
tests/core/test_service_affinity.py
tests/distributed/ray/conftest.py
tests/distributed/ray/fixtures/main_genrm_swap.py.txt
tests/distributed/ray/test_engine_group_characterization.py
tests/distributed/ray/test_engine_metadata.py
tests/distributed/ray/test_engine_metadata_local_ray.py
tests/distributed/ray/test_engine_pool.py
tests/distributed/ray/test_engine_pool_ray_integration.py
tests/distributed/ray/test_genrm_placement.py
tests/distributed/ray/test_genrm_recovery.py
tests/distributed/ray/test_inference_ownership_local_ray.py
tests/distributed/ray/test_maintenance_cancellation.py
tests/distributed/ray/test_multi_engine_manager.py
tests/distributed/ray/test_opd_multi_teacher_orchestration.py
tests/distributed/ray/test_opd_teacher_controller_colocate.py
tests/distributed/ray/test_pd_router_startup.py
tests/distributed/ray/test_placement_physical.py
tests/distributed/ray/test_placement_planner.py
tests/distributed/ray/test_placement_recovery_timeout.py
tests/distributed/ray/test_process_group_receipts.py
tests/distributed/ray/test_release_receipts.py
tests/distributed/ray/test_rollout_snapshot.py
tests/distributed/ray/test_rollout_snapshot_ray_integration.py
tests/distributed/ray/test_runtime_loop.py
tests/distributed/ray/test_scale_in.py
tests/distributed/ray/test_shutdown_liveness.py
tests/distributed/ray/test_shutdown_timeout_exit.py
tests/distributed/ray/test_teacher_automatic_recovery.py
tests/distributed/ray/test_teacher_manager.py
tests/distributed/ray/test_teacher_manager_factory.py
tests/distributed/ray/test_training_phase.py
tests/distributed/ray/test_utils.py
tests/engine/inference/__init__.py
tests/engine/inference/helpers.py
tests/engine/inference/test_admission.py
tests/engine/inference/test_client.py
tests/engine/inference/test_control_http_errors.py
tests/engine/inference/test_coresidency.py
tests/engine/inference/test_deferred_cancellation.py
tests/engine/inference/test_deferred_reward_tasks.py
tests/engine/inference/test_deferred_scoring.py
tests/engine/inference/test_discovery.py
tests/engine/inference/test_gateway.py
tests/engine/inference/test_gateway_cancellation.py
tests/engine/inference/test_gateway_close_fence.py
tests/engine/inference/test_lifecycle.py
tests/engine/inference/test_maintenance_failures.py
tests/engine/inference/test_ownership.py
tests/engine/inference/test_request_body_cancellation.py
tests/engine/inference/test_request_cleanup.py
tests/engine/inference/test_request_control.py
tests/engine/inference/test_request_dispatch.py
tests/engine/inference/test_routing.py
tests/engine/rollout/test_kimi_k3_payload.py
tests/engine/rollout/test_on_policy_distillation_routing.py
tests/engine/rollout/test_opd_native_multimodal.py
tests/engine/rollout/test_opd_prefill_stages.py
tests/engine/rollout/test_opd_student_failures.py
tests/engine/rollout/test_opd_teacher_discovery.py
tests/engine/rollout/test_opd_teacher_retry.py
tests/engine/rollout/test_request_permit.py
tests/engine/rollout/test_sglang_rollout_deferred_reward.py
tests/engine/rollout/test_workload_ownership.py
tests/entrypoints/test_startup_failure.py
tests/test_agentic_rollout.py
tests/utils/opd/__init__.py
tests/utils/opd/test_opd_teacher_defer_args.py
tests/utils/test_genrm_lookaside.py
tests/utils/test_health_monitor.py
接收 These are durable regression and characterization tests for the changed production behavior. The repository test layout already groups backend, component, distributed, engine, and utility coverage by subsystem. Keep tests beside their existing subsystem test suites; no relocation is needed.
Powered by Nyanpasu with gpt-6.1-terra 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.

常规审查结论(初步)

按接受的 68 个文件范围完成常规审查:生产部分逐文件追踪调用方与既有合同(引擎 profile 与 drain 语义、EnginePool 回滚/恢复与 PG 所有权、placement 预检与物理校验、网关/路由/discovery 兼容形状、LifecycleCoordinator 顺序、两条 deferred 打分路径与发布闸门、OPD teacher 发现与重建),测试与文档全量读毕。统一化后的行为与 RFC #71 及任务 No.3 的要求一致,/rollout/*、/genrm/generate、named actor、外部 teacher URL 等旧接口的兼容声明与代码相符。

  • Medium severity P2 · 进入 score 阶段前先排空在途请求(已行级留言):延迟打分与 over_sampling 补投并发时,score 阶段会在在途请求结束前 offload rollout,最坏使 rollout step 以 TimeoutError 失败。
  • Low severity P3 · 非行级:PR 描述的事实性声明需要更正 — 描述称「fixes a bug on main: a failed streaming /rollout/v1/chat/completions raised NameError: _make_error_chunk」。在本 PR 的 merge-base 5ba49c1 与当前 main(06518120)上,_make_error_chunk 都在 relax/components/rollout.py:1009 以模块级函数完整定义、975/980 行的调用可正常解析,未能复现该 NameError。建议更正描述,或给出受影响的具体 commit;PR 内新网关的实现本身没有问题。

两项验收相关事项留待维护者裁决(非代码缺陷,不设严重性):① Rollout+GenRM 共卡兼容例外(_CO_RESIDENT_ROLE_PAIRS)与 RFC #71「一期拒绝同卡同阶段共同驻留」的取舍,作者已在 10-06 评论与 PR 描述 Open question 中提出,验收标准「Shared co-resident layouts fail before startup」在裁决前无法判定;② 多节点 GPU 验证与真实 GPU 上的 GenRM/teacher/deferred 路径,作者已在描述 Verification 节声明未覆盖,而任务 No.3 验收标准包含「完成多节点 GPU 验证」。

深度阶段:测试必要性审计子任务已在后台启动,结论整合后更新看板。看板:nyanpasu-review

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

Comment thread relax/utils/utils.py Resolved

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

审查结论(最终)

深度阶段(测试必要性审计)已完成:35 个测试文件在 CPU 上全部运行(365 通过、0 失败),并以 14 个定向变异验证检测力——引擎池回滚、drain 顺序、生命周期时序、发布闸门失败路径、放置冲突规则等均被对应测试捕获。生产代码必要性结论不变(5 项保留决定)。整体结论仍为 COMMENT,无 P1。

  • Low severity P3 · 删除不覆盖生产代码的取模演示测试(非行级:用例行在 merge-base 已存在,不属于本 PR 变更)— test_on_policy_distillation_routing_group_index_modulo_would_collapse 只对整数取模做断言,不调用任何生产函数(docstring 亦自述),因此任何路由回归都不会让它失败。被拒绝的朴素取模方案已记载于生产侧 _pick_replica 的 docstring 与本文件模块 docstring,真实回归保护由同文件的 balance 测试提供。非阻塞精简建议:删除该用例,行为无损失。

其余审计结论(34/35 测试文件保留、4 个重复机制用例可并入 test_engine_pool.py 口径、fixture 重复等维护项)与验证盲区(真实 GPU、入站 HTTP、多节点)记录在看板;两项待维护者裁决事项(Shared/Co-resident 例外、多节点 GPU 验证)与 F1/F2 维持上轮所述,不再重复。

看板:nyanpasu-review

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.

复审结论

新提交 419d25b 完整解决了此前行级留言中的 P2:两条延迟路径(框架奖励与 --opd-teacher-defer)现在先 abort() 并等待生成停止、再放行发布(abort 失败则整批不发布),默认路径与自定义 hook 的顺序保持不变;同时把框架延迟打分与 --dynamic-sampling-filter-path 的组合在 Controller 预检中拒绝,双语文档同步更新。已在 F1 留言线程回复逐项验证证据,本地相关 3 个测试文件 41 个用例全部通过;本账号缺少折叠讨论的权限,请作者自行 resolve 该线程。

前一轮结论在新 head 上继续成立:F2(PR 描述的 main NameError 修复声明无法复现)与 F3(取模演示测试建议删除)未变,无新增问题,无 P1。整体结论仍为 COMMENT。新 head 的 CI 在复审时仍在运行、暂无失败记录。

看板:nyanpasu-review

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

@Yangruipis

Copy link
Copy Markdown
Collaborator

@Yangruipis @SigureMo I'm working on No.3 (#368). Before implementing the PlacementPlanner I'd like to confirm one conflict between the RFC and an existing feature: does "reject shared co-resident in the first version" include the GenRM Shared / Co-resident mode that is supported today?

Current behavior

  • The docs list Shared / Co-resident as an official GenRM colocate sub-mode. It is enabled automatically when rollout_num_gpus == genrm_num_gpus == actor_total, and Rollout and GenRM stay resident on the same bundles at the same time, split by mem_fraction_static (docs L29, L268-L275).
  • The mode is selected in arguments.py L4360-L4366 and flagged by _genrm_colocate_with_rollout.

What the RFC says

  • Decision table: Shared co-resident | Reject in the first version.
  • Acceptance checks: Shared co-resident layouts fail before startup.
  • The Compatibility section also says existing CLI flags are only converted to the internal spec, and the task acceptance criteria require the old interfaces to stay compatible.

Read literally, the planner would reject a released, documented configuration before startup. 🤔

Which would you prefer?

  1. Reject it. Existing co-resident configs fail before startup, and the docs mark the mode as no longer supported.
  2. Keep it as a compatibility exception. Allow only the existing Rollout + GenRM pair, and reject every other same-bundle, same-phase combination (for example Teacher with Rollout).

I lean toward 2: it doesn't break existing users, and the exception can be a single explicit rule in the planner with its own tests. I'll implement whichever you decide.

hi @oliver-0424 , thanks for your contribution! Option 2 is OK with me

@oliver-0424

Copy link
Copy Markdown
Contributor Author

@rai-studio-bot About F3 (test_on_policy_distillation_routing_group_index_modulo_would_collapse): this PR did not add that test. It was added by fbf2496 (fix(sglang): keep MM zero-copy on single-node TP, 2026-08-24) and is already on main. In that file this PR only appends a helper and three tests after line 138; lines 96–105 are not part of the diff.

So I'm leaving the test unchanged here. Removing it would be an unrelated change in this PR and fits better in a separate one.

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

复审更新

对新增两提交(fbde82d6、e04bb24c)逐项复审完毕:OPD 延迟打分的跨权重更新 carryover 拒绝(--opd-kl-coef、--opd-token-selection、--mask-offpolicy-in-partial-rollout 均确认是已解析参数,见 opd_utils.py:571、opd_utils.py:728、arguments.py:982,校验非死代码)、PD prefill/decode 就绪聚合、网关原生 SSE 流式透传与 /generate 共享路由、引擎 URL 缓存(修复 discovery 快照被内存切换阻塞、超过网关 5 秒抓取超时的事故;启动、finalize、恢复与 pool 启动 4 个拉起路径均有刷新点)与 STARTING 结算跳过——未发现新问题,无 P1。本地 9 个相关测试文件 151 个用例全部通过,新增的真实 Ray 集成测试直接回归该事故场景。

前轮结论在新 head 上继续成立:F1 已解决(publish/abort 闸门未被本轮提交触及),F2(PR 描述的 main NameError 修复声明无法复现)与 F3(取模演示测试建议删除)未变,整体结论仍为 COMMENT。另:此前待裁决的 Shared/Co-resident 例外,维护者已采纳方案 2(与 PR 现实现一致),该项已回应;剩余待验证事项为多节点 GPU(作者已披露未在本环境验证)。CI 复审时无失败记录。

看板:nyanpasu-review

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

@rai-studio-bot

Copy link
Copy Markdown
Contributor

@oliver-0424 感谢指正,已逐项核实,均属实:

  • 该用例 test_on_policy_distillation_routing_group_index_modulo_would_collapse 由 fbf2496(fix(sglang): keep MM zero-copy on single-node TP)加入,且 fbf2496 是本 PR merge-base 的祖先——即该用例已在 main 上、先于本 PR 存在;
  • 本 PR 对该文件仅有唯一增量 hunk(@@ -138,3 +138,39 @@,在 :138 之后追加 helper 与 3 个用例),:96-105 不在 diff 内。

在此 PR 中删除 merge-base 既有的用例确实违反仓库的最小变更原则,F3 的删除建议就此撤回,不再作为本 PR 的待处理项;「该用例不覆盖生产代码」的观察保留为独立的清理建议,供后续单独变更参考。看板已同步更新(F3 状态已标注)。

@rai-studio-bot

Copy link
Copy Markdown
Contributor

@oliver-0424 F2 已确认解决:PR 描述本轮编辑移除了无法复现的「fixes a bug on main:流式 /rollout/v1/chat/completions 抛出 NameError: _make_error_chunk」声明,不再有待更正的事实性问题。同时核对了编辑后的其余内容与已核实事实一致:新增的 10–12 提交行与已审代码一致(发布前先停生成并等 abort、teacher-topk/union carryover 校验、引擎 URL 缓存),Co-resident 段落链接的维护者裁决与 _CO_RESIDENT_ROLE_PAIRS 的实现语义相符。原发现见首轮评审的「非行级:PR 描述的事实性声明需要更正」一条,看板已标记为已解决。

@SigureMo

Copy link
Copy Markdown
Member

辛苦解决下冲突~

另外,确认完成后可以按照流程 @ 我 request review

@oliver-0424
oliver-0424 requested a review from a team October 13, 2026 02:05
@rai-studio-bot

rai-studio-bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @oliver-0424! 感谢你为 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, yuanlehome, SigureMo, NINGBENZHE
CI ❌ 未通过

@oliver-0424

Copy link
Copy Markdown
Contributor Author

@SigureMo 任务已完成,请求 review。

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

复审更新(合并 upstream/main 后)

合并提交 9f5cae1 将基线移至 dce533b,16 个文件的 PR 差异经合并适配,逐文件核对确认已审行为保持:发布前先停生成并等 abort 的发布闸门与 run_deferred_scoring 门、teacher-topk/union carryover 校验、网关路由与 /generate 双路分发(messages 为必填字段,路由精确)、生命周期协调(上游并行的 handle-helper 机制被协调器完全取代,无遗留调用方)、teacher 捆绑偏移改由 plan_placement 认领。合并解析将上一轮的引擎 URL 缓存替换为 main 既有的 init-record 机制(超时为 0 的 ray.get、代际校验、按记录记忆化),消除了重复状态与其 4 个刷新点;真实 Ray 集成测试仍断言内存切换阻塞期间快照可答,事故回归属性保留。

37 个触及测试文件在合并后 head 上 446 个用例全部通过;F1、F2 在新基线复核仍为已解决,F3 维持撤回。无新发现,无 P1,结论仍为 COMMENT;剩余待验证项为多节点 GPU(作者已披露未在本环境验证)。

看板:nyanpasu-review

Powered by Nyanpasu with glm-5.3-flash max, 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.

感谢贡献! 本 PR 在兼容现有调用方式、收敛推理入口和复用资源管理逻辑上做了扎实的推进,物理 GPU 放置校验与分阶段迁移思路也比较清晰。

不过,当前更适合作为 RFC 的阶段性实现:Gateway 尚未成为所有推理请求统一的准入边界,生命周期与资源所有权仍分散在原有组件中,异常恢复和 deferred scoring 的状态闭环也还需要补齐。

后续建议优先明确请求准入、资源切换及故障恢复的统一责任方,补充覆盖实际训练链路的正确性验证,并将 RFC 中已完成、暂时兼容和后续迁移的部分明确列出。整体方向合理,但还需要进一步收敛职责和补足运行保障,才能支撑这套抽象作为稳定的公共基础设施

Comment thread relax/engine/inference/deferred.py Resolved
Comment thread relax/engine/inference/deferred.py Resolved
Comment thread relax/engine/inference/deferred.py Resolved
Comment thread relax/engine/inference/gateway.py Resolved
Comment thread relax/distributed/ray/engine_pool.py Resolved
Comment thread relax/engine/inference/lifecycle.py Resolved
Comment thread relax/components/inference_gateway.py Resolved
oliver-0424 and others added 26 commits November 3, 2026 15:56
Admit lazy chat streams when consumed. Keep queued senders fenced until their transport closes or response headers prove dispatch, including shutdown, so backend idle cannot erase a request still waiting for an HTTP connection. Preserve dead-holder reclamation and explain how to retry an unconfirmed handoff.
Use one deadline through repeated cancellation instead of unbounded settling. Keep late grants and unknown releases in tracked cleanup tasks, retry idempotent returns, and retain the owner permit until acknowledgement or holder-death proof.
Per-call asyncio.run bound persistent allocation locks to discarded loops. Dispatch async runtime methods to a dedicated loop thread, keep blocking primitives in the executor, and settle runtime work before shutting down the loop and releasing owned resources.
Begin can register an inflight token before its RPC receipt arrives. Put validation and begin inside the registered owner task so cancellation cannot strand lease return. Extend the Ray barriers to real async scale-out dispatch as well as synchronous recovery.
Cancelled foreground waits now leave late receipts to tracked cleanup immediately, preserving shorter OPD retry budgets. Verify lost release acknowledgements remain idempotent across generations and log an ongoing cleanup failure only once.
Keep unknown-model HTTP 400 validation eager while deferring actual admission until SSE consumption. This preserves the public error contract without granting an unsent permit.
Maintenance completion is a terminal outcome, not evidence that every replica is unsafe. Keep residency reserved and record partial resources, while leaving slot fencing to the runtime and pool. Preserve owner tasks, lease finish, and offload receipts. Delegate dispatch receipts through the public runtime interface.
Shutdown proves resource release by server process-tree exit. Requiring
abort success or queued senders to finish prevented global recovery after
an engine failure, even though shutdown could still terminate the server.

Retire admission permanently, attempt abort within the existing 30/35 s
bounds when permits remain, and warn about unreleased requests without
waiting for admission grace. Continue engine teardown and preserve its
failure proof; keep offload's strict drain checks unchanged.

Cover abort errors, timeouts, queued senders and failed process teardown
for both runtimes. Update the PR's queued-shutdown regression to require
successful shutdown and reject later admission or a new gate generation.
A non-restarting owner keeps the only permit record. ActorDiedError means
that record has disappeared, so retrying its return forever only leaks
client tasks. End the retry on definitive death while preserving retries
for transient failures or lost acknowledgements.

Remove completed cleanup tasks after logging failure or cancellation so
their tracebacks are not retained for the client lifetime. Cover owner
death within the control budget, transient errors followed by a receipt,
and failed or cancelled cleanup tracking.
Follower init returns before workers are born, so a saved PID snapshot
cannot prove the server tree has exited after its parent disappears.
Carry a unique incarnation through spawn metadata into the server child's
environment and include matching local workers in exit verification.

Keep setproctitle from erasing the marker, and use spawn for SGLang's
explicit multimodal CPU pool so late workers inherit exec-time evidence.
Rescan after termination within the same budget and retain known live
members when a later environment lookup fails. Actor environments and
other incarnations remain independent.

Cover real follower startup, late spawn/pool workers, process renaming,
parent exit, another live incarnation, and births during cleanup. Preserve
legacy PID/create_time checks and bounded live-wrapper retirement.
A multi-node replica can prove each server has exited on different
attempts. Discarding a successful slot's receipt made cleanup require
simultaneous node reachability even after every process had exited.

Cache successful exit receipts against the actor, pool incarnation and
recorded process identity. Reuse same-generation evidence, keep the whole
allocation while any slot is unconfirmed, and invalidate receipts when
identities change or slots are rebuilt. Preserve borrowed placement groups.

Cover alternating node availability with actual CPU process cleanup,
identity replacement and in-place mutation, and a new generation needing
its own exit proof.
Release is cleanup, so a missing receipt must not replace an upstream
success or HTTP error. Bound the foreground wait and warn on timeout
while the tracked task and owner retain responsibility for the permit.

Normalize dispatch RPC failures to model unavailability. Before native
headers return 503 with Retry-After; after streaming starts deliver the
existing error chunk and DONE framing and close the upstream response.

Cover public Rollout handlers through ASGI for 200/429 responses, stalled
release receipts, confirm errors and failures after stream start. Update
the PR-only control regression to preserve normal results after a release
timeout, retaining all unknown-permit and late-return assertions.
Cancellation delivered inside the HTTP body has already consumed the
caller's signal. Awaiting aclose from __aexit__ then starts a fresh control
budget and can overrun OPD's total deadline by the full release timeout.

On CancelledError, start the same idempotent tracked return task and let
cancellation propagate immediately. Keep unknown permits fenced until
the late receipt arrives. Normal exits retain their bounded cleanup wait.

Cover a real OPD teacher timeout and a single external body cancellation,
with the release receipt held behind an event and returned exactly once.
Remove the multimodal executor monkeypatch: forcing spawn loses fork's
copy-on-write sharing and repeats heavy imports without strengthening GPU
release evidence. CPU preprocessing workers forked from the server do not
own a CUDA context; retain SGLang's transport-specific process choices.

Keep inherited tokens, SPT_NOENV, and cleanup rescans. Cover cleanup of
late fork workers through a live parent while preserving the existing
reparented spawn-worker regressions and incarnation isolation.
A final empty PID scan can miss descendants born while their parents exit.
Put each server in its own inherited group before launching SGLang and
capture the PGID only after that exact server becomes group leader.

Require ESRCH for group exit, revalidate generation membership before each
group signal, and keep PID/token cleanup for escapees and legacy identities.
Let the owning multiprocessing.Process reap its server without psutil
stealing the exit status. Unproven or reused groups remain fenced.

Cover the last-scan birth race, early follower capture, PGID reuse, actor
group protection, and zombie reaping with real CPU processes.
Gateway's manual finally blocks and streaming wrappers restarted the
release budget after cancellation. Share a public idempotent start_release
entry with request contexts, and move cancelled HTTP unwinding into tracked
tasks so the frontend can honor its deadline without dropping cleanup.

Retain each original upstream close receipt instead of trusting HTTPX's
early is_closed flag. Protect chat transport unwinding from AnyIO's repeated
cancellation, close responses lost during handoff, and return permits only
after upstream closure. Normal exits keep bounded receipt waiting.

Cover native/chat ASGI deadlines, both sides of the first frame, repeated
429 cancellation, blocked/automatic close, and response handoff. Update the
queued-sender test to wait for the real background receipt before handoff.
The H20 unit-test container mounts no model and does not set MODEL_DIR,
so the restore test skips there. Document the local GPU/model setup and
explain why a negative-control XPASS demonstrates weight loss while XFAIL
only shows that unbacked pages happened to retain their contents.

Only the module docstring changes; all test logic and marks remain intact.
Cold follower spawn could cache an identity before setpgid, while unreaped
zombies and tokenless fork workers kept cleanup fenced indefinitely.
Wait for group isolation on the startup budget, upgrade matching fallback
identities, and confirm group exit after SIGKILL without requiring reaping.
Keep zombie leaders fenced while other threads remain alive.

Preserve generation-bound partial evidence across actor and node-local
cleanup timeouts. Retain pending Ray requests until their evidence arrives,
while keeping legacy PD rollback's independent exit-receipt path usable.

Add real CPU process barriers, fork/zombie/thread cases and Ray transport
regressions. Full pytest has exactly the main baseline's 243 failures and
errors: HEAD-only=0, MAIN-only=0; all 24 R4b cases and pre-commit pass.
Response headers prove a retained request reached its engine, but an
unconfirmed sender otherwise blocks offload even after abort succeeds.
Track confirmation retries after failed close, share pending receipts,
and stop when the original owner dies or revokes the permit. Treat a
cancelled close operation as unconfirmed without delaying cancellation
of the frontend waiting for it.

Keep normal nonstream requests at acquire/release only. Add real owner,
gate, runtime and pool regressions for retirement, transient failures,
late receipts, generation replacement and frontend cancellation.
The server entry sets its group before spawning descendants, so waiting
for an observable PGID can only lose evidence when the leader exits.
Record its PID as the group at capture and remove follower group waits,
their environment knob, and the live-root upgrade path.

Stop known PIDs before the final group signal to prevent a pre-entry root
from creating children after an early ESRCH. Preserve observed PGID reuse
before killing escapees, and retain post-signal exit verification.
A serial actor can queue shutdown forever behind a stuck method. Waiting
on the same pending reference then prevents the independent cleanup path
from ever retiring its server and releasing the slot.

Handle shutdown timeouts like other failures: stop and confirm the wrapper,
then use the recorded process group for node-local exit proof. Discard the
abandoned actor receipt only after wrapper death; retain pending node tasks
and their generation bindings until their proof arrives.
The derived PGID only needs every SGLang worker to start after setpgid.
Spawn bootstrap imports can run short synchronous helpers (for example
Triton's ldconfig or compiler probes) before the target, so the comments
must not claim that no process at all can exist before entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The unit-test container mounts no model checkpoint, so the test only
ever skipped in CI. CPU tests cover the backup arguments and the
generate-only offload order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
No CI job runs these scripts, and they require a remote Ray cluster.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep router termination in the owning inference runtime even when engine
exit is unconfirmed, retaining main's bounded monitor joins and external
primary endpoint behavior. Preserve public manager disposal through the
common owner, with shared shutdown receipts across retries and epochs.

Adapt the router regression entry and admission fixture without changing
its assertions; cover facade delegation and cancellation separately.
@oliver-0424
oliver-0424 force-pushed the unified_inference_service branch from 269dfaf to 6d082f1 Compare November 3, 2026 08:41
@oliver-0424

Copy link
Copy Markdown
Contributor Author

@rai-studio-bot review

@SigureMo

SigureMo commented Nov 4, 2026

Copy link
Copy Markdown
Member

本赛题已经由 #381 锁定,感谢参与~

@SigureMo SigureMo closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants