Repository navigation
【No.3】feat(inference): Unified Inference Service - #368
oliver-0424 wants to merge 72 commits into
Conversation
|
@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
What the RFC says
Read literally, the planner would reject a released, documented configuration before startup. 🤔 Which would you prefer?
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. |
141f803 to
56f2dcf
Compare
|
@rai-studio-bot review |
|
@rai-studio-bot 不会 review draft PR,如果 PR 已经 ready,可以转为非 draft PR |
Nyanpasu 审查看板审查状态: 🔎 审查中 审查版本: 269dfaf 目标分支: main 已按固定 head 开始审查;常规代码、测试与拆分问题正在核对。
CI 异常检查版本: 6d082f1 · 🔎 分析中
尚无已确认的问题记录;这不代表审查通过。 提交范围 · 接收 148 · 建议移出 0 · 待确认 0接收 148 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。
Powered by Nyanpasu with gpt-6.1-terra xhigh, please check the suggestions carefully.
|
rai-studio-bot
left a comment
There was a problem hiding this comment.
常规审查结论(初步)
按接受的 68 个文件范围完成常规审查:生产部分逐文件追踪调用方与既有合同(引擎 profile 与 drain 语义、EnginePool 回滚/恢复与 PG 所有权、placement 预检与物理校验、网关/路由/discovery 兼容形状、LifecycleCoordinator 顺序、两条 deferred 打分路径与发布闸门、OPD teacher 发现与重建),测试与文档全量读毕。统一化后的行为与 RFC #71 及任务 No.3 的要求一致,/rollout/*、/genrm/generate、named actor、外部 teacher URL 等旧接口的兼容声明与代码相符。
P2 · 进入 score 阶段前先排空在途请求(已行级留言):延迟打分与 over_sampling 补投并发时,score 阶段会在在途请求结束前 offload rollout,最坏使 rollout step 以TimeoutError失败。 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
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查结论(最终)
深度阶段(测试必要性审计)已完成:35 个测试文件在 CPU 上全部运行(365 通过、0 失败),并以 14 个定向变异验证检测力——引擎池回滚、drain 顺序、生命周期时序、发布闸门失败路径、放置冲突规则等均被对应测试捕获。生产代码必要性结论不变(5 项保留决定)。整体结论仍为 COMMENT,无 P1。
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 维持上轮所述,不再重复。
rai-studio-bot
left a comment
There was a problem hiding this comment.
复审结论
新提交 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 在复审时仍在运行、暂无失败记录。
hi @oliver-0424 , thanks for your contribution! Option 2 is OK with me |
|
@rai-studio-bot About F3 ( 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
left a comment
There was a problem hiding this comment.
复审更新
对新增两提交(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 复审时无失败记录。
|
@oliver-0424 感谢指正,已逐项核实,均属实:
在此 PR 中删除 merge-base 既有的用例确实违反仓库的最小变更原则,F3 的删除建议就此撤回,不再作为本 PR 的待处理项;「该用例不覆盖生产代码」的观察保留为独立的清理建议,供后续单独变更参考。看板已同步更新(F3 状态已标注)。 |
|
@oliver-0424 F2 已确认解决:PR 描述本轮编辑移除了无法复现的「 |
|
辛苦解决下冲突~ 另外,确认完成后可以按照流程 @ 我 request review |
|
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 请说明问题、改动和验证方式,保持 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:⏳ 合入条件未满足
|
|
@SigureMo 任务已完成,请求 review。 |
rai-studio-bot
left a comment
There was a problem hiding this comment.
复审更新(合并 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(作者已披露未在本环境验证)。
Yangruipis
left a comment
There was a problem hiding this comment.
感谢贡献! 本 PR 在兼容现有调用方式、收敛推理入口和复用资源管理逻辑上做了扎实的推进,物理 GPU 放置校验与分阶段迁移思路也比较清晰。
不过,当前更适合作为 RFC 的阶段性实现:Gateway 尚未成为所有推理请求统一的准入边界,生命周期与资源所有权仍分散在原有组件中,异常恢复和 deferred scoring 的状态闭环也还需要补齐。
后续建议优先明确请求准入、资源切换及故障恢复的统一责任方,补充覆盖实际训练链路的正确性验证,并将 RFC 中已完成、暂时兼容和后续迁移的部分明确列出。整体方向合理,但还需要进一步收敛职责和补足运行保障,才能支撑这套抽象作为稳定的公共基础设施
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.
269dfaf to
6d082f1
Compare
|
@rai-studio-bot review |
|
本赛题已经由 #381 锁定,感谢参与~ |


What
Rollout、GenRM 和 OPD Teacher 共用一套推理服务。共享 GPU 时,只有确认上一个角色已经释放显存,才会切换到下一个角色。
Why
Related to #321(Task No.3),设计依据是 RFC #71。原来各角色各自管理引擎,切换 GPU 时没有统一的准入,也不确认显存已经释放。
How
InferenceManager负责准入和引擎生命周期;LifecycleAuthority决定哪个角色可以使用重叠的 GPU。GenRMEngine,改用SGLangEngine(..., profile="genrm")。Testing
pre-commit run --all-filespassespytest tests/):有 243 个环境失败,与main相同。在 CPU 上对比
main跑全量测试:本分支没有新增失败。GPU 和多节点没有运行。Type of Change
Screenshots / Logs
无。