Skip to content

refactor(executors): delete the duplicated sweep, report and KV-metrics paths - #1994

Merged
chaojhou merged 30 commits into
mainfrom
refactor/chenyi/cc20-actions-executors-3
Oct 22, 2026
Merged

chaojhou merged 30 commits into
mainfrom
refactor/chenyi/cc20-actions-executors-3

Conversation

@chennyiiis

@chennyiiis chennyiiis commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Split GEAK sweep replay, trace-analysis handling, report rendering and AIPerf/KV metric reading into named operations within their existing modules. The sweep uses an internal _ReplayPlan to carry replay inputs and removes _GeakPointReport; the report writer now receives the assembled report. AIPerf aggregate parsing is inlined into read_aiperf_server_metrics, removing its forwarding layer. common.coerce.first_text centralizes first-truthy text selection and stripping.

The diff against main has one fewer production Python line. It changes _geak_sweep.py, _kv_metrics.py, report.py, trace_analyze.py, coerce.py, the metrics baseline and test_geak_sweep_units.py. No module is added or removed. A regression test verifies that an accuracy-parser failure stays local to one sweep point, preserves its artifacts, and permits the next point to succeed. The baseline removes 15 entries and lowers three existing entries; remaining exceptions include trace_analyze_handler at 146 lines.

Observable effect

Sweep point ordering, measurement basis, launch evidence, report content and KV sample/rank selection are preserved for supported inputs. Accuracy-result parsing remains inside the per-point failure handler, so one failed point does not stop later points. Prechecks retain their order: deployment launcher, accepted config, bench script, then replay identity.

The shared text reader trims whitespace around a GEAK launch-recipe path and logical GPU-pin variable name, where those two reads previously used the literal strings. Trace-analysis target_platform, model_name and analysis_mode values are stringified before trimming; non-string scalar values previously raised on .strip(). Ordinary string inputs keep their existing behavior. Trace-analysis failures remain failed results with empty hot-kernel output and a failure diagnostic.

Size-exception rationale: most changed lines move existing branches into same-file helpers across the listed executor paths. Each extraction and its callers remain together, and the shared text reader is introduced with all its uses. The test pins the sweep failure boundary that previously regressed during the extraction.

Validation

252 existing targeted Linux tests passed covering GEAK sweep, KV metrics and wiring, trace-analysis artifact recovery/locking/report paths, and report rendering. The added accuracy-parser failure regression also passed; Ruff check, formatting and git diff --check passed for the addition. The PR head contains main at bb2da63332dcbc46bdf10702c516ef43eb80a016; there are no missing main commits.

chennyiiis and others added 8 commits October 19, 2026 15:09
…eep point through named helpers

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ule, one function per section

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… and finalize its result as three named steps

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…function

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…s named steps, and move port discovery to its own module

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… under the ceiling

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Code metrics gate: PASSED

Judged: the 7 files this change touches. Files it does not touch never fail it; anything found there is listed under Outside this change for information.

Dimension Limit New Worse Baseline out of date Baseline entries vs base
Cyclomatic complexity fails > 20 0 0 0 20 -2
Cognitive complexity fails > 30 0 0 0 102 -5
Function length (lines) fails > 80 0 0 0 240 -6
Nested block depth fails > 5 0 0 0 11 -2
Parameter count fails > 5 0 0 0 88 +0
Module length (lines) warns > 800, fails > 1200 0 0 0 47 +0
Duplicated lines per file fails > 0 0 0 0 95 +0
Dead code (vulture) fails > 0 0 0 0 2 +0
Check Findings Effect
Comments 0
English only 0
Production code imports test code 0
Repeated literals 0
A1 Private name of another package 0
A8 Flag argument 0
A9 Tuple return 0
A10 Raw vocabulary comparison 0
A11 Hidden global write 0
A12 Pure forwarder 0
A12 Single-implementation abstraction 0

Module length warning: over 800 lines, within the 1200-line failure limit (not failing): 1

Module Lines Limit
src/hyperloom/orchestrator/actions/executors/trace_analyze.py 818 warns > 800

Already over at the base (backlog, not this change's): 2

Unit Dimension Base Now
src/hyperloom/orchestrator/actions/executors/_kv_metrics.py:662 port_from_server_log Nested block depth 6 6
src/hyperloom/orchestrator/actions/executors/_kv_metrics.py:1 Module length (lines) 1591 1579
74 findings in files this change does not touch

Outside this change (informational): 74

Unit Dimension Baseline Now
src/hyperloom/orchestrator/state/shared_state.py resolve_graded_comparison Cognitive complexity absent 34
src/hyperloom_kb/collect/mapping.py _experience Cognitive complexity absent 31
src/kernelforge/cli/forge_loop_command.py forge_loop Cognitive complexity absent 31
src/kernelforge/loop/runner.py IterationLoop._collect_session_candidate Cognitive complexity absent 44
src/kernelforge/loop/runner.py IterationLoop._rule_on_attempt Cognitive complexity absent 38
src/hyperloom/inference_optimizer/cli/__init__.py _reexport_session_environment Function length (lines) absent 107
src/hyperloom/inference_optimizer/cli/__init__.py _resolve_agent_lineup Function length (lines) absent 89
src/hyperloom/inference_optimizer/cli/__init__.py _resolve_run_topology Function length (lines) absent 92
src/hyperloom/inference_optimizer/multi_node/scripts/launch_multinode.py _build_parser Function length (lines) absent 84
src/hyperloom/inference_optimizer/multi_node/scripts/launch_multinode.py _spawn_rank_actors Function length (lines) absent 84
src/hyperloom_kb/sync.py GlobalSync.pull Function length (lines) absent 84
src/kernelforge/loop/runner.py IterationLoop._close_iteration Function length (lines) absent 117
src/kernelforge/loop/runner.py IterationLoop._collect_session_candidate Function length (lines) absent 185
src/kernelforge/loop/runner.py IterationLoop._implementer_history Function length (lines) absent 112
src/kernelforge/loop/runner.py IterationLoop._rule_on_attempt Function length (lines) absent 102
src/kernelforge/loop/runner.py IterationLoop._source_attempt Function length (lines) absent 175
src/hyperloom_kb/http_service.py Module length (lines) absent 1525
src/kernelforge/cli/forge_loop_command.py Module length (lines) absent 2003
src/hyperloom/orchestrator/actions/executors/_grid_runner.py run_grid Cognitive complexity 177 180
src/hyperloom/orchestrator/actions/executors/explore.py ExploreExecutor.__call__ Cognitive complexity 369 383
src/hyperloom/orchestrator/specialists/dispatch.py SpecialistDispatchCollaborator.warm_specialist_params Cognitive complexity 93 94
src/hyperloom/orchestrator/actions/executors/_grid_runner.py run_grid Cyclomatic complexity 55 56
src/hyperloom/orchestrator/actions/executors/explore.py ExploreExecutor.__call__ Cyclomatic complexity 76 83
src/hyperloom/agents/quantization/driver/retry.py quantize_via_prompt Function length (lines) 102 103
src/hyperloom/inference_optimizer/breakdown/exporter.py build Function length (lines) 132 136

...and 49 more; the job log lists every row.

Verdict computed by the gate scripts in /home/runner/work/_temp/code-metrics-gate, not by this tree's copy.

Thresholds and sources: [tool.hyperloom.code_metrics] in pyproject.toml. Tools: complexipy 8.0.1, jscpd 5.4.1, ruff 0.16.2, vulture 2.16.

@chennyiiis chennyiiis added the size-exception Waives the PR diff budget; added by a maintainer with a reason in the PR description label Oct 19, 2026
Comment thread src/hyperloom/orchestrator/actions/executors/_report_md.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/_report_md.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/_report_md.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/_report_md.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/_report_md.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/_report_md.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/trace_analyze.py Fixed

@chaojhou chaojhou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #1994 -- refactor(executors): split the GEAK sweep, trace analysis, report rendering and KV metrics into named steps

What it does: PR #1994 says it is a pure refactor. It splits sweep_via_geak, trace_analyze_handler/_build_trace_analyze_cmd, report._format_md (and its roofline and external-baseline sections) and _kv_metrics._read_aiperf_aggregate_json/sample_from_families into named helpers, and moves the Markdown renderer to _report_md.py and port discovery to _kv_ports.py. Script checks show report, kv_metrics and the trace argv output unchanged, but the GEAK sweep and the trace handler have verified behaviour changes on failure paths, and the PR conflicts with main on the code-metrics baseline.

Blocking issues: 3

  1. [geak-eval-outside-try] An exception in the GEAK point's accuracy parse now aborts the whole sweep [verified]
    Problem: In base, parse_eval_results ran inside the per-point try ... except Exception # noqa: BLE001. In head, _measure_sweep_point calls _measured_point_fields (which calls parse_eval_results) after the try block. An exception there now leaves _measure_sweep_point, _replay_sweep_point and sweep_via_geak. src/hyperloom/orchestrator/actions/executors/_geak_sweep.py:546
    Impact: Base marked that point failed with repr(exc), still wrote its launch evidence and benchmark_report.json, and replayed the remaining points. Head raises from sweep_via_geak: the remaining points never run, this point gets no launch evidence or benchmark_report.json, and the caller gets an exception instead of the failure payload. This contradicts the description's claim of 'same ... artifacts and failure payloads'.
    Action: Move the _measured_point_fields(...) call back inside the try block in _measure_sweep_point, so it is covered by the same handler as in base. Add a regression test that drives sweep_via_geak with a point whose parse_eval_results raises.

  2. [geak-precheck-order] GEAK replay pre-check order changed, so the published error_class differs [verified]
    Problem: Base checks in this order: missing_deployment_launcher, invalid_accepted_config, missing_bench_script, invalid_replay_identity. Head's _build_replay_plan calls _resolve_replay_script first, which raises missing_bench_script before _accepted_config_as_variant runs. When both conditions hold, the failure payload is different. src/hyperloom/orchestrator/actions/executors/_geak_sweep.py:400
    Impact: sweep_via_geak returns error_class 'missing_bench_script' where it returned 'invalid_accepted_config'. Anything that branches on or reports error_class sees a different cause. This is an unstated change in a PR that says the failure payloads are kept.
    Action: In _build_replay_plan, call _accepted_config_as_variant before the bench-script existence check: keep the deployment-launcher check first, then accepted_config, then the fallback bench-script check. Alternatively, state the reorder in the description as an intended change.

  3. [merge-conflict-baseline] PR is CONFLICTING with main on scripts/code_metrics_baseline.txt [verified]
    Problem: mergeable=CONFLICTING. Main lowered baseline entries in the conflicting hunks: #1986 84bcdfb lowered build_launch_evidence (cognitive 35, lines 97) and _kv_metrics module-lines to 1590, and #1984 f7f64ac lowered _workload_envs.py to 2158 and baseline.py to 4212. scripts/code_metrics_baseline.txt:45
    Impact: The PR cannot merge. Taking the PR side raises main's lowered values, which the whole-file ratchet rejects. Neither side's _kv_metrics module-lines value matches the merged file (1511 lines).
    Action: Merge origin/main, keep main's lowered values, delete the PR's removed entries, and rerun python scripts/code_metrics.py --update-baseline on the merged tree so that _kv_metrics module-lines becomes 1511.

Checked: _geak_sweep.sweep_via_geak (no); trace_analyze._build_trace_analyze_cmd (yes); trace_analyze.trace_analyze_handler (no); report._format_md -> _report_md._format_md (+_format_roofline_comparison_section, _format_external_baseline_section) (yes); _kv_metrics._read_aiperf_aggregate_json (yes); _kv_metrics.sample_from_families (yes); _kv_ports.port_from_server_log / port_from_workspace (moved from _kv_metrics) (yes) | Conflict with main mechanical-baseline-only | Base: 3fe44e0 | Head: a2bad03

…actions-executors-3

# Conflicts:
#	scripts/code_metrics_baseline.txt
@ZhengGong-amd

Copy link
Copy Markdown
Collaborator

Requesting changes: the "no observable change" claim does not hold for the GEAK sweep, the branch conflicts with main, and the refactor grows production code instead of shrinking it.

Production code: +1767/−1328 (net +439), with 15 new private types (_geak_sweep.py alone is +189 net and 7 types). A complexity refactor should shrink production code. Bring this PR to net-zero or negative by deleting mechanisms, not by moving them into new types and modules.

Blocking

  1. parse_eval_results now runs outside the per-point try (_geak_sweep.py:546). One bad eval file now raises out of sweep_via_geak and loses the remaining points, that point's launch evidence and benchmark_report.json. On base, only that point is marked failed. Move the _measured_point_fields(...) call back inside the try in _measure_sweep_point. Add a regression test: patch parse_eval_results to raise, then assert status == "failed", both points are present and the second point's benchmark_report.json exists.
  2. The pre-check order changed (_geak_sweep.py:400-404): _resolve_replay_script now runs before _accepted_config_as_variant. With an invalid accepted_config and a missing bench script, base reports invalid_accepted_config and head reports missing_bench_script. Restore the base order (launcher, accepted_config, bench script exists, serving identity) and add a test for it.
  3. Conflict in scripts/code_metrics_baseline.txt. Rebase onto main, keep the values main has already lowered, then run python scripts/code_metrics.py --update-baseline on the merged tree.

Simplify instead of relocate

  • GEAK sweep: one _resolve_replay(...) that returns a dict or a failure dict, plus one loop with a single try. Delete _ReplayUnavailable (it uses an exception for control flow), _ReplayScript, _ReplayPlan, _SweepGrid, _SweepPoint (it copies repeats/timeout_sec into every point) and _PointMeasurement (succeeded/error duplicate fields["status"]/fields["error"]). Keep _sweep_point_env and _point_summary.
  • trace_analyze.py: delete _AnalysisTiming and _FrameworkChoice. Make _build_trace_analyze_cmd return argv only and have the handler call _requested_steady_state_mode. Move SharedState.load_or_init back after the trace_input check (:884-886).
  • _point_summary: if the pinned GEAK always writes throughput_tok_s_median, delete the fallback to the legacy output_throughput_tok_s_median field.
  • _report_md.py and _kv_ports.py are real module boundaries and can stay as they are.

Test and others added 3 commits October 20, 2026 10:47
…sult, and name the first failing precheck

An accuracy result the eval reader cannot parse is contained on the point that
produced it again: the point records the error and the grid runs on, instead of
the exception leaving the sweep and taking every remaining point with it.

The prechecks that decide whether a sweep can replay at all run in their original
order, so a run whose accepted config and bench script are both unusable is
reported as `invalid_accepted_config` rather than `missing_bench_script`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…on state is read

A payload without `trace_input` is answered on its own terms again, so a session
whose `state.json` cannot be read reports the missing trace rather than the
unreadable state. Shaping the tool's result is back inside the handler's timeout
guard, and the GEAK grid lays its points out as it reaches them, so an unparseable
shape spec stops the sweep where the grid reaches it.

Port discovery reads the round's evidence through one search of the workspace
instead of three copies of it.

The three wrapped report lines CodeQL read as a list missing a comma are now
explicit single expressions; the rendered Markdown is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chennyiiis

Copy link
Copy Markdown
Contributor Author

PR #1994 -- refactor(executors): split the GEAK sweep, trace analysis, report rendering and KV metrics into named steps

What it does: Four executor units had grown past the repo's complexity ceiling and two of their modules past the module-length limit. Each entry point is now a sequence of named steps over a private record type -- sweep_via_geak into _build_replay_plan / _replay_sweep_point / _sweep_outcome, trace_analyze_handler into resolve / run / finalize, _format_md into one function per section of the report, and _read_aiperf_aggregate_json into phase blocks, series readings and scrape windows -- with the Markdown renderer moved to _report_md.py and metrics-endpoint discovery to _kv_ports.py. Nothing an operator can observe changes: the same entry fields, error_class values, artifacts and log lines come out.

Blocking issues: none

The three findings of the previous review are fixed at this head, each re-verified against origin/main's implementation rather than against the description:

  • _measure_sweep_point calls _measured_point_fields inside the per-point except again, so an eval export the accuracy reader cannot parse fails that point and the grid runs on, with the partially read bench_summary numbers still reaching benchmark_report.json. Pinned by test_an_unreadable_accuracy_result_fails_its_own_point_only, which fails on the pre-fix commit and passes against main's implementation.
  • _build_replay_plan raises in the original order (missing_deployment_launcher, invalid_accepted_config, missing_bench_script, invalid_replay_identity). Pinned by test_the_first_failing_precheck_names_the_sweep_failure, which makes every precheck fail at once so only the order decides the answer.
  • The baseline conflict is resolved and _kv_metrics module-lines is 1511; mergeable is MERGEABLE and code-metrics is green.

Four further differences were found by an independent audit of the whole diff and are fixed in the same head, each with the same treatment:

  • trace_analyze_handler refuses a payload naming no trace before SharedState.load_or_init runs, so an unreadable state.json no longer turns that refusal into a raised JSONDecodeError. Pinned by test_trace_analyze_handler_refuses_a_payload_without_a_trace_before_touching_session_state.
  • _run_analysis_tool shapes the tool's result inside the subprocess.TimeoutExpired guard again.
  • _plan_sweep_points yields, so an unparseable shape spec stops the sweep where the grid reaches it rather than before the points ahead of it have run.
  • _kv_ports.py reads the round's three evidence sources through one search of the workspace instead of three copies of it.

The dropped isinstance(result, dict) guards in the trace handler are reported as nothing: _shape_tool_result (_kernel_agent_tool.py:398) returns a dict on every branch, so no producer can reach them, and AGENTS.md's "trust the caller" is what keeps them removed.

SKIPPED: V4 -- openprs.txt compared #1032, #1154, #1276, #1869, #1907 and #2004 on their first 100 files only, so overlap with those is unchecked. Among the PRs fully compared the only overlap is scripts/code_metrics_baseline.txt, plus a different region of test_baseline_comparison.py with #2042 and of test_conc_sweep.py with #2039.

Checked: _geak_sweep.sweep_via_geak / _build_replay_plan / _measure_sweep_point / _plan_sweep_points; trace_analyze.trace_analyze_handler / _resolve_analysis / _run_analysis_tool / _build_trace_analyze_cmd / _finalize_analysis_result; report._write_final_report and _report_md._format_md with its section helpers; _kv_metrics._read_aiperf_aggregate_json / _series_readings / sample_from_families / _most_pressured_rank; _kv_ports all four resolvers; _kernel_agent_tool._shape_tool_result | Ran: pytest test_geak_sweep_units.py test_kv_metrics.py test_kv_metrics_wiring.py test_report.py test_profile_and_kernel_handlers.py (373 passed, 1 pre-existing local failure from a missing TraceLens checkout); the same selected tests against origin/main's and the pre-fix _geak_sweep.py / trace_analyze.py; differential comparison of both versions on randomized inputs across nine harnesses (31,780 cases, 0 mismatches); cc_scan_cmetrics.py 20 (no function in the six files at or over 20); scripts/code_metrics.py --update-baseline under the pinned toolchain | Base: adbc187 | Head: 8ec61aa | CI: 40 checks, 33 pass, 7 skipped, 0 failing

LGTM

@ZhengGong-amd

Copy link
Copy Markdown
Collaborator

Production code is still too large. The net growth is +449 lines (it was +439), and it needs to keep shrinking before this can merge.

I classified every changed line in the touched production files with an AST pass (merge-base vs head 45fdf6ea7):

net lines
executable logic -8
docstrings +163
def/class signatures +108
NamedTuple/dataclass fields +62
blank lines between new defs +148
imports / __all__ +16

Functions go from 118 to 184, record types from 3 to 16, and total parameters from 176 to 295. Of the 80 new definitions, 57 are referenced exactly once in src/.

The logic barely changed (-8). The growth is the scaffolding around single-use units: their signatures, docstrings, fields and spacing (about +497 lines). That is the same control flow in more places, not a simpler one (AGENTS.md Simplify by removing a mechanism). The parameter-count and tuple-return limits in [tool.hyperloom.code_metrics] are review triggers, not a reason to add a type or a helper. When a limit and the clearer code disagree, keep the clearer code and say so (Size is a design signal).

Cut next:

  • _ReplayUnavailable, _ReplayScript, _ReplayPlan, _SweepGrid, _SweepPoint and _PointMeasurement: one _resolve_replay plus one loop with a single try.
  • _AnalysisTiming and _FrameworkChoice. Have _build_trace_analyze_cmd return argv only.
  • The legacy output_throughput_tok_s_median fallback, if the pinned GEAK no longer writes it.
  • Inline the remaining helpers that have one caller and only thread arguments through, and drop the docstrings that restate a private helper's name (Comment below the local average).

Target: production net ≤ 0, or name each remaining new type in the description with what it removes.

Test and others added 4 commits October 20, 2026 16:51
…actions-executors-3

# Conflicts:
#	scripts/code_metrics_baseline.txt
…actions-executors-3

# Conflicts:
#	scripts/code_metrics_baseline.txt
#	src/hyperloom/orchestrator/actions/executors/_kv_metrics.py
#	src/hyperloom/orchestrator/actions/executors/trace_analyze.py
…actions-executors-3

Resolved against #1952 (Drive the TraceLens Agent from a YAML run config):
--analysis-mode retires with the bypass route, so #1952's _bypass_flags helper
is carried into this branch's extracted _analysis_tool_argv and dropped from
_workload_identity_flags.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Test and others added 5 commits October 21, 2026 11:37
…actions-executors-3

Only scripts/code_metrics_baseline.txt conflicted; resolved with
resolve_baseline.py. test_profile_and_kernel_handlers.py auto-merged and
carries main's #1782 additions (_PROFILE_VLLM_CONFIG, the r9700 gfx12
routing test, gpu_types.gpu_runner_type).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ted work

Reworks the report/trace/kv-metrics executors delete-first instead of
relocating code: the aiperf reader's forwarder, the per-sample rank
unpacking, the roofline section's two copies of the theoretical-peak
caveat and three copies of the snapshot block, the external-baseline
advisory note, the three "Reference mean" branches, the unreachable
`isinstance(result, dict)` wrapper in the trace-analysis handler, the
`_GeakPointReport` bag that was unpacked one line later, and six copies
of a first-non-empty-text fallback that `hyperloom.common.coerce` now
owns as `first_text`.

Functions that were under every repo threshold at the merge base are
restored to it, including the whole `_kv_ports` / `_report_md` split.

No observable change: internal structure only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…le-use property

``port_from_server_log`` was under every threshold already, so put its guard
back the way it was. ``_ReplayPlan.env_str`` had one reader; join the accepted
env where it is used.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…actions-executors-3

# Conflicts:
#	scripts/code_metrics_baseline.txt
@chennyiiis

Copy link
Copy Markdown
Contributor Author

Reworked delete-first. Against the current merge base (origin/main at 9f7030af9, which carries #1896, #1998, #1959 and #2046) this PR is now −1 net production line (was +449) with −2 docstring lines. origin/main is merged, the baseline conflict was resolved with the lower-of-both tool, and CI is 40 checks / 0 failures.

Measured every touched function at the merge base on the gate's own scales (ruff C901 20 / complexipy 30 / 80 lines / 5 params). Over a threshold there, and therefore in scope: sweep_via_geak (20/70/235/10 params), trace_analyze_handler (20/51/232), _format_md (22/48/150), _read_aiperf_aggregate_json (22/91/101), sample_from_families (10/33/100), _format_external_baseline_section (10/24/82), _format_roofline_comparison_section (6/13/102).

Reverted as never over any threshold: _kv_metrics.port_from_server_log — its guard is byte-identical to the merge base again.

Two functions are green on the repo gate at the merge base but were over the external Cmetrics 20 bar (_replay_serving_env 30, _build_trace_analyze_cmd 24), so they stayed in scope and are now 15 and 15.

read_aiperf_server_metrics shows as changed only because the pure forwarder of that name was deleted and _read_aiperf_aggregate_json took its name.

One deliberate exception to the revert rule, called out rather than hidden: _write_benchmark_report was under every threshold at the merge base, but the change to it deletes the single-use frozen dataclass _GeakPointReport (12 fields) and has the caller build the report dict. Reverting would put 18 lines of state bag back. I left it deleted; say the word and I will restore it.

common/coerce.first_text is the only addition outside the touched executors: 4 lines, 15 call sites, and a sibling of the existing first_float/first_int.

Highest Cmetrics anywhere in the four files: 19 (_format_composite_perf_section). Nothing in scope is at or over 20.

@chennyiiis chennyiiis changed the title refactor(executors): split the GEAK sweep, trace analysis, report rendering and KV metrics into named steps refactor(executors): delete the duplicated sweep, report and KV-metrics paths Oct 21, 2026
Test and others added 7 commits October 21, 2026 21:40
Resolve the scripts/code_metrics_baseline.txt ratchet by keeping the lower
value on each side.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merging main shortened the module; the ratchet entry has to follow.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Resolve scripts/code_metrics_baseline.txt by keeping main's entries and
applying this branch's removals and lowered values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…actions-executors-3

Only scripts/code_metrics_baseline.txt conflicted. Resolved with the
ratchet rule: whichever side records the lower value wins, an entry the
merge base had and a side dropped is retired, an entry absent from the
base is kept.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…actions-executors-3

Only scripts/code_metrics_baseline.txt conflicted. Resolved with the
ratchet rule: whichever side records the lower value wins, an entry the
merge base had and a side dropped is retired, an entry absent from the
base is kept.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…actions-executors-3

Brings the branch up to origin/main; no path conflicted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@chaojhou chaojhou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #1994 -- refactor(executors): delete the duplicated sweep, report and KV-metrics paths

What it does: Five executor units sat above the code-metrics baseline. The PR removes their duplicated parts and splits them into helpers in the same files. The duplicates are: the roofline note and snapshot block, the advisory note, the SGLang/vLLM usage fallback, the _GeakPointReport state bag and the read_aiperf_server_metrics forwarder. It adds common.coerce.first_text for the repeated str(a or b or "").strip() chains. Production code is one line shorter overall, and 15 baseline entries are deleted and 3 lowered. The only behaviour changes are the ones the description states: whitespace is now trimmed around the GEAK launch-recipe path and the logical GPU-pin variable, and non-string trace-analysis target_platform/model_name/analysis_mode values are stringified instead of raising.

Blocking issues: none

SKIPPED: V4 -- openprs.txt compared #1869, #1276, #1154 and #1032 on their first 100 files only, so overlap with them is unchecked.

Checked: _geak_sweep.sweep_via_geak/_replay_serving_env/_replay_sweep_point/_sweep_outcome; trace_analyze.trace_analyze_handler/_build_trace_analyze_cmd and the new helpers; report._format_md/_format_roofline_comparison_section/_format_external_baseline_section; _kv_metrics.read_aiperf_server_metrics/sample_from_families; coerce.first_text; _kernel_agent_tool._shape_tool_result; _subprocess_kill.run_with_session_kill | Ran: pytest test_geak_sweep_units.py (32 passed, head and base code); test_kv_metrics.py test_kv_metrics_wiring.py test_report.py test_profile_and_kernel_handlers.py test_kernel_request_handlers_units.py (602 passed, 1 failure from the missing TraceLens checkout, same failure on base); base-vs-head differential on randomized inputs for report rendering, AIPerf JSON, the replay serving env and KV rank selection (18,500 cases, 0 mismatches) | Base: bb2da63 | Head: aa09cf4 | Branch head e40a4e0 merges main into the reviewed head: baseline file only, non-baseline diff identical to the reviewed head

LGTM

@chaojhou
chaojhou merged commit b960813 into main Oct 22, 2026
40 checks passed
@chaojhou
chaojhou deleted the refactor/chenyi/cc20-actions-executors-3 branch October 22, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-exception Waives the PR diff budget; added by a maintainer with a reason in the PR description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants