[4/4] [Power] feat: strict AMD gpu monitor lifecycle for MI355X / MI355X 单节点功率监控严格生命周期 - #2494
[4/4] [Power] feat: strict AMD gpu monitor lifecycle for MI355X / MI355X 单节点功率监控严格生命周期#2494edwingao28 wants to merge 8 commits into
Conversation
中文:补齐 AMD 严格生命周期——stop 前多等一拍让 watch 流括住窗口右沿(amd-smi 一次性 CSV 无时间戳列,不能像 NVIDIA 那样补样),awk 逐行 fflush 防 kill 丢缓冲样本,起止两端写硬件能量累加器与 identity 快照供积分交叉审计;截断行修复抽为共用函数。
中文:gpu_metrics 与 power_audit 两个 artifact 增列能量累加器起止快照与 identity 文件,缺省 ignore 不影响非 AMD lane。
中文:三个 bash 生命周期测试(等一拍+能量快照/截断修复不追加/起停全链路含 fflush 存活)+ MI355X 实测 26.2.0 watch 表头钉死 socket_power 优先于 power_management。
|
Thanks for the contribution! Please reach out to respective companies' CODEOWNER to fill in the latest PR_REVIEW_CHECKLIST.md before pinging core maintainer on Slack for review. In order for the signoff PR check bot to trigger, you must follow the PR_REVIEW_CHECKLIST.md template correctly, including the phrase For PR verification, add the PR authors are responsible for ensuring that after merging, all GitHub Action jobs fully pass. A lot of the time, failures are just flakes and simply re-running the failed jobs will fix it. See GitHub's docs on re-running failed jobs 感谢你的贡献!请联系相应公司的 CODEOWNER 填写最新的 PR_REVIEW_CHECKLIST.md,然后再在 Slack 上联系核心维护者进行审阅。为了触发 signoff PR 检查机器人,你必须正确遵循 PR_REVIEW_CHECKLIST.md 模板,包括保留英文语句 如需进行 PR 验证,请为此 PR 添加 PR 作者有责任确保合并后所有 GitHub Action 任务完全通过。 很多时候失败只是偶发抖动(flake),重新运行失败的任务即可解决。参见 GitHub 关于重新运行失败任务的文档 |
中文:MI355X 首验实测双根因——amd-smi(Python)stdout 块缓冲吞掉 kill 前的尾部 tick(PYTHONUNBUFFERED=1 解决);时间戳为整数秒,同秒样本括不住小数窗口右沿(end=…153.325 vs 样本 …153.0),等待加到 interval+2 保证下一整秒 tick 落盘。
中文:consumer 侧新增 cross_check_accumulator——用起止累加器快照差值对账全流梯形积分(校验采样仪器本身,非单窗口),结果写入 sidecar accumulator_check 字段,纯 advisory 不影响 power_valid;覆盖缺失/不可解析/负差/不匹配 GPU/零分母守卫与真实快照表头。
…er' into feat/power-pr5-amd-producer # Conflicts: # benchmarks/benchmark_lib.sh
|
Claude finished @edwingao28's task in 3m 45s —— View job Review
LGTM - no blocking issues found. Checked specifically: the refactored Note: I could not run pytest in this environment (command approval denied), so I relied on static review; the suites run in CI. |
There was a problem hiding this comment.
I didn't find any bugs, but this PR is worth a human look given it makes several hardware-timing assumptions about AMD's amd-smi tool (a magic interval+2s sleep to bracket the window boundary, buffering behavior under kill) that are hard to verify outside the actual MI355X hardware they were tuned against, and it touches the power-measurement pipeline behind the published benchmark anchor numbers.
What was reviewed: the AMD stop-lifecycle sleep/kill/repair sequence in benchmark_lib.sh, the awk fflush buffering fix, and the new cross_check_accumulator GPU-set matching/tolerance logic in aggregate_power.py (advisory only, does not affect power_valid). Checked that the accumulator cross-check intersects GPU IDs between start/end snapshots and the stream rather than assuming matching populations, and that a hung amd-smi call in the monitor sidecars is bounded by the surrounding job timeout rather than blocking indefinitely — both raised as candidates and not reproducible in the diff.
Extended reasoning...
This PR hardens the AMD branch of the single-node GPU power-monitor lifecycle (benchmark_lib.sh), adds an advisory hardware energy-accumulator cross-check (utils/aggregate_power.py), and wires three new sidecar artifacts through the benchmark CI template. It is part of a stacked cross-platform power-measurement series (#2323 → #2437 → #2456 → this PR).
Security risk is minimal — no auth, secrets, or user-facing surface is touched; the changes are internal CI/benchmarking tooling that shells out to amd-smi/nvidia-smi and writes local CSV/JSON artifacts.
The level of scrutiny warranted is higher than a typical CI tweak because this pipeline computes the power/energy metrics used in externally-published benchmark numbers (the PR body includes an anchor-results table with J/token and W/GPU figures). The bash changes rely on empirically-tuned timing (a before killing the AMD watch stream, PYTHONUNBUFFERED + per-row fflush to avoid losing buffered samples on kill) that the author validated against real MI355X hardware runs, but which cannot be independently re-verified without that hardware. The Python cross-check is well isolated and explicitly advisory (never affects power_valid), which limits its blast radius, but the bash lifecycle changes directly gate whether a run's telemetry is considered valid.
Other factors: test coverage is extensive (new bash lifecycle tests mirroring the NVIDIA harness, a real-header column-detection regression test, and 11 accumulator cross-check unit tests), and the bug-hunting pass found no defects, including on the specific hardware-timing and GPU-set-matching concerns a finder raised. Given the combination of non-trivial hardware-specific timing logic and downstream use in published metrics, I'd still like a human familiar with the AMD tooling to confirm the timing assumptions before merge.
Hardens the AMD branch of the single-node GPU power monitor so MI355X runs produce strictly valid energy data through the same pipeline as NVIDIA. Stacked on #2323 (PR1); part of the cross-platform power series (#2323 → #2437 → #2456).
What changes
stop_gpu_monitorwaits one extra tick on AMD before killing the watch stream, so the last benchmark window's right edge is always bracketed for boundary interpolation. The amd-smi one-shot CSV has no timestamp column, so the NVIDIA-style "append one post-exit sample" approach cannot work on AMD.gpu_metrics_energy_{start,end}.csv) plus agpu_metrics_identity.jsonstatic dump. The accumulator endpoint delta gives auditors an independent cross-check of the trapezoid integral.benchmark-tmpl.ymluploads the three sidecars in the gpu_metrics and power_audit artifacts (if-no-files-found: ignore, so non-AMD lanes are unaffected).Ground truth (measured on an MI355X compute node inside the production sglang-rocm container, AMDSMI 26.2.0 / host ROCm 7.1.1):
timestamp,...header, epoch-second timestamps, bare-numbersocket_power; the header also containspower_management, so a test now pins column detection tosocket_powermetric -E --csvcarriesgpu,total_energy_consumptionTests: 3 new bash lifecycle tests (mirroring the existing NVIDIA harness) + 1 real-header column-detection pin + 11 accumulator cross-check tests;
test_process_result.py+test_aggregate_power.py= 97 passed. The cross-check ships inaggregate_power.pyas an advisoryaccumulator_checkblock in the validation payload — it never affectspower_valid.中文说明
把单节点 GPU 功率监控的 AMD 分支补齐到严格生命周期,使 MI355X 与 NVIDIA 走同一条能量管线:
依据为 MI355X 计算节点上生产容器内的实测(AMDSMI 26.2.0):调用延迟 p95 80.9ms、累加器单调且单位为焦耳、每秒增量与瞬时功率一致、watch 表头含 power_management 陷阱列(已用测试钉死列探测)。
Anchor results, N=3 per platform (mean over 3 independent dispatches; CV% in parentheses; Qwen3.5-397B-A17B-FP8, 8k1k, sglang). MI355X: 30960241075, 30962586410, 30964321893. B200: 30958610420, 30962588049, 30964371690. Every window power_valid=1.
On MI355X the hardware energy-accumulator cross-check ran in production on all six windows: relative error vs the trapezoid integral 0.07%–1.30%, all within the 5% advisory tolerance. The b200 TP8 c4 row rides along because the sweep matrix has no TP filter; it is reported for completeness, not compared against TP4 rows.
中文:两平台各 3 次独立 dispatch 的锚点复现表。J/out-tok 的 CV 最差 2.37%(b200 TP4 c4),MI355X 两档均 ≤1.16%;MI355X 六个窗口的硬件累加器交叉验证误差 0.07%–1.30%,全部在 5% 容差内。TP8 c4 行是 sweep 矩阵无 TP 过滤的顺带产物,仅作记录。