Skip to content

Keep the Forge adapter working against the current engine; pass it lanes, new-file paths and the score aggregate - #158

Open
jiaqiang-dot-liu wants to merge 7 commits into
AMD-AGI:mainfrom
jiaqiang-dot-liu:fix/forge-engine-public-interfaces
Open

jiaqiang-dot-liu wants to merge 7 commits into
AMD-AGI:mainfrom
jiaqiang-dot-liu:fix/forge-engine-public-interfaces

Conversation

@jiaqiang-dot-liu

@jiaqiang-dot-liu jiaqiang-dot-liu commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Six commits on agents/forge and its tests, plus a merge of main, net +260 / −208 lines over nine files. Nothing outside the Forge adapter changes.

Problems solved

The adapter imported engine modules that have moved. Hyperloom's source-tree restructure (05e67da61) moved the modules the adapter imported. Against a current engine the probe reported no rewrite source languages, so every FlyDSL rewrite was refused, and initialization failed on import after the baseline had already been measured. The probe now reads the rewrite's source languages from the handshake forge-rewrite-by-flydsl --capabilities-json prints, and initialization builds the implementer from kernelforge.workflows.forge_loop.api, the interface the engine publishes for callers outside its loop. The probe imports the same names, so an engine without them (any Hyperloom revision before 05e67da61) is refused before campaign work starts.

Initialization named a gate field the engine removed. It passed interposed_driver_path, set to the driver itself. AMD-AGI/Hyperloom#2878 removed that field with the generated driver wrapper, so the initialize workflow failed with a TypeError. The argument is dropped; an engine that still has the field behaves the same with it unset.

An optimization session that created a file lost its whole change. A schema-v3 task lets a candidate add files to its declared solution tree, but only the initialization implementer was told so; forge-loop got no --commit-new-path, and the engine commits a created file only where it was told one may appear. In four 6-hour runs this rolled back 8 sessions. Every forge-loop command now carries one --commit-new-path per directory of each declared tree scope, and the probe requires the option.

A run could not choose the engine's lane count. No --lanes was passed, so every run followed the engine default. lanes joins the settings a run may override: empty still leaves the count to the engine, a positive integer is passed as --lanes. A rewrite's nested loop is not given it.

The engine searched by a different mean than Arena grades by. Arena's speedup is the geometric mean of per-case speedups; the engine judged its own KEEPs by the arithmetic mean, so it kept candidates Arena scores lower and reported a search score above its grade. Where the installed engine's forge-loop accepts --case-aggregate, the adapter passes geometric. An engine without the option still runs.

The README is updated for all of the above, and no longer describes a planning stage or planning probes: the current engine has neither.

Verification

Forge tests (tests/test_forge_*.py), with AKA_FORGE_PROBE_PYTHON pointing at an interpreter that imports the engine:

engine result
Hyperloom main at da65963f9 (contains #2878) 180 passed, 2 skipped
Hyperloom b57a20751 (the commit #2878 was based on) 180 passed, 2 skipped
no engine interpreter 173 passed, 9 skipped

On this repository's main (a8666be4) against the same current engine, 8 of those tests fail: the six test_installed_upstream_initialization cases and the two test_scratch_branch_passes_real_upstream_campaign_preflight cases.

Whole suite (pytest tests), same environment: 2554 passed, 38 failed, 5 errors on this branch; 2535 passed, 46 failed, 5 errors on main. The 43 failures and errors the two share are the same tests, none in Forge (test_magpie_workload_catalog.py, test_serving_evaluation.py, test_sikl_task_builder.py, test_benchmark_method_consistency.py, five collection errors); I have not investigated them. src/tools/sync_perf_helpers.py passes.

Real campaigns at this PR's head against Hyperloom main at da65963f9 (contains #2878), one MI300X each, short budgets chosen to exercise each workflow rather than to optimize. Every result was accepted by the final evaluation.

workflow task and target budget what happened
initialize HIP SiLU baseline, Triton target 75 min initialization passed correctness on the first attempt; the loop that follows kept two candidates; accepted at 1.022x
rewrite Triton GELU-tanh baseline, FlyDSL target 90 min the port passed on the first attempt; accepted at 1.070x (see the limit below)
optimize, lanes: 1 mHC, Triton 90 min two rounds, two candidates kept; accepted at 1.949x
optimize, lanes: 3 gated GEMM, Triton 150 min five rounds, four candidates kept; accepted at 1.603x
optimize, lanes: 3 MLA decode, Triton 150 min four rounds, four candidates kept; accepted at 7.348x

Earlier, the first five commits drove eight 6-hour optimize campaigns (fused MoE, MLA decode, gated GEMM and mHC Triton tasks, each at lanes: 1 and lanes: 3) against the #2878 branch before it merged; every result was accepted. The lane setting, --commit-new-path and --case-aggregate geometric were in use in all of these campaigns.

Limits of that evidence

  • All campaigns ran on MI300X (gfx942) with the tasks' required_arch extended locally to admit it; the tasks declare gfx950, and that edit is not part of this PR.
  • In the rewrite campaign the optimization loop that follows the port delivered nothing: its three lanes finished as its budget ran out and the engine cut the round off before merging them, so the accepted result is the port's. That is the engine's round budgeting, not the adapter; a rewrite's nested loop is not given lanes or a session budget by the adapter.
  • One run per workflow, at short budgets; these runs show the workflows work, not how well they optimize.

Hyperloom's source-tree restructure (05e67da61) moved the modules the adapter
imported. Against a current engine the probe reported no rewrite source
languages, so every FlyDSL rewrite was refused, and initialization failed on
import after the baseline had already been measured.

- The probe reads the rewrite's source languages from the capability
  handshake `forge-rewrite-by-flydsl --capabilities-json` prints, instead of
  importing an engine module.
- Initialization builds the implementer from
  `kernelforge.workflows.forge_loop.api`, the interface the engine publishes
  for callers outside its loop, and takes the usage ledger from
  `kernelforge.agent_backends.usage`. The branch for the earlier keyword
  implementer API is removed, with the option splitting it needed.
- The probe imports the same library names, so an engine without them is
  refused before campaign work starts. Hyperloom revisions before 05e67da61
  are such engines.

The engine-gated tests register their scripted provider through the engine's
provider registry instead of replacing an engine function, and no longer call
`IterationLoop._measure_baseline` or `create_campaign_config`. The scratch
repository's branch, clean tree and tracked files are checked without an
engine.
…te tree

A schema-v3 task lets a candidate add files to its declared solution tree. The
adapter told the engine so only for the initialization implementer; the
forge-loop command carried no --commit-new-path, and the engine commits a
created file only where it was told one may appear. An optimization session
that split the kernel into a new module therefore had its whole change rolled
back: in four 6-hour runs this cost 8 sessions.

build_command now passes one --commit-new-path per directory of each declared
tree scope, the allowlist initialization already used, to every forge-loop
command. The pattern builder moves beside the other candidate-bundle rules, and
the engine probe requires the option.
The adapter passed no --lanes, so every run followed the engine default of
three concurrent implementer lanes per round and a run had no way to ask for
one.

`lanes` joins the settings a run may override. Empty, the default, still leaves
the count to the engine; a positive integer is passed to forge-loop as --lanes.
The engine owns the upper bound and what a given count means. A rewrite's
nested loop is not given the setting.
Arena's speedup is the geometric mean of per-case speedups. The engine judged
its own KEEPs by the arithmetic mean, which counts a large gain on one case in
full, so it kept candidates Arena scores lower and reported a search score
above the grade it then received.

The probe now reports whether the installed engine's forge-loop accepts
--case-aggregate, and build_command passes `geometric` where it does. An
engine without the option still runs and searches by its own aggregate.
…ectory

The case added with the aggregate declaration built its second command under a
subdirectory that did not exist and failed before asserting anything. Each
engine capability is now its own parametrized case.
Initialization built the engine's gate settings with
`interposed_driver_path`, set to the driver itself. Hyperloom removed that
field together with its generated driver wrapper (AMD-AGI/Hyperloom#2878), so
against a current engine the `initialize` workflow failed with a `TypeError`
after the baseline had already been measured. An optimization campaign does
not build these settings and was not affected.

The argument is dropped. Passing the driver as its own interposer asked for
no wrapper, which is what an engine that still has the field does when the
field is left unset, so engines back to the one the probe admits keep working.

The README no longer describes a planning stage the lane count might skip, or
planning probes: the current engine has neither, and what a lane count means
was already left to the engine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant