Repository navigation
refactor(executors): stop copying files from outside a round into its run_dir; delete the leak harvest - #2927
Closed
ZhengGong-amd wants to merge 4 commits into
Closed
ZhengGong-amd wants to merge 4 commits into
ZhengGong-amd wants to merge 4 commits into
Conversation
… run_dir; delete the leak harvest harvest_leaked_artifacts was written for a harness that could leave a round's server log, results and traces outside the round's workspace. Since #2614 every round runs on inference_suite, whose server, client, eval and profile all write below the round's run_dir, so there is nothing left to bring back. The harvest still ran: after every warmup and measured round of run_grid (explore, integrate, rebench, concurrency sweep, multi-branch) it globbed the top of /workspace, $INFERENCEX_PATH and $RESULT_DIR, or INFERENCE_OPTIMIZER_LEAK_ROOTS when set, and copied any server.log, gpu_metrics.csv, profile_*.trace.json.gz, inferencex_result*.json or results*.json modified since the round started into the round's run_dir. A file another process wrote under one of those names replaced the round's own server.log, or became a candidate for the accuracy reader's results*.json glob. The baseline, profile and roofline rounds never called it. Removed: - harvest_leaked_artifacts, its helpers and INFERENCE_OPTIMIZER_LEAK_ROOTS; the measurement runner's call on its own work directory and the leak root the local backend named for it; the leak-root pin eleven test modules set only to keep the harvest off the host. - The multi-node report injection the harvest ended with (_inject_gpu_monitor, _aggregate_gpu_samples_by_role, _row_to_gpu_sample). It wrote gpu_monitor, pd and gpu_monitor_by_role into the round's benchmark_report.json, a file no round has had since #2614, so it returned on its first line. The specialist prompt sentence pointing at gpu_monitor_by_role goes with it. - gpu/_gpu_metrics.write_gpu_metrics, which read benchmark_report.json and was called only by the harvest. gpu_metrics.json is still written by RoundFolder.write_gpu_metrics on both round arms, unchanged; the writer's failure-policy tests now call write_gpu_metrics_from_report. Kept: harvest_mn_gpu_metrics still merges the pods' sampler CSVs into the round's gpu_metrics.csv; the grid now calls it where it reads the finished round. Observable effect: - No file from outside a round's run_dir is copied into it. The "harvested N leaked artifact(s)" log line and the harvested_leaked_artifact:<path> warning are gone. - INFERENCE_OPTIMIZER_LEAK_ROOTS (never documented) is no longer read. - The measurement runner's signed files hold nothing copied from the top of its work directory. On a host that reports itself multi-node the runner also no longer writes a merged gpu_metrics.csv at the top of those files; each round's run_dir still gets its own. - Throughput, latency, accuracy and grading of a round that left nothing outside its run_dir are unchanged. docs: upgrade.md and the release notes gain an entry. Co-Authored-By: Claude Code <noreply@anthropic.com>
Code metrics gate: PASSEDJudged: the 30 files this change touches. Files it does not touch never fail it; anything found there is listed under Outside this change for information.
Module length warning: over 800 lines, within the 1200-line failure limit (not failing): 4
Thresholds and sources: |
…file; drop the last mentions of the leak harvest Review follow-up to the leak-harvest removal. - harvest_mn_gpu_metrics was called from the grid under `except (OSError, ValueError, csv.Error)`, a handler carried over from the deleted harvest. The merge already handles OSError on its read and its write and nothing in it raises ValueError, so only csv.Error could arrive. That one is now caught where the pod file is read, with the same outcome (a warning, no gpu_metrics.csv), and the grid calls the merge in one line without importing csv. - The module docstring of gpu/_gpu_metrics.py still listed the pod-side sampler as a producer of `gpu_monitor`; the injection that made it one is gone. The comment on the baseline event's warning cap still gave "one per harvested artifact" as its reason. - Tests: one entry-point test shows a multi-node grid round still gets gpu_metrics.csv in its run_dir, which no test covered after the call moved. Two test_gpu_metrics.py cases that had become the same call are merged, an assertion that only echoed its own argument is dropped (the round-folder test asserts the real source), and a docstring that pointed at the deleted row mapper is replaced. No observable change. Co-Authored-By: Claude Code <noreply@anthropic.com>
ZhengGong-amd
marked this pull request as ready for review
November 27, 2026 06:21
A pod CSV whose rows all fall outside the round's window, or that the csv module refuses to parse, leaves no gpu_metrics.csv and does not fail the round. The malformed-file branch moved into the merge with the leak harvest's removal and had no test of its own. Co-Authored-By: Claude Code <noreply@anthropic.com>
Collaborator
Author
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.
refactor(executors): stop copying files from outside a round into its run_dir; delete the leak harvest
Description: what and why
harvest_leaked_artifactswas written for a harness that could leave a round's server log, results and traces outside the round's workspace. Since feat(hyperloom): measure every round with InferenceSuite and remove Magpie #2614 every round runs on InferenceSuite, whose server, client, eval and profile all write below the round's run_dir, so there is nothing left to bring back. The harvest still ran. After every warmup and measured round ofrun_grid(explore, integrate, specialist rebench, concurrency sweep, multi-branch) it globbed the top level of/workspace,$INFERENCEX_PATHand$RESULT_DIR(orINFERENCE_OPTIMIZER_LEAK_ROOTSwhen set) and copied everyserver.log,gpu_metrics.csv,profile_*.trace.json.gz,inferencex_result*.jsonandresults*.jsonmodified since the round started into the round's run_dir. On a healthy host it found nothing. When another process wrote one of those names during the round, the copy replaced the round's ownserver.log, or put a foreignresults*.jsonwhere the accuracy reader globs. The baseline, profile and roofline rounds never called it and have run without it since feat(hyperloom): measure every round with InferenceSuite and remove Magpie #2614.Removed:
harvest_leaked_artifactsand its helpers inexecutors/benchmark_result.py, its export fromexecutors/__init__.py, andINFERENCE_OPTIMIZER_LEAK_ROOTS.measure/runner/run.py) and the leak root the local backend named for it (measure/local.py)._inject_gpu_monitor,_aggregate_gpu_samples_by_role,_row_to_gpu_sample,_MN_GPU_SAMPLE_CAP. It wrotegpu_monitor,pdandgpu_monitor_by_roleinto<round>/benchmark_report.json, a file no round has had since feat(hyperloom): measure every round with InferenceSuite and remove Magpie #2614, so it returned on its first line. The PD-disaggregation specialist prompt told the specialist to readgpu_monitor_by_rolefrom the benchmark report; that sentence goes with it.gpu/_gpu_metrics.write_gpu_metrics, the function that readbenchmark_report.jsonfrom a workspace and wrotegpu_metrics.jsonfrom it. The harvest was its only production caller, and no round workspace has that file.gpu_metrics.jsonis still written exactly as before byRoundFolder.write_gpu_metrics→write_gpu_metrics_from_report, called frombenchmark_run/launch.py(baseline arm) andgrid/_round_report.py(grid arm); neither is changed.gpu/_gpu_metrics.pyandtest_gpu_metrics.py, the ones that named_row_to_gpu_sampleor called the pod-side sampler a producer ofgpu_monitor; intelemetry/kv_record.py, the reference to_MN_GPU_SAMPLE_CAP; inbreakdown/recorder/baseline_event.py, the warning cap's stated reason, "one per harvested artifact".Kept:
harvest_mn_gpu_metricsstill merges the pods'gpu_metrics_<host>.csvinto<run_dir>/gpu_metrics.csvfor every grid round that left a run_dir. It was called from inside the harvest; the grid now calls it where it reads the finished round (grid/_round_report._settled_measurement). The harvest wrapped that call inexcept (OSError, ValueError, csv.Error); the merge already handlesOSErroron its read and its write and raises noValueError, so the one error that could arrive, a malformed pod file, is now caught where the file is read, with the same outcome (a warning, nogpu_metrics.csv). Nothing in the tree reads that file and the session package does not collect it, but writing it is an effect and there is no multi-node run to check it against, so it stays for the multi-node owner to decide.This is the first of two stacked PRs. The second deletes the result parsing that cannot run since feat(hyperloom): measure every round with InferenceSuite and remove Magpie #2614 (the
benchmark_report.jsonmapper, the rescue path, the report settle loop) and has no observable effect on a round; this one is kept apart because it removes behaviour that still ran.Linked issue(s): none.
Tests: added/updated? commands run? (if a test was replaced, where its assertions live now):
Deleted with the code they pinned: the eleven
test_harvest_*cases intest_benchmark_result.py, the harvest and_resolve_leak_rootscases intest_benchmark_result_branches_unit.py, the two harvest cases intest_gpu_metrics.py, and the two multi-node cases that asserted the removed injection.Carried across:
gpu_metrics.jsonwriter (the artifact's content, no artifact and no warning for a report without telemetry, a failed write is logged and never raises) was asserted throughwrite_gpu_metrics; the tests now callwrite_gpu_metrics_from_report, which owns that policy. The two no-telemetry cases became the same call and are one test. The artifact'ssourceis asserted with the value a round really writes intest_round_folder.py::test_gpu_metrics_are_written_from_the_report_into_the_round_dir_not_the_run_dir. The two cases specific to the deleted file reader (nobenchmark_report.json, an unparseable one) are removed.measure/tests/test_local_backend.py:test_the_per_round_cap_comes_from_the_callno longer expectsINFERENCE_OPTIMIZER_LEAK_ROOTSin the round's environment; two sample warning strings that named the removed warning are replaced.Added:
test_round_folder.py::test_the_grid_merges_a_multi_node_rounds_pod_gpu_samples_into_its_run_dir. The merge is now reached through a call this PR moved, and no test went through it; this one reads a round as the grid does on a host that reports itself multi-node and asserts<run_dir>/gpu_metrics.csv.Run on Python 3.12 with
PYTHONPATH=src, on this branch merged withmain:pytest -n 40 src/hyperloom/inference_optimizer/tests src/hyperloom/orchestrator src/inference_suite src/hyperloom/measure src/hyperloom_multibranch src/hyperloom/common/tests/test_round_measurement.py: 28326 passed, 82 skipped, 63 failed, 40 errors. All 103 failing test ids also fail onmainon the same host: bubblewrap sandbox tests that cannot remount/, atorchimport that cannot load a ROCm library in a subprocess, installer and gateway-catalog tests. None imports code this PR changes.ruff check .andruff format --check .: clean.python scripts/code_metrics.py --base-ref origin/main: PASSED (30 files judged).lint-imports: 17 contracts kept.python scripts/check_broad_suppress.py: clean.python scripts/pr_hygiene.py size: 391 production Python lines changed.Size/complexity triggers crossed: split, or why the shape is right:
None. 391 production lines change (42 added, 349 deleted), below the 400-line review trigger. No function is added and none gains a branch (
_settled_measurementgains the one merge call);grid/_grid_runner.pyshrinks from 1,112 to 1,088 lines.If this simplifies or refactors: which mechanism was removed, which contract was preserved, and the tests that show it:
Removed: the post-round search for files outside the run_dir, its environment variable, the inert multi-node report injection and the second
gpu_metrics.jsonwriter. Preserved: a grid round's row, warnings other than the removed one, error classes and stop attribution (executors/tests/test_grid_suite_round.py,test_grid_callers_suite.py,test_suite_round.py, unchanged apart from dropping the leak-root pin);gpu_metrics.jsonbeside every round (test_round_folder.py,test_gpu_metrics.py); the multi-nodegpu_metrics.csvmerge: the grid still writes it into a round's run_dir (test_round_folder.py) with the same rows (test_benchmark_result_branches_unit.py).Observable effect: what an operator will now see, and what the old behaviour cost them (if none, why the change is unobservable):
server.log,gpu_metrics.csv,profile_*.trace.json.gz,inferencex_result*.jsonorresults*.jsonfrom the top of/workspace,$INFERENCEX_PATHor$RESULT_DIRis copied into the round's run_dir. Before, a file another process wrote under one of those names during a round could overwrite the round'sserver.logor be picked up as its accuracy result.harvested N leaked artifact(s)and theharvested_leaked_artifact:<path>entry in a round'snonfatal_warningsare gone.INFERENCE_OPTIMIZER_LEAK_ROOTS(never documented) is no longer read and is silently ignored.gpu_metrics.csvat their top level; each round's run_dir still gets its own.gpu_metrics.csvin its variant or warmup directory; the harvest wrote one there, and the merge now runs only on a run_dir. The warning for a malformed pod CSV now names the file.gpu_monitor_by_role, a report field that has not been written since feat(hyperloom): measure every round with InferenceSuite and remove Magpie #2614.gpu_metrics.json, throughput, latency, accuracy and grading of a round that left nothing outside its run_dir are unchanged.docs/reference/upgrade.md("Upgrading from 1.2.x") and the Unreleased release notes carry the entry.Breaking changes: yes, for a setup that relied on the harvest: a benchmark script or wrapper that writes
server.log,results*.json,inferencex_result*.json,gpu_metrics.csvor a profile trace outside the round's run_dir no longer has it copied in, andINFERENCE_OPTIMIZER_LEAK_ROOTSno longer redirects the search. No round on InferenceSuite writes there. In-tree API:harvest_leaked_artifactsleaveshyperloom.orchestrator.actions.executorsandwrite_gpu_metricsleavesgpu/_gpu_metrics.py; their in-tree callers, includinghyperloom.measure, are migrated here.PR addresses single concern: yes — the leak harvest and what only it called.
Root cause is upstream (TraceLens/GEAK/IntelliKit/AgentKernelArena), ticket filed: no.
🤖 Generated with Claude Code