Repository navigation
[v5] 复用 perf 与 metric 统一性能观测 - #368
Merged
Merged
Conversation
4 of 8 tasks
qychen2001
force-pushed
the
feat/add-log
branch
from
November 4, 2026 07:59
bdc9f19 to
95c0477
Compare
Keep raw timing and memory collection in perf, move throughput calculations into the Metric protocol, and reuse MetricsReporter for append-only records and terminal totals. Remove the RL recorder, duplicate JSONL writer and unused remote wait API. Co-authored-by: Codex
tastelikefeet
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR type
PR information
Related issue: 暂无。配套 Swift #10512,建议先合入本 PR。
将性能观测接入 Twinkle 既有的
perf与metric能力,清理 RL 专用记录器、重复 JSONL writer、手工外部时间区间 API 和 RPC 观察线程所需的额外等待接口。@timed / TimeRecorder / span;perf.stats.memory_stats返回每 worker 的 allocator 峰值与 host RAM 原始字节数。默认不重置计数或同步设备,测量屏障由调用方显式选择。TimeRecorder支持注入单调纳秒时钟进行确定性验证,不增加record_interval。ThroughputMetric使用accumulate / calculate / reset,接收显式样本长度、阶段秒数和物理设备预算。通过计数累积计算窗口总量之比,不平均逐步吞吐,不包含训练轮次状态、任务等待或文件输出。内存转换和跨卡归约使用memory_metrics。MetricRecord / MetricsReporter / _JSONLBackend,不新增 writer 类。增加可选 append 模式保存重启后的旧记录;非有限数值以 null 保留在非数值属性中;生产方按批次上报时允许使用终态总数校准汇总计数。perf不引入 RL 生命周期、吞吐公式或 JSONL 输出;清理RLPerformanceRecorder、rl.py、rl_metrics.py和独立 writer 的 public surface。只提交代码和测试,没有新增独立文档文件。使用 Codex 辅助实现、测试和提交。Experiment results
2026-11-06 在最终实现上完成 3 轮真实 GRPO 训练。配置:8×PPU-ZW810(96 GiB)、Qwen3.5-4B、FSDP2、colocate、rollout TP=2×4、每轮 8 prompts×8 completions=64 条轨迹;每卡微批次 2、梯度累积 4、seed=42、thinking=false、回答上限 1024、context 上限 5120,不保存 checkpoint。回答上限 1024 用于缩短本次记录链路验证。
检查结果:
metrics_raw.jsonl共 7 条:3 条train、3 条rollout(scope=iteration)、1 条run;同一 run_id,包含时间戳和明确的优化器步数。WebUImetrics.jsonl保持原有平铺格式,共 3 条。summary.json正确汇总 24 个生成组、192 条生成样本、192 次训练样本访问、3 次更新,无记录丢弃。全窗口吞吐为 138.920 token/s/GPU,按总 token / 总逻辑秒数 / 8 计算。完整进程耗时 398.561 秒,含环境和模型初始化。这是一轮集成验证,不据此给出稳定提速或收敛结论;首轮含首次调用开销。阶段观测不相互独立,不能把并发或嵌套时间直接相加。
验证对应的提交:
4b0e012768ecb39d96ad759452f7834efa6f10d0160c12be82162b6a72ba16dbf007cab453cced6e训练时使用未提交工作区,提交后已逐文件核对两仓提交内容与被测源码的 SHA-256 一致。原始配置、源码变更快照、日志、逐步 CSV、验证结果和提交核验保存在本地
scripts/performance_a1/output/20261106-metric-pipeline-three-iterations/,实验产物不加入代码 diff。回归与静态检查
在两仓共同父目录、
swift-test环境运行:结果:236 passed, 4 warnings。覆盖 token/时间归一化、窗口吞吐采用总量之比、长度统计、内存转换、追加写入、并发记录、终态总数、日志重叠只扣一次、训练尾批/重复访问、辅助前向并发提交、远程优化器失败传播、发布边界和 WebUI 兼容。
其中 11 项来自既有 reporter 测试的隔离执行:原
test_async_rl_metrics.py导入当前检出缺失的twinkle_agentic.async_rl.metrics,无法整文件收集;临时文件仅去掉该无关导入及依赖它的 helper 测试,保留 reporter 测试行为。副本和运行日志保存在实验目录checks/;不声明该原始测试模块或全仓测试全部通过。两仓
git diff --check通过。完整pre-commit run --all-files已在隔离源码目录执行,仍有仓库已有的 Ruff、格式和文件末尾换行问题;批量格式化未带入提交,不声明全仓 lint 通过。