Skip to content

【No.15】feat(agentic): audit weight versions at training consumption - #670

Open
AllureCurtain wants to merge 11 commits into
redai-studio:mainfrom
AllureCurtain:feat/agentic-weight-version-audit
Open

AllureCurtain wants to merge 11 commits into
redai-studio:mainfrom
AllureCurtain:feat/agentic-weight-version-audit

Conversation

@AllureCurtain

Copy link
Copy Markdown

What

Add weight-version provenance and consumption-age reports to Agentic training observations, enabled with --dump-agentic-obs.

The report traces effective training tokens back to their Session, turn and generation attempt. It separates version changes during generation from the wait between generation and training consumption.

Why

A multi-turn Agent can wait for a tool across several weight publications, generate again, then queue for training. Tracking committed token intervals and successful policy publications makes these different sources of lag measurable.

Relates to #321, contributor-program task 15.

How

  • Preserve token intervals and source versions when generation attempts commit to the Session lineage, including multi-turn and partial-resume boundaries.
  • Assign publication ordinals after rollout weight installation succeeds. A publisher epoch identifies comparable versions; unknown provenance remains explicit in the report and missing-rate metrics.
  • Connect exported trajectories to successful optimizer consumption through the existing observation records. Intersect provenance intervals with sparse final objective masks to calculate token-weighted ages.
  • Support exact objective membership for CP=1 standard policy reducers, including OPSM, vanilla TIS, ICEPOP, entropy and KL. Keep sampling, GRPO grouping and gradients unchanged.
  • Include bilingual documentation and a reproducible CPU example that exercises Session scheduling, tool waiting, publication hooks, export, optimizer consumption and report reconstruction.

For source publication v, generation-end publication e and consumption publication c, generation age is e-v, waiting lag is c-e, and consumption age is c-v.

Testing

Validated on macOS arm64 with Python 3.12:

  • 205 targeted CPU tests passed, plus 3 subtests, with no skips. Coverage includes Session cancellation and partial resume, two-rank Gloo publication, loss/gradient parity, sparse masks and DCS publication ordering.
  • pre-commit run --all-files --show-diff-on-failure: all hooks passed.
  • npm run docs:build: passed.
  • The CPU example persisted trajectory, stage and training JSONL; independently rebuilding the report produced the same audit.
Targeted regression command
CUDA_VISIBLE_DEVICES='' python -m pytest -q --disable-warnings --tb=short \
  tests/cpu/utils/test_weight_audit.py \
  tests/cpu/utils/test_weight_publication.py \
  tests/cpu/utils/test_agentic_obs.py \
  tests/cpu/test_agentic_observability.py \
  tests/cpu/distributed/checkpoint_service/test_dcs_fused_weight_buckets.py \
  tests/cpu/distributed/checkpoint_service/test_weight_sync_lifecycle.py \
  tests/cpu/components/test_rollout_weight_update_handshake.py \
  tests/cpu/core/test_initial_weight_sync.py \
  tests/cpu/test_agentic_rollout.py::test_agentic_weight_segments_follow_committed_partial_content \
  tests/cpu/test_agentic_rollout.py::test_agentic_run_ir_requeues_empty_delta_abort_without_clearing_prefix \
  tests/cpu/test_agentic_rollout.py::test_agentic_context_exhaustion_preserves_partial_generation \
  tests/cpu/test_agentic_rollout.py::test_agentic_no_decode_capacity_returns_context_error_without_commit
  • 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

Run the CPU example in a fresh process with project dependencies:

CUDA_VISIBLE_DEVICES='' python -m examples.agentic_weight_audit.demo --output weight-demo.json
python -m relax.utils.agentic_obs.weight_report weight-demo-records --output rebuilt-report.json

The example generates 4 tokens with publication 1, waits for a tool while publications 2 and 3 complete, then generates 6 tokens with publication 3. Training consumes the sample after publication 4.

Result Observed value
Per-turn source publications 1, 3
Per-turn consumption ages 3, 1
Generation span / post-generation waiting lag 2 / 1
Token-weighted consumption age 1.8
Version missing rate 0
Audit completeness true

The example uses a controlled generation backend, a real local Ray coordinator and Gloo publication hooks, and a CPU PyTorch loss/backward/SGD update. Raw JSONL records are written beside the report for independent inspection.

Track committed generation token intervals and successful policy publications,
then join their provenance with final objective masks and optimizer outcomes.
Report generation span, post-generation waiting lag and token-weighted ages.

Preserve sparse training masks and publish DCS versions after quantization
finalization. Add a reproducible CPU Session/tool-wait/publication/optimizer
example and regressions for provenance, publication and loss accounting.

Relates to redai-studio#321
@rai-studio-bot

rai-studio-bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @AllureCurtain! 感谢你为 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, RexFlux, yuanlehome, SigureMo, NINGBENZHE, Lemon-412
CI ✅ 已通过

@AllureCurtain

Copy link
Copy Markdown
Author

/review

Please review commit 86af3c7.

@rai-studio-bot

rai-studio-bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: ✅ 已通过

审查版本: 4cab9b2

目标分支: main

双语指南已明确 Fully Async 和 Hybrid 的 DCS 更新均适用 PP 接收集合校验。F9 已修复,本轮未发现新问题。

审查阶段进度范围与结果
常规审查 ✅ 已完成 已核对两处文档改动、Hybrid 和 Fully Async 的 DCS 调用路径及 Megatron 接收拒绝检查。git diff --check 通过。
深度审查 ✅ 已完成 已复核当前提交的 Codenip 与拆分分析。此次增量仅改文档,未重跑运行时测试。

审查发现

待处理
编号 严重性 问题状态规则来源
暂无待处理的记录。
已解决或已取代
编号 严重性 问题状态规则来源
F1 Medium severity 确认各 PP 接收集合一致后再认证发布 ✅ 已解决 Task 15:按同一策略的已发布版本序号计算年龄
F2 Medium severity 计入 GSPO 序列比值仍依赖的目标 token ✅ 已解决 最终目标成员支持范围及自定义 loss 的未知语义
F3 Medium severity 将委托 policy loss 的自定义目标保留为未知 ✅ 已解决 最终目标成员支持范围及自定义 loss 的未知语义
F4 Medium severity 避免在每个 GSPO micro-batch 中同步读取 CUDA 标量 ✅ 已解决 热路径禁止 GPU-CPU 同步
F5 Medium severity 适配器同步跳过完整权重审计的开始步骤
精简建议(非阻塞)
✅ 已解决 —
F6 Medium severity 移除已下线的 SlimeRouter 审计开关 ✅ 已解决 路由迁移约定
F7 Medium severity 在后端返回时采集生成结束序号 ✅ 已解决 生成结束边界
F8 Low severity [experimental · REF007] 直接读取已初始化的请求协调器
精简建议(非阻塞)
✅ 已解决 —
F9 Low severity 在双语指南中注明 PP 接收集合校验适用于 DCS ✅ 已解决 —

改进建议(非阻塞)

精简

💡 生产代码 · 1 条建议

仅让 DCS 收集 PP 接收集合。

范围建议保留的行为与验证依据
Megatron 通用发布提交 删除
按各 rank 一致的后端类型,仅让 DCS 执行接收集合收集,保留所有发布者的拒绝检查和广播。
DCS 需验证各 PP 源的接收集合;其他审计发布仍需汇总接收拒绝并广播序号。
Tensor 和分布式 updater 的接收者为序列,当前每 rank 收集空列表。未测量性能影响。 https://github.com/redai-studio/Relax/blob/d245fea1bae3b4afbd6b358df30e1f0a147d9565/relax/utils/agentic_obs/weight_publication.py#L138-L177

相关 PR

💡 实现与合入建议

保留 #670 的标准 CP=1 审计口径,协调复用 #549 的接收者快照及 #669 的离线读取能力。

https://github.com/redai-studio/Relax/pull/549 · b73bdb4ce86cc32bb90b57d8b0d047403f0d9baa · 目标分支 main

https://github.com/redai-studio/Relax/pull/570 · 433cd17c29380749a80fdb0a7feab9ff9323dbf5 · 目标分支 main

https://github.com/redai-studio/Relax/pull/629 · 155497c223da5f3aa48e51aa1d8be449859ae2f2 · 目标分支 main

https://github.com/redai-studio/Relax/pull/669 · d73884b7814a2aadf1466792048baf94ac3fbbbe · 目标分支 main

实现取舍: #670 以成功发布序号、最终目标 mask 和已提交的 optimizer update 计算年龄。#549 的接收者身份快照可供 DCS 发布确认和恢复路由共用。#669 已拒绝中间损坏行并保留末尾残行容错,离线 CLI 有独立用途。

当前 PR 调整: 复用 #549 时保留 #670 的 epoch 和拒绝判定。若整合 #669 的离线 CLI,保留末尾残行与中间损坏的区分,并以完整的训练更新组合键关联提交状态。

合入顺序: 这些改动没有硬依赖。若先交付 #670 的审计口径,#669 可在 rebase 后保留离线接口并移除重叠采集。也可先独立落地 #549 的接收者快照,再由 #670 复用。

依据与验证范围: 已核对固定版本的接收者收集、坏行处理与训练提交聚合。未运行整合实现。
https://github.com/redai-studio/Relax/blob/b73bdb4ce86cc32bb90b57d8b0d047403f0d9baa/relax/distributed/checkpoint_service/backends/device_direct.py#L1000-L1049
https://github.com/redai-studio/Relax/blob/d73884b7814a2aadf1466792048baf94ac3fbbbe/relax/utils/agentic_obs/version_audit.py#L249-L314
https://github.com/redai-studio/Relax/blob/d73884b7814a2aadf1466792048baf94ac3fbbbe/relax/utils/agentic_obs/version_audit.py#L399-L430
https://github.com/redai-studio/Relax/blob/a3352861bfbfc89c97ab3f98e6c3cdfc6fc43287/relax/utils/agentic_obs/weight_report.py#L17-L38

Powered by Nyanpasu with gpt-6.2-sol high, 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.

有补充意见,发布认证边界仍在复核

已核对固定版本 86af3c7 的 Session 来源、报告聚合及训练消费路径,确认最终目标 mask 的两处错误完整性判断,详见行级意见。两个四 token CPU 边界复现中,启用审计前后的 loss/梯度一致;真实模型、GPU 和多节点集成尚未验证,DCS 的 PP 接收者认证仍在独立复核。

审查看板

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

Comment thread relax/utils/agentic_obs/weight_loss.py Resolved
Comment thread relax/utils/agentic_obs/weight_loss.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.

审查完成,有补充意见

已完成固定版本 86af3c7 的审查。新增的 PP 发布认证风险已给出行级意见,先前两项 mask 意见仍适用;目前确认的影响集中在旁路审计准确性。四个有界 CPU 探针覆盖了相关边界,真实 SGLang/GPU 安装、Megatron 完整训练及多节点集成未验证;当前没有回归 CI 通过证据。

审查看板

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

…ercount

## 🐛 Bug Fix

Address two review findings where the weight audit could certify a complete
effective mask while missing tokens that still participate in the objective:

- `custom_loss` objectives may nest `policy_loss_function` and add further
  targets; the nested policy call previously wrote a `complete` mask before
  the outer terms ran. Reject certification up front with `custom_loss` so
  final membership stays unknown, matching the documented contract.
- Sequence-ratio objectives (GSPO) build a differentiable sequence ratio
  from every log-prob inside `loss_masks` before per-token TIS/OPSM gating
  zeroes outer terms. Rejected tokens still contribute through the ratio,
  so a per-position mask cannot be exact: report `sequence_ratio_unresolved`
  whenever any in-mask token is filtered, unless an auxiliary entropy/KL
  term already keeps full-mask membership.

## ✅ Tests

- New regressions drive the real `policy_loss_function` on CPU: GSPO+ICEPOP
  partial rejection reports unknown, full acceptance stays exact, and a
  `custom_loss` policy call reports `custom_loss` rather than `complete`.
- Verified rejected tokens still receive gradient through the shared
  sequence ratio (-0.5 per position), confirming undercount was real.

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

审查结论

已核验 7d54948 的两项 mask 准确性修复,并在原线程确认;新增的 GPU 标量同步已给出行级意见,原 PP 发布认证意见仍适用。两个精确 CPU 用例通过;完整训练、GPU 与多节点路径未执行,当前未取得回归 CI 通过证据。独立拆分评估建议保持同一 PR。

原修复线程仍开放:当前账号没有标记线程解决的权限。

审查看板

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

Comment thread relax/utils/agentic_obs/weight_loss.py Resolved
…receivers

## 🐛 Bug Fix

Address two further review findings:

- **GPU scalar read in the loss hot path**: the previous sequence-ratio check
  evaluated `(base & ~policy).any()` on training-device masks, converting the
  result to `bool` triggers `.item()` and blocks the CUDA stream on every
  micro-batch. Whether a gate actually filtered lives on the device, so the
  combination is now conservatively reported `sequence_ratio_unresolved`
  whenever a per-token gate (TIS weights or OPSM mask) is present — a pure
  CPU-side check that preserves the corrected accuracy without synchronizing.
- **Divergent PP receiver sets**: each PP source rank prunes its DCS HTTP
  proxy receivers independently, so sets can diverge (PP0={A,B}, PP1={B})
  without any explicit rejection; a partially installed engine would then
  inherit the new version label. `commit_publication` now gathers the
  per-rank receiver key sets and certifies only when all reporting sets are
  identical, leaving the evidence unknown otherwise.

## ✅ Tests

- GSPO regressions updated: gated sequence-ratio objectives report unknown,
  an ungated GSPO objective stays exact; gradient sync removed from the path.
- New two-rank Gloo regression covers the intersection-non-empty-but-unequal
  receiver sets the review called out: divergent sets stay unknown while
  identical sets certify normally.

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

审查通过

7a89da5 的增量复查已完成,四项原意见均已核验修复,未发现新的可操作问题。本轮两个指定 CPU/Gloo 用例通过;真实模型、GPU/多节点集成未执行,当前也没有回归 CI 通过证据。拆分复核建议保持同一 PR。

修复已在原线程确认;线程标记解决仍受账号权限限制。

审查看板

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

Provide the generation provenance defaults used by MsgNode in the existing
six-stream observation test, so its trajectory writer can exercise the full
prompt-to-training linkage after weight auditing was added.

Reproduced the missing-field failure before the change. All 230 related CPU
observation and audit tests and the full pre-commit checks pass afterward.
@AllureCurtain

AllureCurtain commented Nov 14, 2026 •

Copy link
Copy Markdown
Author

/review

Please review the two-line test-fixture update in fc52b457c628820b98d917bb7791b91db1a36b19.

The CPU CI failure in test_six_streams_keep_prompt_session_export_and_update_links reproduces locally: its SimpleNamespace node omitted generation_segments and generation_end_version, preventing the trajectory record from being written. The fixture now supplies the same defaults as MsgNode.

Validation: all 230 tests across test_agentic_obs_isolation.py, test_agentic_obs.py, test_weight_audit.py, test_weight_publication.py, and test_agentic_observability.py passed with GPUs hidden; full pre-commit run --all-files --show-diff-on-failure passed.

The separate Ray startup failure occurred before the test body; that fixture is identical to the base and upstream main, and the other parameter variant passed in the same CI run. Its discarded startup output does not establish the cause. Both previously failing cases now explicitly pass in CPU CI on fc52b45.

Local Ray follow-up: the exact failing [False] case passed (1 test, 63.56s) with process-scoped RAY_AUTH_MODE=token and GPUs hidden. The local CLI detects an existing token, while the explicit-address driver needs the auth mode enabled; this is distinct from the CI startup failure. The Ray fixture and production code remain unchanged.

Final CI verification on fc52b45: all 7 required checks passed. CPU/GPU unit tests passed (CPU: 9457 passed, 155 skipped, 3 subtests passed); all GPU/NPU integration jobs and pre-commit CI passed. Nyanpasu approved this exact head. All four threads with confirmed fixes have now been marked resolved by the PR author.

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

审查通过

已核对 fc52b45 的两行夹具更新:两个默认值与 MsgNode 一致,修复旧 CI 中轨迹记录缺失的原因,现有六流关联与更新提交断言保持不变,未发现新的可操作问题。生产代码未变,沿用前轮已完成审查;本轮未重跑测试,当前尚无完整测试 CI 通过证据。旧 Ray 启动失败的根因仍未确定。

审查看板

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

@AllureCurtain AllureCurtain changed the title feat(agentic): audit weight versions at training consumption 【No.15】feat(agentic): audit weight versions at training consumption Nov 18, 2026
@AllureCurtain

Copy link
Copy Markdown
Author

麻烦帮这个 PR 补一下 Hackathon 2nd 标签:#321 看板上第 15 题的 AllureCurtain 一栏目前仍显示「暂无 PR」。谢谢!

Keep the LoRA session binding and managed-lora routing while preserving
the weight-version audit fields. Record per-attempt generation segments
and only treat an install as certified when all receiver sets match.

- session: bind lora adapter before audit snapshot; keep adapter id as
  raw_version, leave certified source unknown without a publication map
- device_direct: upstream restructured push-failure handling; commit
  publication unconditionally on the non-adapter path
- tests: cover DCS receiver rejection and managed abort/resume segments

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

审查结论

已复核 27ec0bf 合入主线后的行为。三个定向 CPU 用例通过,覆盖受管 LoRA 续跑、完整权重分段溯源和量化失败时跳过发布。本轮新增一项非阻塞建议,详见行级评论。

审查看板

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

Restrict publication begin to the same full-weight paths as commit so
adapter synchronization cannot leave the audit ledger in updating or
replace the frozen base label with an uncertified epoch label.

Extend the existing quantized-adapter lifecycle regression with the real
publication helper and ledger behind mocked transport. The old condition
fails with an updating snapshot; the fix passes both initial and delta
sync checks. Apply the two ruff-format changes required by CI.

Validation: 25 targeted CPU tests pass, including two-process Gloo
publication tests; full pre-commit passes. Broader rollout tests require
SGLang and managed publication tests require Megatron, absent locally.
GPU/NPU and multi-node integration are left to repository CI.

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

审查通过

已复核 6b5a788。LoRA 适配器审计问题已解决,定向 CPU 回归及四个改动文件的 Ruff 格式检查通过。当前提交的主要 CI 工作流尚无验证结果。

审查看板

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

Preserve generation-source auditing and publication certification while incorporating the latest session replay and recovery behavior.
@AllureCurtain

Copy link
Copy Markdown
Author

/review

Please review the merge-conflict resolution against the latest main at d6b0359 (head d245fea).

Comment on lines +23 to +28
def weight_audit_enabled(args: Any) -> bool:
"""Custom router middleware may require numeric labels; leave it
unknown."""
return agentic_obs_enabled(args) and not (
getattr(args, "use_slime_router", False) and getattr(args, "slime_router_middleware_paths", None)
)

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 · 移除已下线的 SlimeRouter 审计开关

合入的 #805 已移除 Python SlimeRouter 和自定义中间件。若旧 YAML 仍带有 use_slime_router: true 和非空的 slime_router_middleware_paths,--custom-config-path 仍会把它们写进 args。原生路由照常运行,这里却会关闭发布审计,即使用户已启用 --dump-agentic-obs。

建议直接复用 agentic_obs_enabled,并删除仅覆盖旧路由分支的测试、示例参数和双语说明。 路由迁移约定 · YAML 参数覆盖

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已核对 feadc0e:旧 YAML 字段已不会关闭权重审计。两份指南仍声称自定义 SlimeRouter 中间件会禁用审计并保留旧标签,建议同步删掉该说明。 英文指南 · 中文指南

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已在 a335286 核实:中英文指南都移除了关于旧 SlimeRouter 中间件关闭审计的说明,和现行审计开关一致。原意见已处理。

Powered by Nyanpasu with gpt-6.2-sol high, 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.

复审结论

已复核 d245fea 合入 d6b03596 的两处冲突。Session 保留主线的 replay 引用处理;Tensor 更新在安装完成后才提交发布记录,colocate 恢复仍等待 KV cache 和 CUDA graph 就绪。新增非阻塞意见见行级评论。Session 定向用例和两进程 Gloo 审计用例通过,Tensor 恢复用例因缺少 Megatron Core 跳过。

审查看板

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment thread relax/agentic/session/service.py Outdated
result.meta_info["engine_weight_version"] = result.meta_info.get("weight_version")
result.meta_info["weight_version"] = str(session.lora_binding.version_id)
elif audit_enabled:
end_version = await generation_snapshot(audit_coordinator)

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 · 在后端返回时采集生成结束序号

Fully Async 下,权重发布可以在 adopt_response 等待 replay 存储确认期间完成。此时后端已经返回,但这里才读取结束序号。受控 CPU 复现中,后端返回时序号为 1,接管期间发布 2,最终把生成年龄和生成后等待从预期的 (0, 1) 记成了 (1, 0)。

建议在后端返回时发起快照读取,让 replay 接管照常进行。在接管成功且 IR 仍有效后使用读到的序号。这样可以保留 main 的引用清理顺序。 生成结束边界

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已在 feadc0e 核实:Session 在 replay 接管前发起结束快照,只有仍有效的 IR 才会写入分段记录。定向 CPU 回归通过,接管期间推进发布序号后,记录仍使用接管前的序号。本轮未运行真实分布式 replay 交错。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment thread relax/agentic/session/service.py Outdated
from relax.utils.agentic_obs.weight_publication import generation_snapshot, weight_audit_enabled

audit_enabled = weight_audit_enabled(self.args)
audit_coordinator = getattr(self, "_sglang_request_limiter", None)

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.

Low severity P3 · [experimental · REF007] 直接读取已初始化的请求协调器

Shard 构造时总会设置 _sglang_request_limiter,持有请求许可的生产路径也直接使用它。可以删除这处兜底,在启用审计的快照分支中直接传入 self._sglang_request_limiter。这也让禁用审计的路径无需读取该字段。 Shard 初始化

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

已在 feadc0e 核实:启用审计时直接读取已初始化的请求协调器,关闭审计时跳过读取。原意见已处理。

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Capture the generation-end publication frontier as soon as the backend returns,
before replay adoption can wait on remote storage. Use the snapshot only after
adoption succeeds and the request remains current.

Enable weight auditing directly from Agentic observability, remove the
obsolete router-flag gate, and initialize the CPU demo shard's cleanup state.
Expose subprocess output when the demo regression fails.
## ✅ Tests

### Fix CPU observability regressions after direct limiter reads

- Set `_sglang_request_limiter` to None in `_session_observation_fixture`,
  matching the constructor attribute that `_run_ir` now reads directly;
  a None coordinator yields the documented unknown-evidence path in
  `generation_snapshot`, so audit-free assertions are unchanged
- Fixes 6 CPU failures: `test_session_attempt_tokens_include_abort_and_cleanup_result`
  (x4) and `test_request_infra_failure_closes_call_as_failed` (x2)

## 📝 Documentation

### Drop stale Slime router audit caveat

- Remove the EN/ZH guide claim that custom Slime router middleware disables
  publication tracking: the Python SlimeRouter was removed upstream in redai-studio#805
  and legacy YAML fields no longer gate weight auditing
@AllureCurtain

Copy link
Copy Markdown
Author

/review

Please review commit a335286a. It fixes the 6 Unit Tests (CPU) failures reported on feadc0e:

  • test_session_attempt_tokens_include_abort_and_cleanup_result (x4) and test_request_infra_failure_closes_call_as_failed (x2) all failed with AttributeError: 'AgenticSessionShard' object has no attribute '_sglang_request_limiter' at service.py:2770, because _session_observation_fixture assembles shards via object.__new__ without the constructor. The fixture now sets _sglang_request_limiter = None; a None coordinator is handled by generation_snapshot as the documented unknown-evidence path, identical to the behavior the pre-feadc0e fallback produced, so no test assertion changes.
  • Verified locally: all 6 previously failing cases pass, plus the full test_agentic_observability.py + test_weight_audit.py + test_weight_publication.py files (157 passed).

It also drops the stale Slime router audit caveat in both guides (docs/en/docs/zh/guide/agentic-rollout.md) flagged in the previous review: the Python SlimeRouter was removed upstream in #805 and legacy YAML fields no longer gate weight auditing.

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

复审结论

已复核 a335286 的三个改动文件。共享夹具补齐协调器字段,此前失败的两组 CPU 测试各选一个变体,均通过。双语指南已移除旧 SlimeRouter 说明。PP 接收集合的适用范围留有一条非阻塞文档意见。当前提交的主要 CI 工作流尚无验证结果。

审查看板

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

Comment thread docs/en/guide/agentic-rollout.md Outdated
adapter-only LoRA and uninstrumented backends cannot provide certified ages.
Audit-enabled publishers use a unique lifetime prefix in backend labels to prevent
restart collisions. Missing coordinator access also yields unknown evidence;
receiver rejections never count as successful publications. Certification additionally requires every PP

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.

Low severity P3 · 在双语指南中注明 PP 接收集合校验适用于 DCS

上文同时介绍了 Megatron tensor/distributed 和 DCS,容易让读者以为三条路径都会校验每个 PP 源的接收集合。实际比较只读取 DCS 的字典式接收集合。两种 Megatron updater 使用序列,仍会检查接收拒绝,但不向这项比较提供集合。建议在英文和中文对应句都加上 DCS 限定。校验实现 · 中文对应句

Suggested change
receiver rejections never count as successful publications. Certification additionally requires every PP
receiver rejections never count as successful publications. For DCS, certification additionally requires every PP
Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

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.

两份指南现在正确区分了 DCS 的接收集合校验和两种 Megatron updater 的接收拒绝检查。还有一个范围需要补齐。Hybrid 的权重更新也会调用 update_weights_fully_async(..., rollout_only=True),DCS 在确认完整或合并权重发布前会执行相同的 PP 接收集合比较。建议把两份指南中「仅 fully-async DCS」改为「通过 DCS 更新完整或合并权重时(包括 Fully Async 和 Hybrid)」。Hybrid 调用路径 · DCS 发布校验

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

## 📝 Documentation

### Clarify which updaters feed the receiver-set comparison

- Note in both guides that only fully-async DCS updates certify identical
  receiver sets across PP source ranks; both Megatron updaters still check
  receiver rejections but store engines as sequences, not the dict the
  comparison reads
- Addresses the non-blocking P3 review suggestion on PR redai-studio#670
@AllureCurtain

Copy link
Copy Markdown
Author

/review

Please review commit 74d84cd0, a docs-only clarification of the PP receiver-set certification scope per your P3 suggestion: both guides now state that only fully-async DCS updates feed the receiver-set comparison, while both Megatron updaters still check receiver rejections but do not participate in the set comparison (their rollout_engines are sequences, not the dict the comparison reads).

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

复审结论

已核对 74d84cd 的双语指南及更新路径。文档还需补充 Hybrid 也适用 DCS 接收集合校验,见原讨论。此次增量仅改文档,git diff --check 通过,未重跑运行时测试。原讨论 · 审查看板

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

## 📝 Documentation

### Extend the DCS scoping to hybrid mode

- Hybrid pushes weights actor-to-rollout through the same DCS DeviceDirect
  path as fully-async, so the PP receiver-set certification applies there
  too; previous wording covered only fully-async
- Follow-up to the P3 review suggestion on PR redai-studio#670
@AllureCurtain

Copy link
Copy Markdown
Author

/review

Please review commit 4cab9b2a, a follow-up docs correction: hybrid mode pushes weights actor-to-rollout through the same DCS DeviceDirect path as fully-async, so both guides now scope the PP receiver-set certification to DCS updates in fully-async and hybrid modes.

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

复审通过

4cab9b2 的中英文指南已说明 Fully Async 和 Hybrid 通过 DCS 更新时均适用 PP 接收集合校验,F9 已修复。本次增量仅改文档,git diff --check 通过,未重跑运行时测试。F9 讨论 · 审查看板

Powered by Nyanpasu with gpt-6.2-sol high, please check the suggestions carefully.

This branch has not been deployed

No deployments
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