Repository navigation
feat(agentic): add trajectory and training observability - #555
xiaoliang0601 merged 4 commits into
Conversation
# ⭐ Feature - Join prompt, group, session, trajectory, stage and training records through stable export identities, with observation collection disabled by default. - Record run outcomes, backend timing, selection and transfer events, and per-sample training scalars through bounded background writers. - Add optional media capture and colocated / asynchronous example launchers. # 🐛 Bug Fix - Preserve current context exhaustion, Score Centering, SFT, fault events, optimizer skip and memory reporting behavior when replaying the source. - Rebuild source-row metadata when an observation reader encounters an offsets-only cache, preserving original JSONL row identities. # ✅ Tests - Carry source observability regressions into the CPU suite and isolate the CUDA snapshot test; adapt moved checkpoint and entrypoint fixtures. # 📝 Documentation - Document observation streams, identifiers and configuration in English and Chinese. Source merge: ea979372716677e08a0e83835001214ada280821 (cherry picked from commit a7fc3cca843b0dcb23d83abc2cc6e6330904d064)
|
Thanks for contributing to Relax, @xiaoliang0601! 感谢你为 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:✅ 满足合入条件
|
Nyanpasu 审查看板审查状态: 📝 初步结果已发布 · 深度审查中 审查版本: bbfc670 目标分支: main 已完成本轮范围与 Run 写入修复的常规复核:开始事件及 manifest 均由后台有界队列持有,shutdown 先启动 watchdog 再按序落盘。正在核对同 run 的 shard 重建身份与相关 PR/拆分边界。
审查发现待处理
已解决或已取代
改进建议(非阻塞)拆分🔎 分析中 — 按当前固定版本重新检查拆分边界及依赖。 相关 PR🔎 分析中 — 核对描述中关联的 PR #526 的重叠实现与合入边界。 提交范围 · 接收 57 · 建议移出 0 · 待确认 0接收 57 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。
Powered by Nyanpasu with gpt-6.1-sol xhigh, please check the suggestions carefully.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查结论:COMMENT
常规与深度审查已完成。已确认一项 P2 来源身份问题,已附在对应 diff 行;其余已检查的 Agentic 导出、阶段事件、TransferQueue/Megatron 训练字段、生命周期清理和默认关闭路径未发现新的可证实阻塞缺陷。当前头的 GitHub checks 已全部通过;多节点 GPU/完整 Megatron 路径仍以 CI 为准。
审查看板:nyanpasu-review
| from relax.utils.agentic_obs.source import SourceRow | ||
|
|
||
| if self._is_parquet: | ||
| start = self.row_slice.start or 0 if self.row_slice is not None else 0 |
There was a problem hiding this comment.
parse_generalized_path 接受 @[负数:] 切片,但这里把负的 row_slice.start 直接加到局部索引。于是 rows.parquet@[-3:] 实际读取物理行 2、3、4,却写出 source_row_id 为 -3、-2、-1,破坏来源身份契约,并可能让观察记录无法与其他读取路径对齐。请使用 slice.indices(len(self._parquet_data))(或等价的规范化边界)后再计算物理行号;同时补一个 Parquet 负切片回归。最小复现:StreamingReader("rows.parquet@[-3:]", with_source=True) 在该头返回 [("2", "-3"), ("3", "-2"), ("4", "-1")]。
There was a problem hiding this comment.
已确认修复:4c37b7739d5b2a64f0851ef783cab40be53d6e64 在 Parquet 切片前用 slice.indices(len(_parquet_data))[0] 保存规范化的物理起点,负切片和越界起点现在写出与未切片读取一致的 source_row_id。新增的 Parquet 负切片、批量读取、跨文件 composite 以及 source-disabled 回归已通过(4 tests passed)。
Capture the normalized physical start before slicing Parquet rows so source_row_id and prompt_id match reads of the same unsliced source. Cover negative bounds, starts before the file beginning, direct and batch access, per-file composite datasets, and source-disabled reads. Validation: 171 CPU tests and all pre-commit hooks pass.
| description = "OBS launcher references the trial env var name, not its value" | ||
| condition = "AND" | ||
| regexTarget = "match" | ||
| regexes = ['''^QS_TRIAL_ID$'''] |
# 🐛 Bug Fix ## Restore the existing Gitleaks config - Remove the launcher-specific trial ID exception. The launcher accepts its observation directory through OBS_DIR. - Restore the original rule table now that the extra exception is gone. - Verify all configured pre-commit hooks, including Gitleaks.
Yangruipis
left a comment
There was a problem hiding this comment.
审查版本:8613043486c8e9585694f6271ab7db93186ca8d5。
发现两项需要合并前修复的 P2,已附行内评论:
- 全局故障恢复重建 SessionShard 后复用 export ID,破坏轨迹、阶段与训练记录的身份关联契约。
- Run 开始事件同步写盘,观测存储阻塞时会卡住训练启动,违背观测不等待磁盘的隔离契约。
两项均已有轻量 CPU 复现。当前 head 的 13 项 GitHub checks 均通过;本地所选 CPU 用例 148 通过、7 项因缺依赖失败,另两个模块因缺依赖无法收集。本地未运行 GPU 或多节点集成验证。
# 🐛 Bug Fix ## Preserve export identity through shard recovery - Reserve a distinct counter range for each shard fleet created by the driver and carry it in the observation configuration. - Keep the shard ordinal and the signed int64 and decimal JSON formats. ## Queue the run start event - Write the start event on a bounded daemon and drain it before flushing the recorded outcome during shutdown. - Cover shard recorder recreation and blocked JSONL opens in CPU tests.
## What Store the Agentic training-input loss mask as nonzero token intervals in train JSONL. Relates to #555. ## Why Tool observations and model responses often form long runs of the same mask value. The interval representation keeps the positions needed for debugging while making those records smaller. ## How - Encode `loss_mask.ranges` in the background writer as zero-based `[start, end, value]` triples with an exclusive end. Positions outside the ranges are zero up to `response_length`. - Compute `effective_tokens` from the interval lengths and values. Integer mask weights and all-zero samples can be reconstructed exactly. - Advertise train schema `4.0.0` through `train_schema_version` in the manifest. The format guide documents v3 arrays and v4 intervals, and the regression checks both with the existing DP update merge. ## Testing - [x] `pre-commit run --all-files` passes - [ ] Tests pass (`pytest tests/`) - [x] New tests added (if applicable) - [x] Documentation updated (if applicable) The Agentic observability, JSONL writer, and stream-join CPU suites passed 201 tests. The round-trip test covers integer mask values and checks the same merged update summary for v3 and v4 records. The CUDA snapshot test skipped on the local CPU host, and integration tests require multi-node GPU hardware. ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [x] Documentation update - [ ] Refactoring (no functional changes) - [x] Performance improvement - [ ] CI/CD or build changes ## Screenshots / Logs The 42-token synthetic mask in the round-trip regression takes 126 bytes as a JSON array and 37 bytes as an interval object, counting the field value only.

What
Add optional Agentic observability from source merge
ea979372716677e08a0e83835001214ada280821, whose code change is identical toa7fc3cca843b0dcb23d83abc2cc6e6330904d064.--dump-agentic-obsjoins prompt, group and session inventories, exported trajectories, stage outcomes and per-sample training scalars. Collection is disabled by default. Includes English/Chinese documentation and colocated / asynchronous example launchers.Why
Follow an individual exported context from its original prompt through generation, reward, selection, transfer and optimizer application. Stable identities and explicit terminal outcomes make dropped, failed and trained exports distinguishable.
Relates to #526, which includes the same observability source alongside hybrid DCS changes. This PR scopes the observability feature independently on current
main.How
sample_export_idthrough SessionShard exports, TransferQueue columns and actor observations; preserve opaque int64 identities in JSON records.mainwhile retaining partial generation on context exhaustion, router retry ownership, Score Centering fields, pre-shifted SFT labels, nonfinite-gradient skips, peak-memory accounting and fault-event lifecycle.tests/cpu/, isolate the CUDA snapshot test, and adapt checkpoint, entrypoint and normalized-message fixtures to currentmain.Testing
pre-commit run --all-filespassespytest tests/)Focused local regression across 24 modules: 623 passed, 14 skipped with GPUs hidden. Coverage includes observability producers/writers, Agentic runtime and protocol behavior, startup/failure outcomes, checkpoint annotation, CPU optimizer/Gloo behavior, source-row provenance, TransferQueue iteration and HTTP timing.
The skipped entries comprise 13 unavailable Megatron imports (including module-level skips) and one CUDA snapshot test. The full suite and multi-node GPU integration were not run because this local environment lacks the Megatron training stack and NVIDIA GPUs; these skips are not counted as regression coverage.
Both launchers pass
bash -nandDRY_RUN=1. Changed Python files pass duplicate-definition and Ruff F811 checks; all tracked files pass the sensitive-content scan.Type of Change
Screenshots / Logs
Local focused result:
623 passed, 14 skipped. The added cache/provenance regression prevents original JSONL row identifiers from being lost when cached offsets are available. Existing media assertions verify sidecar contents and that media writes leave the event loop free.