Skip to content

Use Magpie's native AgentX contract for optimization - #1922

Merged
xiaofei-zheng merged 12 commits into
mainfrom
feature/magpie-agentx-clean
Oct 17, 2026
Merged

xiaofei-zheng merged 12 commits into
mainfrom
feature/magpie-agentx-clean

Conversation

@haofrank

@haofrank haofrank commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Hyperloom uses Magpie's native AgentX execution with its familiar workload flags:

HYPERLOOM_AGENTX=1 hyperloom optimize \
  --model deepseek-ai/DeepSeek-V4-Pro-0813 \
  --framework sglang --precision fp4 --tp 8 --ep 8 --conc 32 \
  --max-hours 12

Hyperloom translates the resolved flags into Magpie YAML, archives benchmark.yaml in the session, and injects --server-args / serving --extra-env through Magpie's verified launch overrides. --benchmark-config remains optional for advanced recipe and profiling settings. Resume reuses the archived workload and rejects conflicting workload flags. Custom models require --docker-image; registered recipes can supply their image. Run Hyperloom inside the serving image: this path uses local execution.

Magpie owns the server, InferenceX/AIPerf replay, profiling and cleanup. Hyperloom owns candidate generation, reviewed source/kernel patches, TraceLens analysis, and KEEP/REVERT. A session fixes its workload and CONC; only valid, unprofiled Magpie reports for that same workload can justify KEEP. GEAK results remain proposals until Critic review and canonical Magpie revalidation.

This replaces Hyperloom's AIPerf client, installer/repair path and phase-gate machinery. Related to #1675. Compatibility boundary: HYPERLOOM_AGENTX=1 selects native Magpie for new sessions; old AIPerf sessions and client-specific controls are not migrated. Ordinary benchmarks and the independent MLPerf backend retain their entrypoints. Initial native scope is single-node SGLang/vLLM, one concurrency per session; trace replay does not use CLI ISL/OSL.

Magpie is pinned to 6a1ee26f9053363d3750b43e3d5afb5d1c4ce84e. Native AgentX uses Magpie's InferenceX resolver and default revision 408c015be4b22d14c69518643609669405507077, including the inferencex-e2e/ layout. Hyperloom's synthetic INFERENCEX_PATH no longer overrides that selection; explicit benchmark.inferencex_path or MAGPIE_INFERENCEX_PATH remain supported. Ordinary benchmark/MLPerf installation and preflight retain their compatible 3d5581562f643f9bdeb8410cd924e2c70906c966 revision and patches. Launch/resume documentation and an advanced YAML example are included.

MLPerf still rejects interrupted or incomplete runs. Native AgentX carries measured per-GPU power into baseline and KEEP budgets; sampling follows AIPerf's measured replay, including outstanding responses. The operator docs list native AgentX's unsupported flags and require a separate session for each concurrency.

Accepted launch changes remain relative to the verified baseline recipe unless replacement was explicitly requested. Explore and patch revalidation apply accepted changes once, preserving unrelated recipe/operator settings across successive KEEPs. Appended-only removals are handled locally; shared recipe options still reach Magpie's removal validation. Native server-log observations now reach the existing prefix-cache baseline gate, and GEAK receives explicit environment assignments and unsets as well as Magpie's runtime snapshot. Packaged installs include the Magpie capability-check script.

Validation:

  • 1,266 focused CPU regression tests pass, covering successive KEEP/replay and patch revalidation, SGLang/vLLM cache gates, GEAK environment fidelity, native/synthetic InferenceX selection, CLI controls and shared benchmark paths.
  • Independent checks against pinned Magpie's actual launch implementation confirm appended-option removal across consecutive Explore rounds and explicit environment assignments/unsets in GEAK handoff. GPU execution is substituted in the executor tests.
  • Ruff, formatting, all seven architecture contracts and the code-metrics gate pass, with no complexity-baseline increase. A built wheel passes the repository's contents check and includes the installer capability check.
  • Native GPU execution and a complete Coordinator/GEAK optimization session remain unvalidated on this branch. Current-head Linux CI is tracked by the PR checks.

The large deletion is the retired AIPerf implementation and its implementation-specific tests. Its supported acceptance, rollback and profiling contracts are covered at the Magpie boundary. This PR addresses one concern: making Magpie the sole native AgentX execution owner.

Size exception: the total diff includes removal of the retired shell client and its tests. Switching callers and removing the old execution owner together completes the replacement. The size-exception label covers total diff size only; all code-metrics limits remain enforced. InferenceX checkout policy is separated from preflight telemetry, and KEEP reuses its already-composed controls rather than rebuilding them.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Code metrics gate: PASSED

Judged: the 130 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 72 +0
Cognitive complexity fails > 30 0 0 0 280 -4
Function length (lines) fails > 80 0 0 0 443 -6
Nested block depth fails > 5 0 0 0 26 -1
Parameter count fails > 5 0 0 0 560 -3
Module length (lines) warns > 800, fails > 1200 0 0 0 53 +0
Duplicated lines per file fails > 0 0 0 0 118 +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): 4

Module Lines Limit
src/hyperloom/inference_optimizer/cli/bootstrap.py 808 warns > 800
src/hyperloom/inference_optimizer/cli/parser.py 1192 warns > 800
src/hyperloom/orchestrator/actions/executors/_subprocess_kill.py 1192 warns > 800
src/hyperloom/orchestrator/actions/executors/benchmark_result.py 968 warns > 800

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

Unit Dimension Base Now
src/hyperloom/inference_optimizer/cli/__init__.py:1811 _reexport_session_environment Function length (lines) 112 112
src/hyperloom/inference_optimizer/cli/__init__.py:2377 _resolve_agent_lineup Function length (lines) 89 89
src/hyperloom/inference_optimizer/cli/__init__.py:2272 _resolve_run_topology Function length (lines) 92 92
src/hyperloom/inference_optimizer/cli/__init__.py:1925 _resume_session Function length (lines) 171 171
src/hyperloom/inference_optimizer/cli/__init__.py:2098 _seed_fresh_session Function length (lines) 183 172
src/hyperloom/orchestrator/actions/executors/explore.py:770 ExploreExecutor.__call__ Cognitive complexity 377 374
src/hyperloom/orchestrator/loop/intent_router.py:858 IntentRouter.handle_delegate Cognitive complexity 41 41
src/hyperloom/orchestrator/loop/writeback.py:3521 WritebackCollaborator.build_env_spec Cognitive complexity 37 37
src/hyperloom/orchestrator/phases/kernel.py:1219 KernelPhase._run_geak_kernel_phase Cognitive complexity 132 132
src/hyperloom/orchestrator/actions/executors/_workload_envs.py:1252 materialize_config_with_envs Cyclomatic complexity 111 111
src/hyperloom/orchestrator/actions/executors/explore.py:770 ExploreExecutor.__call__ Cyclomatic complexity 78 78
src/hyperloom/orchestrator/phases/kernel.py:1219 KernelPhase._run_geak_kernel_phase Cyclomatic complexity 52 52
src/hyperloom/inference_optimizer/cli/__init__.py:2484 _run_optimize Function length (lines) 278 278
src/hyperloom/inference_optimizer/cli/bootstrap.py:417 _seed_shared_state Function length (lines) 156 156
src/hyperloom/inference_optimizer/cli/parser.py:178 _build_parser Function length (lines) 1016 1015
src/hyperloom/orchestrator/actions/executors/_workload_envs.py:1252 materialize_config_with_envs Function length (lines) 928 926
src/hyperloom/orchestrator/actions/executors/benchmark_result.py:606 extract_benchmark_measurement Function length (lines) 135 135
src/hyperloom/orchestrator/actions/executors/explore.py:770 ExploreExecutor.__call__ Function length (lines) 1156 1142
src/hyperloom/orchestrator/actions/executors/explore.py:587 filter_baseline_noop_variants Function length (lines) 112 112
src/hyperloom/orchestrator/loop/intent_router.py:858 IntentRouter.handle_delegate Function length (lines) 181 181
src/hyperloom/orchestrator/loop/proposals.py:333 ProposalsCollaborator.materialize_approved_proposal Function length (lines) 125 125
src/hyperloom/orchestrator/loop/writeback.py:3521 WritebackCollaborator.build_env_spec Function length (lines) 111 111
src/hyperloom/orchestrator/loop/writeback.py:4556 WritebackCollaborator.validate_geak_via_geak_harness Function length (lines) 187 187
src/hyperloom/orchestrator/phases/kernel.py:1219 KernelPhase._run_geak_kernel_phase Function length (lines) 487 483
src/hyperloom/orchestrator/phases/kernel.py:2117 KernelPhase.promote_geak_from_candidate Function length (lines) 167 167

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

61 findings in files this change does not touch

Outside this change (informational): 61

Unit Dimension Baseline Now
src/hyperloom/orchestrator/enablement/recipe/projections.py project_launch_evidence Cognitive complexity absent 36
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/hyperloom_kb/schema.py FieldDeclaration.__post_init__ Cognitive complexity absent 32
src/kernelforge/cli/forge_loop_command.py _prepare_measurement_driver Cognitive complexity absent 36
src/kernelforge/cli/forge_loop_command.py _read_kb_warm_start Cognitive complexity absent 40
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_kb/tests/test_cli.py Duplicated lines per file absent 18
src/hyperloom_kb/tests/test_global_identity_and_pull.py Duplicated lines per file absent 13
src/hyperloom_kb/tests/test_local_state.py Duplicated lines per file absent 18
src/hyperloom/inference_optimizer/multi_node/cli.py _restart_multinode Function length (lines) absent 107
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 90
src/hyperloom_kb/http_service.py RequestHandler._dispatch Function length (lines) absent 91
src/hyperloom_kb/sync.py GlobalSync.pull Function length (lines) absent 86
src/kernelforge/cli/forge_loop_command.py _RunReporter.build_result Function length (lines) absent 91
src/kernelforge/cli/forge_loop_command.py _prepare_measurement_driver Function length (lines) absent 140
src/kernelforge/cli/forge_loop_command.py _read_kb_warm_start Function length (lines) absent 154
src/kernelforge/loop/knowledge_integration.py _measure_warmstart_field Function length (lines) absent 83
src/kernelforge/loop/runner.py IterationLoop._close_iteration Function length (lines) absent 135
src/kernelforge/loop/runner.py IterationLoop._collect_session_candidate Function length (lines) absent 187
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 104
src/kernelforge/loop/runner.py IterationLoop._run_supervisor_review Function length (lines) absent 88

...and 36 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.

@haofrank haofrank added the size-exception Waives the PR diff budget; added by a maintainer with a reason in the PR description label Oct 15, 2026
Comment thread src/hyperloom/orchestrator/actions/executors/profile.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/profile.py Fixed
run = asyncio.create_task(coordinator.phase_kernel._revalidate_geak_candidate(reason="unit"))
await _actual_verdict(coordinator, "approve")
with pytest.raises(asyncio.CancelledError):
await run

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Keeping this: await run waits for the task and propagates asyncio.CancelledError into pytest.raises. It is the assertion point for cancellation, not an unused expression. The cancellation/resume regression passes.

Comment thread src/hyperloom/orchestrator/actions/executors/_grid_runner.py Fixed
envs[str(k)] = str(v)
from ._workload_envs import pin_mlperf_round_concurrency, prepend_launch_path
base_envs = _apply_variant_env(envs, variant, base_extra_envs, base_unset_envs)
from ._workload_envs import pin_mlperf_round_concurrency

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This function-local import already exists on main. The reported return path depends on the type-only Coordinator import in collaborator.py, so it does not form an executable import cycle. Keeping the shared concurrency helper in its current owner.

Comment thread src/hyperloom/orchestrator/actions/executors/baseline.py Fixed
log.error("grid_runner: %s; failing this benchmark", eval_bounds_msg)
return PreparationFailure(EVAL_PROBE_UNPATCHABLE_RETURNCODE, eval_bounds_msg)
log.warning("grid_runner: %s", eval_bounds_msg)
from ._workload_envs import prepare_agentx_runtime

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This preparation step was moved from _run_magpie; its _workload_envs import remains deferred until the function runs. The return path crosses collaborator.py's TYPE_CHECKING import, which is not executed. No runtime cycle was introduced.

Comment thread src/hyperloom/orchestrator/actions/executors/explore.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/integrate_patch.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/profile.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/profile.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/profile.py Fixed
Comment thread src/hyperloom/orchestrator/actions/executors/baseline.py Fixed
run = asyncio.create_task(coordinator.phase_kernel._revalidate_geak_candidate(reason="unit"))
await _actual_verdict(coordinator, "approve")
with pytest.raises(asyncio.CancelledError):
await run

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Keeping this: await run waits for the task and propagates asyncio.CancelledError into pytest.raises. It is the assertion point for cancellation, not an unused expression. The cancellation/resume regression passes.

Comment thread src/hyperloom/orchestrator/actions/executors/profile.py Fixed
@haofrank
haofrank marked this pull request as ready for review October 16, 2026 00:41

@jiaqiang-dot-liu jiaqiang-dot-liu 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 #1922 -- Use Magpie's native AgentX contract for optimization

What it does: Hyperloom carried its own AgentX execution stack -- a shell AIPerf client, a phase
gate, an installer/repair path and a corpus-rules mirror -- alongside Magpie, which already owns
server launch, replay, profiling and cleanup, so the two had to be kept in step by hand. This PR
deletes Hyperloom's copy and makes Magpie the sole owner: HYPERLOOM_AGENTX=1 now translates the
ordinary workload flags into a native Magpie YAML (or --benchmark-config supplies one), the
resolved workload is archived as <session>/benchmark.yaml and re-read on resume, candidates are
composed into benchmark.agentx.launch_overrides instead of into env and extra-args, and KEEP
evidence comes from Magpie's public benchmark_report.json validity verdict rather than from a
parsed AIPerf export. Profile rounds become diagnostic-only and can never justify a KEEP; reviewed
GEAK source products get a new revalidation phase that routes through Critic review and the existing
integrate_patch executor.

Blocking issues: 1

  1. [D11] Magpie's server-launch receipt is written under effective_env and read back under
    runtime_environment, so the GEAK handoff discards the accepted server environment [verified]
    Problem: native_launch_evidence takes the environment off Magpie's server_launch as
    launch["effective_env"] and republishes that same dict verbatim as magpie_server_launch
    (src/hyperloom/inference_optimizer/agentx/report.py:80 and :107 -- and
    test_magpie_agentx_contract.py:234 asserts the republication is verbatim through the real
    BaselineExecutor). seed_native_geak_proxy reads that object back out and takes the
    environment as evidence.get("runtime_environment")
    (src/hyperloom/inference_optimizer/agentx/geak_proxy.py:82). It is one object: baseline.py:557
    attaches it to result["launch_evidence"], writeback.py:3419 shallow-copies the evidence
    without touching magpie_server_launch, kernel.py:1297 reads it back off
    current_best_measurement, and kernel.py:1483 hands it to seed_native_geak_proxy. The two
    names cannot both be Magpie's. A tree-wide grep finds runtime_environment used as a mapping
    key in exactly one production line (geak_proxy.py:82) and effective_env in exactly one
    (report.py:80).
    Impact: if Magpie's key is effective_env, runtime is PATH-only, and because geak_proxy.py:90
    does config.update({..., "extra_envs": runtime}) -- an overwrite, not a merge -- the handoff
    also discards the cumulative accepted environment it already carried from
    baseline_env_spec.config (kernel.py:1468; writeback.py:3504 documents that field as "cumulative
    server args + env vars"). handoff["accepted_env"] likewise comes back empty, and both are
    serialized to geak/handoff.json (kernel.py:1486-1488), so GEAK tunes kernels against a server
    configuration missing every environment variable the accepted launch ran with, silently and on
    every native session -- seed_native_geak_proxy raises rather than returning when the receipt is
    absent, so this is the live branch, not a fallback. If instead Magpie's key is
    runtime_environment, report.py:80's bare subscript raises KeyError: 'effective_env' on the
    first native baseline that produces launch evidence. One of the two is live; neither is
    acceptable. CI is green over it because the two new test files encode the two different names and
    never cross: test_magpie_agentx_contract.py:133 authors effective_env and drives the real
    executor but never calls seed_native_geak_proxy, while
    test_geak_handoff_workload_contract.py:135 hand-writes a magpie_server_launch carrying
    runtime_environment and no effective_env -- a receipt the production writer cannot produce,
    and one that would have raised KeyError had native_launch_evidence built it (T1).
    Action: read the key name off Magpie at the pinned 6a1ee26f9053363d3750b43e3d5afb5d1c4ce84e and
    use that one name in both places -- better, have seed_native_geak_proxy consume the
    requested_server_env that native_launch_evidence already publishes rather than re-deriving it
    from the raw receipt -- merge rather than overwrite config["extra_envs"], and add one test that
    carries a receipt from native_launch_evidence through to handoff["accepted_env"] so the two
    halves can no longer drift.
    One limit, stated rather than hidden: Magpie is external and its server_launch schema is not
    vendored or documented in this tree, so neither I nor the independent reviewer could rule out
    that Magpie emits both keys, in which case this degrades to two spellings of one field. The
    in-repo evidence points the other way -- each of the two new fixtures carries exactly one of the
    keys and omits the other -- and the first action above settles it either way.

Checked: src/hyperloom/inference_optimizer/agentx/{report.py,geak_proxy.py,runtime.py,deploy.py,mapping.py},
src/hyperloom/inference_optimizer/cli/{benchmark_config.py,init.py,parser.py,bootstrap.py,preflight.py},
src/hyperloom/inference_optimizer/{runtime_environment.py,session/manifest.py,assets/check_magpie.py},
src/hyperloom/common/{benchmark_config.py,perf_metric.py,agentx_workload.py,env_safety.py},
src/hyperloom/orchestrator/actions/executors/{magpie_agentx.py,benchmark_config.py,_workload_envs.py,_grid_runner.py,_grid_base.py,baseline.py,profile.py,benchmark_result.py,_accuracy_gate.py,integrate_patch.py,_integrate_attempt.py,_kv_metrics.py},
src/hyperloom/orchestrator/phases/{geak_native_revalidation.py,geak_rebench.py,geak_adoption.py,kernel.py},
src/hyperloom/orchestrator/loop/{writeback.py,intent_router.py,proposals.py},
src/hyperloom/orchestrator/trace_analysis/{trace_selfcert.py,_trace_rank.py},
src/hyperloom/inference_optimizer/breakdown/reporters/cross_section.py, AGENTS.md, .importlinter,
docs/{components/magpie.md,reference/environment-variables.md,compatibility.rst}; symbols
native_launch_evidence, agentx_measurement, read_agentx_report, magpie_server_launch, effective_env,
runtime_environment, effective_argv, seed_native_geak_proxy, build_env_spec, constraint_fields,
CONSTRAINT_FIELDS, benchmark_backend, workload_identity, agentx_backend, native_agentx_veto,
_measurement_succeeded, materialize_benchmark_config, materialize_variant, apply_launch_changes,
build_agentx_workload_spec, agentx_client_script, geak_overlay_is_loadable, apply_runtime_override,
submission_valid. Enumeration scope: tree-wide git grep under src/ for every one of the 185
identifiers the diff adds, and for the nine deleted aiperf symbols -- not a walk of the diff's frame.
| Ran: bash .claude/skills/review-pr/fetch.sh 1922; the chain agentx_measurement ->
native_launch_evidence -> seed_native_geak_proxy driven directly on a Magpie-shaped report, twice and
independently (requested_server_env carries the variables while accepted_env comes back '' and
extra_envs is overwritten to PATH-only); ruff check --select C901 --config lint.mccabe.max-complexity=20 over the 50 changed non-test src/*.py files at head and at the merge
base -- 26 units over 20 on both sides and the only movements are downward
(ProfileExecutor.__call__ 66 -> 47, _run_once 56 -> 54), so the complexity ceiling is clear;
gh pr view 1922 --json isDraft,additions,deletions.
SKIPPED: pytest -- this reviewer is on Windows and cli/kb.py imports fcntl at module scope, so
the repo's suites cannot be collected here; the test-behaviour axis is therefore checked by reading
the added tests and by calling the production functions directly, not by running the suite. The full
matrix is green at the current head in CI.
| Base: a3fc0ba | Head: 26a5cfd

@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 #1922 -- Use Magpie's native AgentX contract for optimization

What it does: Hyperloom carried its own AgentX execution stack -- a shell AIPerf client, a phase gate, an installer/repair path and a corpus-rules mirror -- beside Magpie, which already owns server launch, replay, profiling and cleanup. This PR deletes Hyperloom's copy and makes Magpie the sole owner: HYPERLOOM_AGENTX=1 translates the ordinary workload flags into a native Magpie YAML, the resolved workload is archived as <session>/benchmark.yaml and re-read on resume, candidates are composed into benchmark.agentx.launch_overrides instead of into env and extra-args, and KEEP evidence comes from Magpie's benchmark_report.json validity verdict. Profile rounds become diagnostic-only, and reviewed GEAK source products route through a new revalidation phase. Read against Magpie at the pinned 6a1ee26f, the core contract holds: agentx_measurement is strictly more conservative than Magpie's own verdict, latency units are seconds on both sides, "a profile round can never justify a KEEP" is enforced independently by Magpie (benchmarker.py:615-623) and by Hyperloom (report.py:26-31), and Magpie's launch receipt carries both effective_env and runtime_environment (agentx_launch.py:549, :554), so report.py and geak_proxy.py each read a field Magpie writes.

Blocking issues: 4

  1. [free:mlperf-submission-veto-deleted] Deleting the submission_valid veto makes an interrupted or incomplete MLPerf agentic round a usable measurement [verified]
    Problem: is_valid_measurement lost the block that refused a round whose submission_valid was False (base benchmark_result.py:795-807). At head it special-cases magpie_agentx and otherwise falls through to completed > 0 (src/hyperloom/orchestrator/actions/executors/benchmark_result.py:792-803). The MLPerf backend this PR keeps still produces the verdict: map_mlperf writes "submission_valid": not reasons, with interrupted when state == "interrupted" and incomplete_run when complete is not True (src/hyperloom/inference_optimizer/agentx/mapping.py:123-131), and _merge_raw_result still copies it onto the measurement (benchmark_result.py:524). The MLPerf YAML sets only benchmark_script (_workload_envs.py:507) and no agentx: block, so its report takes the non-native branch and reaches this gate. mlperf_agentic_client.sh:240-257 exits non-zero only when the harness itself fails, so a summary that records an interrupted or incomplete run is mapped and exits 0, and served_complete_protocol -- consulted only on a non-zero exit (baseline.py:3849, _grid_runner.py:1815) -- never sees it. src/hyperloom/orchestrator/actions/executors/benchmark_result.py:792
    Impact: with HYPERLOOM_AGENTX=1 HYPERLOOM_AGENTIC_BACKEND=mlperf, a round whose harness summary says interrupted or incomplete now counts as valid and can anchor the baseline or win a KEEP, silently. Running the head and base trees on {"output_throughput": 1234.0, "completed_requests": 500, "submission_valid": False, "submission_invalid_reasons": ["interrupted"]}: base returns False, head returns True. The description says the MLPerf backend retains its entrypoints and states no change to its validity rule.
    Action: keep the verdict honoured for the backend that still produces it -- refuse a measurement whose submission_valid is False before the magpie_agentx branch -- or remove submission_valid / submission_invalid_reasons from map_mlperf and the breakdown readers, so no field is written that nothing enforces.
  2. [free:native-agentx-power-unmeasured] A native AgentX session with a power budget stops right after its baseline [verified]
    Problem: extract_benchmark_measurement returns agentx_measurement(report) (src/hyperloom/orchestrator/actions/executors/benchmark_result.py:636) before the measurement dict that calls _round_gpu_power (:674, the only call site), so a native measurement carries no gpu_power_by_gpu_w. power_veto_reason fails closed on a missing per-card reading and returns power_unmeasured (src/hyperloom/common/perf_metric.py:386-387). baseline_budget_stop_reason runs that veto on the baseline itself and returns baseline_over_power_budget (src/hyperloom/orchestrator/measurement/baseline_budget.py:63-82), which writeback.py:2060 turns into the session's stop reason. The launch-time guard written to prevent this, power_budget_unmeasurable_error, refuses multi-node sessions, scriptable frameworks and an unavailable sampler, but has no native-AgentX clause (src/hyperloom/inference_optimizer/cli/bootstrap.py:215-241). At base there was no early return, so AgentX rounds were stamped. src/hyperloom/orchestrator/actions/executors/benchmark_result.py:636
    Impact: HYPERLOOM_AGENTX=1 hyperloom optimize ... --max-power-w 3000 on a single-node SGLang session passes the launch guard, measures a full baseline, logs "baseline does not satisfy the power budget (power_unmeasured) ... reported no per-GPU power" and stops -- the outcome the guard's own docstring says it exists to prevent. Not stated in the description.
    Action: stamp the measured power onto the native measurement before returning (call _round_gpu_power on the native branch), or, if Magpie's managed launch leaves the sampler nothing to read, add a native-AgentX clause to power_budget_unmeasurable_error so the session refuses at launch instead of after a baseline.
  3. [D9] remove_args is applied locally and also forwarded to Magpie, where it is matched against a different argv and errors on zero matches [verified]
    Problem: apply_launch_changes strips the names from Hyperloom's own append_args through compose_server_args(..., remove_args=...) and then accumulates the same names into launch["remove_args"] for Magpie (src/hyperloom/orchestrator/actions/executors/magpie_agentx.py:58-68). Magpie applies remove_args to the recipe's canonical launcher argv and raises unless each name matches exactly one existing option (Magpie agentx_launch.py:245-252 at the pinned 6a1ee26f). A flag the session's accepted stack appended lives in append_args, not in that argv. Driving head apply_launch_changes with an accepted --cuda-graph-max-bs 256 and then remove_args=["--cuda-graph-max-bs"] yields append_args: ["--mem-fraction-static", "0.85"] and remove_args: ["--cuda-graph-max-bs"]; feeding those overrides to Magpie's apply_launch_args with an SGLang launcher argv that does not carry the flag raises remove_args must match exactly one existing option: --cuda-graph-max-bs. src/hyperloom/orchestrator/actions/executors/magpie_agentx.py:68
    Impact: SKILL.md:1010-1013 -- a file this PR edits -- still tells the Decide role to emit exactly this shape, with {"name": "remove_cuda_graph_max_bs", "remove_args": ["--cuda-graph-max-bs"]} as the worked example, and GridVariant.remove_args carries it through (_grid_base.py:36). Every ablation of a flag the session or the operator appended is refused at server launch, so a documented candidate family cannot run on the native path and each attempt costs a round.
    Action: forward to Magpie only the names that occur in the recipe's launcher argv, and keep the local strip for the names Hyperloom appended -- they are different operations on different argv and should not share one list. Add a test that drives an ablation of an appended flag through materialize_variant and checks the overrides against Magpie's apply_launch_args.
  4. [X3] The loop doc tells operators to pass --enable-conc-sweep under AgentX, which now aborts the default backend at startup [verified]
    Problem: docs/conceptual/optimization-loop.md:459 (not touched by this PR) reads "Under AgentX the sweep is off unless --enable-conc-sweep is passed, since each rung is a 3600 s window and the session grades at a fixed CONC; SWEEP then records a disabled skip." On the default native backend (agentic_backend defaults to magpie), configure_benchmark now raises ValueError("AgentX concurrency is fixed per session; create a session for each CONC") for that flag (src/hyperloom/inference_optimizer/cli/benchmark_config.py:106). The same validator newly rejects --isl, --osl, --profile-osl, --max-model-len, --reference-script, --quantize, --quantize-scheme, a framework other than sglang/vllm, more than one node, and ISL/OSL/RANDOM_RANGE_RATIO/MAX_MODEL_LEN/EP_SIZE through --extra-env (:99-121); no in-tree operator doc or --help text names these rejections. docs/conceptual/optimization-loop.md:459
    Impact: an operator following the loop doc on a native AgentX session gets a startup abort, and the doc describes a SWEEP skip path native sessions never reach.
    Action: correct that paragraph to say the sweep is unavailable on native AgentX and that another concurrency needs its own session, and list the rejected flags where an operator meets them (the optimize help or the AgentX section of SKILL.md).

Checked: Magpie at the pinned 6a1ee26f9053363d3750b43e3d5afb5d1c4ce84e (modes/benchmark/benchmarker.py server_launch/execution_owner/diagnostic_only and _managed_agentx, result.py agentx_metrics and the benchmark_valid/publishable verdict, agentx_launch.py validate_overrides/apply_launch_args/prepare_server_launch and the receipt fields, agentx_profile_config.py, config.py TorchProfilerConfig); Hyperloom at head -- agentx/report.py, agentx/geak_proxy.py, magpie_agentx.py, cli/benchmark_config.py, common/benchmark_config.py, runtime_environment.py, benchmark_result.py (is_valid_measurement, served_complete_protocol, extract_benchmark_measurement, _merge_raw_result, _round_gpu_power), common/perf_metric.py (power_veto_reason, constraint_veto_reason), measurement/baseline_budget.py, cli/bootstrap.py (power_budget_unmeasurable_error), agentx/mapping.py (map_mlperf), assets/agentx/mlperf_agentic_client.sh, _workload_envs.py (apply_agentx_switch, prepare_agentx_runtime), phases/geak_adoption.py and geak_native_revalidation.py with their wiring in kernel.py/intent_router.py/writeback.py, SKILL.md, docs/conceptual/optimization-loop.md | Ran: head-vs-base is_valid_measurement on an interrupted MLPerf measurement (base False, head True); head apply_launch_changes on an accepted flag plus its ablation, and Magpie's pinned apply_launch_args on the resulting overrides (ValueError); gh api reads of Magpie at the pin. Not run: the PR's own test suite, and no GPU execution -- the description already marks native GPU execution and a full Coordinator/GEAK session as unvalidated on this branch | Base: a3fc0ba | Head: 26a5cfd

@haofrank

Copy link
Copy Markdown
Member Author

Thanks @chaojhou — fixed all four. MLPerf rejects incomplete/interrupted runs again, AgentX keeps per-GPU power for budget checks, and removing an appended flag no longer causes a second removal in Magpie. The docs now list the unsupported flags and explain that each concurrency needs its own session.

823 focused tests and the pinned Magpie contract checks pass. Also resolved the main conflict. Native GPU and full optimization-loop validation are still pending.

ensure_eval_unbound_outputs_patched,
eval_probe_targets_exist,
)
from .benchmark_config import prepare_benchmark_runtime

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

benchmark_config imports _workload_envs only inside prepare_benchmark_runtime. The return path back to _grid_runner then crosses a TYPE_CHECKING import in collaborator.py, so this is a static dependency cycle rather than an executable import cycle. Fresh-process imports and all seven architecture checks pass.

@devalshahamd

Copy link
Copy Markdown
Collaborator

Hello @haofrank @chaojhou
I have created this issue with details on all trace collection requirements for AgentX.

#1948

This also has instructions for running a torch trace folder checker that verifies the collected traces and its compatibility with TraceLens. You can use this to ensure TraceLens requirements on trace collection are satisfied.

Please verify with above script before merging this PR on a vLLM and SGLang run of top model for AgentX.

@haofrank

Copy link
Copy Markdown
Member Author

Thanks @devalshahamd for documenting the requirements. Could we address #1948 in a follow-up PR after this one merges?

We'd use Magpie's existing capture-window controls for one 256-step capture, starting 300 seconds into the measured phase. Hyperloom would apply the updated TraceLens patches and prepare the SGLang kernel shape tool, reusing its existing profiling setup. The follow-up would include vLLM and SGLang runs verified with your checker.

Would that split work for you?

@haofrank
haofrank requested a review from chaojhou October 16, 2026 22:04

@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 #1922 -- Use Magpie's native AgentX contract for optimization

What it does: Hyperloom carried its own AgentX execution stack beside Magpie, which already owns server launch, replay, profiling and cleanup. This PR deletes Hyperloom's copy and makes Magpie the sole owner: HYPERLOOM_AGENTX=1 translates the workload flags into a native Magpie YAML archived in the session, candidates are composed into benchmark.agentx.launch_overrides, and KEEP evidence comes from Magpie's benchmark_report.json verdict. Old-AgentX compatibility is intentionally dropped. Three of the previous card's four items are fixed at this head. is_valid_measurement refuses submission_valid is False again before the native branch, and map_mlperf always writes a bool. The native branch now stamps per-GPU power: I traced Magpie at 6a1ee26f, InferenceX at 408c015 and its pinned AIPerf, and AIPerf writes <output_dir>/benchmark_*/aiperf_artifacts/logs/aiperf.log with the exact (profiling) started / (profiling) complete lines _resolve_scan_logs reads. The docs and --help list the native rejections, matching the validator. The fourth item, remove_args, is fixed for explore's appended-only case but not in general; see item 1.

Blocking issues: 2

  1. [D9] The remove_args fix decides "recipe option or appended option" from a launch receipt that is absent on the grid paths, so integrate_patch raises in Magpie and explore measures the wrong config [verified]
    Problem: recipe_option_names (src/hyperloom/orchestrator/actions/executors/magpie_agentx.py:48-61) reads launch_evidence.json beside the config only when its recipe_digest matches. run_grid builds variants from per-call base YAMLs: explore_base, integrate_patch, conc_sweep_base and specialist_rebench .with_envs.yaml. Evidence is persisted only into variant_NN_* slots, so no receipt ever sits beside these YAMLs and materialize_variant (:224) always gets an empty set. That produces two failures. (a) integrate_patch applies the accepted stack's base_remove_args twice: once through materialize_benchmark_config (integrate_patch.py:4549) and again through run_grid (:4628). If the stack removed an option that only Hyperloom appended (an operator --server-args flag ablated and KEEP'd in explore), the first pass strips it locally. The second pass no longer sees it in append_args, forwards it in launch_overrides.remove_args, and Magpie's apply_launch_args raises remove_args must match exactly one existing option. (b) In explore, ablating an option present both in the recipe argv and in the appended args (--cuda-graph-max-bs 512 over the recipe's 256) is treated as appended-only, line :90. It is removed from append_args and not forwarded, so the server runs the recipe's 256 while the variant is recorded as the ablation. src/hyperloom/orchestrator/actions/executors/magpie_agentx.py:90
    Impact: (a) Once such an ablation is KEEP'd, every later native integrate_patch benchmark fails before the server starts. (b) An explore KEEP or REVERT can be decided on a launch that is not the candidate, and integrate/baseline then replay a different stack than the one measured. Both reproduce on the head code fed into the pinned Magpie apply_launch_args.
    Action: take the recipe's option set from one source, the accepted baseline's verified launch receipt, held on shared state rather than looked up beside each YAML, and pass it to every materialization. Apply the accepted stack once on the native path instead of in both materialize_benchmark_config and run_grid. Add a test that runs a KEEP'd appended-only ablation through integrate_patch and an in-both ablation through explore against Magpie's apply_launch_args.
  2. [C1] On the native path the AgentX prefix-cache-off baseline gate merged in #1884 can no longer refuse SGLang or vLLM [verified]
    Problem: this PR merged main (f2c5081), which brought in #1884's refuse_cacheless_agentx_baseline. For SGLang and vLLM that gate reads only launch_evidence.observed_server_config (disable_radix_cache is True / enable_prefix_caching is False); only the ATOM branch reads requested_server_args. On the native path, _attach_baseline_launch_evidence returns through native_launch_evidence, which hardcodes "observed_server_config": {} (src/hyperloom/inference_optimizer/agentx/report.py:95), and build_launch_evidence, the only writer of that field, never runs. Native Magpie is the default AgentX backend, so the gate is dead for both main engines. src/hyperloom/inference_optimizer/agentx/report.py:95
    Impact: --server-args "--disable-radix-cache" on SGLang, or --no-enable-prefix-caching on vLLM, reaches Magpie's append_args and effective_argv. Neither flag is in Magpie's PROTECTED_ARGS or golden-acceptance checks at 6a1ee26f. The cold-cache baseline is accepted as the anchor, and any later candidate that restores the cache is credited with the cache as a gain. That is the failure #1884 was merged to stop, and main refuses this case today. Reproduced with the head code: both baselines stay succeeded with no error_class. #1884's tests stay green only because they build evidence with observed_server_config filled in, which the native path never produces.
    Action: let the gate judge the native launch. Either prefix_cache_off_evidence reads requested_server_args / effective_argv for SGLang and vLLM as it already does for ATOM, or native_launch_evidence fills observed_server_config from Magpie's benchmark_*/server.log through observed_server_config_from_log. Add a test that feeds native-shaped evidence through refuse_cacheless_agentx_baseline.

Checked: the fix commits fa3b121, 68e0f8b and 0b41e0b, and the merge f2c5081; benchmark_result.py (is_valid_measurement, the native branch of extract_benchmark_measurement, _round_gpu_power); _subprocess_kill.py (_resolve_scan_logs, _scan_logs_increment, _RecorderFanout.note_client_phases, _build_round_recorders); _gpu_power.py and _kv_metrics.py phase tuples; magpie_agentx.py (recipe_option_names, apply_launch_changes, materialize_variant); _workload_envs.py materialize_benchmark_config; integrate_patch.py two-pass stack application; explore.py, _grid_runner.py _build_variant_yaml; agentx/report.py native_launch_evidence; _agentx_prefix_cache.py and its baseline.py call site; geak_adoption.py, geak_native_revalidation.py and kernel.py after the refactor; agentx/mapping.py map_mlperf; docs and --help; Magpie at 6a1ee26f (workspace.py, agentx_runtime.py, agentx_launch.py PROTECTED_ARGS / apply_launch_args / _validate_golden_launch); InferenceX 408c015 agentic replay.py and its pinned AIPerf (timing/phase/runner.py, config_defaults.py) | Ran: head code on the real nested Magpie layout with amd-smi mocked (power sampled only between (profiling) started and (profiling) complete, giving per-GPU readings); head apply_launch_changes / materialize_variant / materialize_benchmark_config on appended-only, recipe-only and in-both ablations fed into the pinned Magpie apply_launch_args (integrate_patch appended-only raises; explore in-both keeps the recipe value); head native_launch_evidence plus refuse_cacheless_agentx_baseline for SGLang and vLLM with the cache-off flag (not refused); head is_valid_measurement on an interrupted MLPerf result (refused); CI at 0b41e0b (all green). Not run: GPU execution and a full optimization loop, which the description already marks as pending | Base: 79cad92 | Head: 0b41e0b


from __future__ import annotations

from hyperloom.orchestrator.actions.executors._workload_envs import prepare_grid_benchmark_config

from __future__ import annotations

from hyperloom.orchestrator.actions.executors._workload_envs import prepare_grid_benchmark_config

@xiaofei-zheng xiaofei-zheng 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 #1922 -- Use Magpie's native AgentX contract for optimization

What it does: Hyperloom carried a second AgentX execution owner beside Magpie -- its own aiperf_client.sh, phase gate, capability preflight and runtime repair -- so server launch, replay validity and trace capture were implemented twice and could disagree. This PR retires that path and makes Magpie the only native AgentX owner: one workload YAML is bound per session (HYPERLOOM_AGENTX=1 generates it from the ordinary workload flags, or --benchmark-config supplies one), archived as benchmark.yaml, and candidates are expressed as benchmark.agentx.launch_overrides while Magpie's public benchmark_report.json becomes the sole measurement and validity source.

Blocking issues: 4

  1. [free:native-profile-unpromotable] A native AgentX profile reports success and is then silently dropped by the promotion gate [verified]
    Problem: ProfileExecutor._measurement_succeeded was overridden to accept a diagnostic round via round_succeeded, and _run_native_profile returns status="succeeded" with main_trace_path / trace_input_ready / profile_captures filled. But WritebackCollaborator.is_promotable_result still gates profile on is_valid_measurement, and the new native branch there returns False for exactly this round. src/hyperloom/orchestrator/actions/executors/benchmark_result.py:796 against src/hyperloom/orchestrator/loop/writeback.py:896
    Impact: _promote_profile never runs for a native session, so last_profile_trace, last_profile_launch_evidence_path, last_profile_status, last_profile_workload and last_trace_analyze are never updated. request_handlers.py:3738 calls state.last_profile_trace "the only source" for the fusion/kernel lane, so TraceLens analysis, roofline re-anchoring and the kernel phase run on an empty or stale trace while the executor reports the round succeeded. Nothing is logged.
    Action: align the gate with the executor -- accept round_succeeded for a profile task in is_promotable_result, and add the test that carries a diagnostic_only native profile result through it.

  2. [free:runner-type] The generated native YAML pins the real board as runner_type, not the Magpie runner label [verified]
    Problem: benchmark["runner_type"] = args.gpu_type writes the probed board, while args.gpu_type is deliberately the real GPU and os.environ["GPU_TYPE"] carries the runner label that _gpu_runner_type derived from it. src/hyperloom/inference_optimizer/cli/benchmark_config.py:159
    Impact: on MI308X and MI325X, _gpu_runner_type maps to mi300x and cli/__init__.py:2154 prints "WARN: mi308x uses mi300x as Magpie runner_type (... Magpie has no sglang_mi308x.sh / vllm_mi308x.sh yet)" immediately followed by "Magpie runner : mi300x (will inject runner_type into Magpie YAML)" -- and then the YAML carries runner_type: mi308x, so Magpie resolves a launch script this repo states does not exist and the baseline cannot boot. The legacy path is unaffected: _workload_envs.py:1344 takes the label from GPU_TYPE. test_agentx_cli_config.py:88 asserts only mi355x, the one board where the two labels coincide.
    Action: write _gpu_runner_type(args.gpu_type) and extend the test to a board where the two differ.

  3. [X3] The GPU-power documentation still describes the pre-PR measured-phase window [verified]
    Problem: "only while the round is in its measured phase (from server ready, and from AIPerf's measured-phase line under AgentX, until the client exits or the eval starts)". Under native AgentX this diff maps server-ready to boot rather than measured (_build_round_recorders(ready_phase=...)), so sampling no longer starts at server ready, and it adds _AGENTX_MEASURED_END_MARKERS = ("(profiling) complete",) with a finished phase that ends the window before the client exits. docs/conceptual/optimization-loop.md:256 against src/hyperloom/orchestrator/actions/executors/_subprocess_kill.py:265,913,1108
    Impact: the one paragraph that defines which samples enter gpu_power_avg_w describes a different window than the code, for the backend the description says now carries measured per-GPU power into baseline and KEEP budgets. An operator reading it cannot tell whether a boot-phase reading is included. Single copy; the same file is edited by this PR for the conc-sweep paragraph.
    Action: restate the window for native AgentX -- sampling starts at the measured-phase line only, and ends on (profiling) complete.

  4. [X5] HYPERLOOM_BENCHMARK_CONFIG is an operator-reachable knob that reaches no documentation [verified]
    Problem: the new variable is honoured straight from the ambient environment -- source = getattr(args, "benchmark_config", None) or benchmark_config_path() -- so exporting it alone selects the native workload and turns on AgentX grading (confirmed: agentx_enabled() returns True with only the export set). It appears in no .md/.rst, including docs/reference/environment-variables.md, which this PR edits, and the description does not mention it. src/hyperloom/inference_optimizer/cli/benchmark_config.py:34, src/hyperloom/common/benchmark_config.py:15
    Impact: X5's subprocess-handoff exemption does not apply, because the CLI reads it from the operator's environment rather than only writing it for its own children (_ray_runtime.py:441 also forwards it to Ray workers). configure_benchmark meanwhile rejects the same name in --extra-env with "Use --benchmark-config to select the workload YAML", so the two surfaces disagree about whether an operator may set it.
    Action: document it in docs/reference/environment-variables.md with its unset default, or declare it internal in the description and make the CLI ignore an ambient value.

SKIPPED: V4 -- openprs.txt carries five # PARTIAL: lines (#1032 #1154 #1276 #1675 #1869 compared on their first 100 files only); #1924 overlaps 13 files including _workload_envs.py and cli/parser.py and was not compared in full. Conflicting in-flight work on those paths is therefore unchecked.

Checked: common/{benchmark_config,perf_metric,agentx_workload}.py | cli/{benchmark_config,init,parser,bootstrap,preflight}.py | inference_optimizer/{inferencex_checkout,runtime_environment,session/manifest}.py | agentx/{report,geak_proxy,runtime,preflight,deploy,mapping}.py | executors/{magpie_agentx,benchmark_config,benchmark_result,baseline,profile,explore,_grid_runner,_grid_base,_workload_envs,_subprocess_kill,_accuracy_gate,_agentx_prefix_cache,_gpu_power,integrate_patch,report}.py | phases/{geak_native_revalidation,geak_adoption,geak_rebench,kernel}.py | loop/{writeback,proposals,intent_router,dispatcher}.py | docs/{components/magpie,conceptual/optimization-loop,how-to/optimize,reference/environment-variables}.md | assets/{install.sh,check_magpie.py,configs/agentx_sglang.yaml} | Ran: agentx_measurement + is_valid_measurement on a diagnostic Magpie report (round_succeeded True / valid_measurement False / is_valid_measurement False); gpu_runner_type over mi300x,mi308x,mi325x,mi355x; agentx_enabled() with only HYPERLOOM_BENCHMARK_CONFIG exported; scripted reader-count over every new top-level symbol; head-tree sweep for AIPERF_CLIENT_SCRIPT / map_aiperf / CANONICAL* / _INFERENCEX_REF_DEFAULT / agentx.repair / _agentx_timeouts (no survivors) | Base: 79cad92 | Head: da37a3e

@xiaofei-zheng

Copy link
Copy Markdown
Collaborator

Correction to my review above: two of the four items do not meet the blocking bar and I am withdrawing them, and the scope of item 1 was overstated.

Withdrawn — 3 (docs/conceptual/optimization-loop.md:256). The sentence lists two start triggers conjunctively ("from server ready, and from AIPerf's measured-phase line under AgentX"). Under native AgentX only the second one now fires, which makes the prose incomplete rather than contradicted — the case X3 exempts. Not blocking.

Withdrawn — 4 (HYPERLOOM_BENCHMARK_CONFIG undocumented). I classified it as an operator knob because the CLI honours an ambient value. The intended surface is clearly --benchmark-config, with the variable acting as the handoff to workers (hence its entry in SAFE_ENV_KEYS). No behaviour is wrong. Not blocking.

Narrowed — 1 (native profile not promotable). The defect is real, but it does not affect the roofline path: RooflineExecutor builds its profile sub-task inline and writes last_profile_trace / last_profile_status / record_trace_analyze itself at roofline.py:1180-1184, never reaching is_promotable_result. What breaks is the standalone profile action (protocol/action_surfaces.py:259, "lightweight roofline alternative — torch_profiler trace only"): it is dispatched as a profile-kind task, is_promotable_result gates it on is_valid_measurement, and a native AgentX profile is diagnostic_only by construction, so that gate is always False and _promote_profile never runs. The action's only purpose is to refresh the trace, so it is a no-op in a native session while reporting success. My earlier claim that roofline re-anchoring is also starved was wrong.

Items 1 (as narrowed) and 2 (runner_type) stand. A fix for both follows on this branch.

Magpie stamps a profiled replay diagnostic_only, so a native AgentX profile is
never a valid measurement. ProfileExecutor already accepts the round on
round_succeeded, but is_promotable_result still gated the profile lane on
is_valid_measurement, so _promote_profile never ran and last_profile_trace was
never refreshed while the executor reported success.

runner_type must carry the Magpie runner label, not the probed board: Magpie
resolves {framework}_{runner_type}.sh and ships none for mi308x or mi325x, which
is why $GPU_TYPE already holds the derived value.
@xiaofei-zheng

Copy link
Copy Markdown
Collaborator

Pushed aba9556 with both fixes and their regression tests.

  • writeback.is_promotable_result: a profile task is now accepted on round_succeeded, matching ProfileExecutor._measurement_succeeded. A diagnostic measurement still cannot anchor a baseline, and a non-succeeded measurement_status is still refused.
  • _generated_agentx_benchmark: runner_type is now _gpu_runner_type(args.gpu_type).

Tests: test_native_agentx_profile_promotes_its_trace and test_native_agentx_profile_measurement_still_cannot_anchor_a_baseline in test_profile_and_kernel_handlers.py, and a parametrised mi308x/mi325x/mi355x case in test_agentx_cli_config.py. I could not execute them locally (Windows; these modules import fcntl), so they are unrun outside CI — I verified both fixes by calling is_promotable_result and _gpu_runner_type directly. Please confirm the new tests are green in this run.

@xiaofei-zheng
xiaofei-zheng dismissed their stale review October 17, 2026 03:11

Both blocking items are fixed on this branch in aba9556 and CI is green at that head; two of the four original items were withdrawn in a follow-up comment.

@xiaofei-zheng xiaofei-zheng 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.

No blocking issues remain.

Both items from my earlier review are fixed in aba9556, and the other two were withdrawn as not meeting the blocking bar (see the correction comment above). CI is green at that head: 33 checks pass, 7 skipped, all 12 test shards success. The py3.10 shard totals went 25583 -> 25588, which is exactly the five new test items, so the added tests were collected and run rather than skipped.

Checked: the native/synthetic dispatch at all three executors (baseline materialize_benchmark_config / _after_materialize_config / _preflight_server_argv, _build_variant_yaml, ProfileExecutor); the KEEP path through native_agentx_veto and CONSTRAINT_FIELDS into current_best / baseline_perf; apply_launch_changes removal composition across two Explore rounds against the recipe digest; read_agentx_report's None-vs-{} consumers in the accuracy gate; native_launch_evidence reachability from both attach sites; the MAGPIE_REF / InferenceX pins across install.sh, cli/preflight.py and docs/components/magpie.md; a head-tree sweep for surviving references to the retired AIPerf symbols; and the prefix-cache baseline gate reading observed_server_config from the native launch evidence.

Ran: agentx_measurement + is_valid_measurement + is_promotable_result on a diagnostic Magpie report; _gpu_runner_type across mi300x/mi308x/mi325x/mi355x; agentx_enabled() against an ambient HYPERLOOM_BENCHMARK_CONFIG; a reader-count scan over every new top-level symbol.

Note for whoever merges: the head commit aba9556 is mine, so this approval is not independent for that commit. Native GPU execution and a full Coordinator/GEAK session remain unvalidated on this branch, as the description states.

@xiaofei-zheng
xiaofei-zheng merged commit 75df551 into main Oct 17, 2026
40 checks passed
@xiaofei-zheng
xiaofei-zheng deleted the feature/magpie-agentx-clean branch October 17, 2026 03:13
fengshaoyi-amd added a commit that referenced this pull request Oct 17, 2026
…back-config-env

Main's AgentX contract change (#1922) renamed the entry point the profile
tests and the baseline YAML comments name, and re-exported
_default_baseline_config from baseline.py. The tests and comments follow
main; the alias stays removed, so the one test that used it imports
default_baseline_config from _workload_envs. The baseline keeps main's
entries, tightened with --update-baseline.
zoroyihan7 added a commit that referenced this pull request Oct 17, 2026
…ut once main's move is merged

Main's #1922 moved preflight._INFERENCEX_REF_DEFAULT to the public
inferencex_checkout.DEFAULT_REF, so the lockstep test failed on #1869's
merge with main. Read the public name when it exists, the old one until then.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

6 participants