A deterministic Workflow (JS-orchestrated multi-agent pipeline) that raises the sglang/vllm/ATOM
serving throughput of an LLM on AMD Instinct MI GPUs and the validated Radeon AI PRO R9700
(gfx1201, vLLM or SGLang only). Generic gfx1201 is an ISA identity, not a supported serving product.
The Radeon Pro W7900 (gfx1100, target w7900) is vLLM-only, with product-scoped roofline peaks
that have no BF16, FP8 or INT4 entry; any other gfx1100 board is refused.
It is a system layer built on top of — and recursively
calling — the UNCHANGED single-kernel kernel_workflow (../kernel_workflow/). The single-kernel workflow's
quality is preserved verbatim; this layer adds everything above the kernel: profiling a running
server, Amdahl triage, config/backend tuning, extracting hot kernels into standalone unittests,
optimizing them with the kernel layer, overlaying them back, and re-validating end-to-end throughput.
- System layer (this dir): owns the server, the throughput metric, profiling, triage, config, and reintegration. Roles: e2e Director, System Architect, Profiler, Config Tuner, Kernel Extractor, e2e Integrator/Validator.
- Kernel layer (
../kernel_workflow/, UNCHANGED): given a kernel task dir, does the real multi-backend optimization with independent verification. The system layer hands it an extracted task dir and consumes its verifiedfinal_patch.diff+ geomean. Same contract as a hand-written kernel task.
Because the kernel layer is called as-is, single-kernel optimization effect cannot regress — and the
workflow is backward compatible: pass args.kernel_path (no model_path) and it delegates
straight to the kernel layer (single-kernel pass-through).
e2e throughput is Amdahl-dominated: only a speedup on a kernel that is a large share of GPU time,
times how often that path runs, moves the headline number. A 5× on a 2%-of-time kernel is invisible.
So the system layer always reasons in pct_gpu_time × achievable_speedup, tunes the cheap
landscape-reshaping config knobs FIRST, and gates every kernel change on a measured end-to-end
throughput delta that exceeds the noise band. See knowledge/e2e_optimization.md.
- e2e Director = setup (isolated eval dir + TRUE baseline throughput) + final independent throughput validation/arbitration + output-parity gate.
- System Architect = strategy: read the standardized Top-N, route by Amdahl into config/kernel/
host tracks, per-milestone planning + stop rule, and the persistent cross-run experience library
(
knowledge/backend_playbook.md, grown after every run). - Profiler = warm-server trace (torch + optional rocprofv3) → ONE standardized Top-N artifact via
scripts/parse_profile.py(the "spec" contract). - Config Tuner = Tier-0 flag/env/backend sweep, runs FIRST (default ON), no source rewrite.
- Kernel Extractor = capture real shapes + a reference I/O oracle → an IMMUTABLE standalone unittest task dir the kernel layer consumes (anti-cheating).
- e2e Integrator/Validator = reversible overlay reintegration + e2e throughput gate + final bundle.
- Kernel squad = the UNCHANGED
../kernel_workflow/kernel_workflow.js, invoked recursively.
Setup(preflight env-check + baseline throughput) → Baseline Profile(Top-N) → Strategize(Amdahl routing) →
ConfigSweep(flags/env/backends, FIRST) → Re-profile →
LOOP milestone[ plan → per kernel: Extract → recursive kernel_workflow.js → Overlay+e2e gate → ] → Re-profile → grow playbook →
Finalize(overlay+patch+launch bundle) → Architect Report → Director Validation
Setup runs a preflight (see knowledge/preflight.md) — a judgment-guided env self-check (not a
rigid script): it confirms the chosen backend stack, the model, GPU visibility; verifies the
caller-established structured product/ISA/CU identity, detects trace
sources, available op backends, and the model's arch class; degrades gracefully and writes
env_report.{md,json} that every later phase routes on.
Every accepted change compounds into the carried-forward overlay + config; throughput is always
measured on a warm server, in the same lifecycle as the TRUE baseline it is compared against.
The serving stack is NOT baked in. args.backend (sglang|vllm|atom, default sglang; vllm, and only vllm, on R9700 and gfx115x) selects
scripts/adapters/<backend>.sh, which scripts/bench_e2e.sh (a backend-agnostic dispatcher: owns
server lifecycle, warmup, timed round(s), summary, free-port allocation) sources. Adding a new
stack = adding one adapter that defines adapter_launch / adapter_health / adapter_bench
(+ optional adapter_default_port). No role or orchestration change. MODEL is required — there
is no rig-specific default that could silently bench the wrong target.
ATOM profiling is configured through --torch-profiler-dir at server launch and
ATOM_PROFILER_MORE=1 for shape-bearing traces. It writes a trace below a separate rank_<N> (or
dp<D>_tp<N>) directory for each worker; adapter_profile_window waits for every expected gzip to
finalize and writes atom_profile_manifest.json. A missing or incomplete manifest is a failed ATOM
profile rather than permission to continue with a partial rank-0 trace.
Who starts the server is a separate choice: BENCH_LAUNCHER=native, magpie or multinode
(one server across machines; see docs/multi_node.md).
A kernel's backend can be changed from three places, in increasing cost (knob names are backend-
specific — see perf_knowledge/backends/<backend>/ + perf_knowledge/reference/env_vars.md, as
reference only; verify every switch by measuring):
- launch flags (
--attention-backend,--quantization, …) — Config Tuner - env vars (sglang
SGLANG_USE_AITER, vllmVLLM_ROCM_USE_AITER, ATOMATOM_USE_TRITON_{MLA,MOE,GEMM}/ATOM_ENABLE_*_FUSION,HIPBLASLT_TUNING_FILE, …) — Config Tuner - source (a Triton/FlyDSL/HIP/CK/asm reimplementation) — Kernel Extractor + kernel squad,
overlaid back reversibly (never editing site-packages). For a hot op with no existing editable
implementation, the head track now authors one from scratch: the Op Benchmarker DISCOVERs
existing impls + tunes cheap levers, then emits an
author_plan; the orchestrator runs the kernel layer in author mode (mode=author target_language=flydsl|triton|hip|ck) to write a fresh baseline against the immutable oracle and optimize it, then the Integrator rebinds the op's call site to it and gates on e2e. Routing (direct_light tune vs author/rewrite via the kernel layer vs drop) is decided by Amdahl headroom + rewrite type. Triton is always a viable author target; for a dense / quantized GEMM (esp. fp8/A4W4) FlyDSL is the preferred author target (aiter's SOTA GEMM DSL — JIT, no build, baseline reusesflydsl_hgemm/flydsl_preshuffle_gemm_a8; FlyDSL is also one of the backends aiter's per-shape DB tune races, so it can also win via the cheap env lever with no author step). HIP/CK when the headroom justifies them (head_author_max, default 2 = FlyDSL+Triton).
Production callers should use interface/run_e2e.py, which performs structured
on-box identity detection before backend and knowledge policy are selected. A
direct model-mode Workflow call must supply both expected_gfx and
expected_target; this entry fails closed when either is missing.
workflow_dir must be this folder (a JS workflow can't read its own path); the
kernel layer defaults to the sibling kernel_workflow/.
e2e_workflow.js, kernel_workflow.js and kernel_lane.js are evaluated as async
function bodies in a realm whose entire global surface is the JS built-ins plus
agent / parallel / pipeline / phase / log / workflow / args / budget /
console / setTimeout. In particular:
process |
require |
dynamic import |
|
|---|---|---|---|
Claude Code's native Workflow tool (the default path) |
no | no | refused at launch |
interface/runtime/engine/run_workflow.mjs (--agent codex, …) |
yes | no | yes |
A dynamic import anywhere in one of those three files is a static rejection of the
whole script — not one line runs, on any phase. require is simply undefined on both
runtimes, so a require site must never be load-bearing. Anything that needs the
filesystem belongs in a vendored CLI under scripts/ that an agent runs, which is how
every other datum in the workflow (the profile, the strategy, every A/B number) already
arrives. scripts/tests/test_llm_ledger.py enforces this in CI; node --check does not
catch it, because plain Node accepts both.
Workflow({
scriptPath: "<E2E_DIR>/e2e_workflow.js",
args: {
model_path: "/path/to/model", // REQUIRED for e2e mode (no default)
workflow_dir: "<E2E_DIR>", // REQUIRED: this folder
expected_gfx: "gfx950", // REQUIRED direct E2E identity
expected_target: "unknown", // REQUIRED: r9700|r9600d|w7900|unknown; gfx1201 never implies a product; gfx1100 requires w7900
backend: "sglang", // optional: sglang|vllm|atom (selects scripts/adapters/<backend>.sh) on Instinct (default sglang); R9700 and R9600D are vllm or sglang only (default vllm); gfx115x and W7900 are vllm-only (default vllm)
launch_script: "<...>/launch.sh", // optional; else the stack's default config
kernel_workflow_dir: "<...>/workflows", // optional; default = sibling kernel_workflow/
budget: 4, // max kernel-optimization tasks (kernel-layer tasks; config sweep is free)
kernel_budget: 6, // budget passed DOWN to each recursive single-kernel run
milestone_min_pct: 5, // Milestone only optimizes editable kernels with pct_gpu_time >= this (default 5);
// overrides min_kernel_tasks — sub-threshold kernels are skipped (Amdahl)
config_tune: "true", // Tier-0 sweep on/off (default ON)
tuning_skillset: "true", // standalone TuningSkillset phase on/off (default ON). Runs the VENDORED
// tuning skillset (<repo>/perf_knowledge/expert_skills/tuning) WHOLE, as its own phase, AFTER
// ConfigSweep and BEFORE HeadKernel, with its own pre/post A/B so its share
// of the gain is attributable. "false" injects nothing -> byte-identical.
tuning_kb: "true", // consult tuning-kb/ (the per-model ANSWER KEY). Set "false" for blind evals.
// No op budget: the tuning loop is uncapped (tuning ops are cheap and their
// value is cumulative). See "Tuning skillset" below +
// knowledge/tuning_skillset_integration.md.
analysis_skill: "roofline", // profile-analysis skill (default "roofline"; "none" disables).
// Enriches the Top-N with % of the hardware roofline -> attainable speedup ->
// expected e2e gain, so budget goes to the kernel with HEADROOM, not merely
// the biggest one. ADVISORY: annotates + reorders, never prunes a candidate
// and never overrides the measured pct_gpu_time. See "Roofline" below.
use_expert_skills: "false", // consult perf_knowledge/expert_skills (advisory priors) on/off (default OFF, opt-in);
// set "true" to enable. When OFF (default) nothing is injected -> behavior is
// byte-identical to a run without the feature. Threaded down to the kernel layer too.
gpu_ids: "0", // comma-separated
isl: 1024, osl: 1024, conc: 64, // workload (profile + bench use the SAME)
task: "focus on ...", // optional steer
apply_to_original: "false" // if "true", emit an apply bundle (overlay + launch), never edits site-packages
}
})
// Single-kernel pass-through (backward compatible): pass kernel_path instead of model_path.
isl/osl/conc describe a synthetic sweep: every request is the same shape, and the profile and
the bench use it identically. An AgentX submission is not that. It replays a recorded corpus, so the
client owns the request mix, the arrival pattern, its own warmup and the measurement duration.
Standalone it is graded on the axis Hyperloom keeps AgentX candidates on, TTFT-inclusive P50
interactivity: e2e_norm_intvty_p50, i.e. 1 / P50(E2EL/OSL) in tok/s/user. Its guards ride
beside it: the P90 tail (guard_e2e_norm_intvty_p90_median), output tok/s, and total (input+output)
tok/s (guard_aggregate_total_token_tok_s_median). Unless the caller states its own KEEP rule, a win
must gain 3% on the graded axis with each guard at most 5% below the base leg, whichever axis is
graded but total itself; another axis keeps the guards summarized beside it, total among them. Total
is there because the corpus fixes the work each request asks for, so a candidate that completes less
of it can still raise the graded number. interface/run_e2e.py enforces the rule on a handoff. A
direct Workflow call gets the guards as an instruction to the Director at Validate, where the gain
bar is the run's noise band (0.5% unless the Director or noise_band_pct widens it). The output-only
axis a sweep uses is a poor fit: on a ~140:1 prefill-to-output corpus it barely moves for a large
change in work.
Under Hyperloom this arrives as environment variables that interface/run_e2e.py exports. Standalone,
declare it in the args instead — one line is enough, and it fills the canonical setup:
Workflow({
scriptPath: "<E2E_DIR>/e2e_workflow.js",
args: {
model_path: "/models/Kimi-K3", workflow_dir: "<E2E_DIR>", backend: "vllm",
gpu_ids: "0,1,2,3,4,5,6,7", tp: 8,
workload_kind: "agentx_trace_replay", // <- the whole declaration
conc: 8,
}
})
Note there is no isl/osl here. Nothing is measured at them on a trace replay — aiperf owns the
sequence lengths — but the roles still read them when they size tiles and synthesize GEMM shapes, so
leaving them at the synthetic 1024/1024 default would aim the whole kernel search orders of
magnitude below the real load. So the run measures its own shape: bench_e2e.sh reports the
average it actually served as observed_isl/observed_osl in bench_summary.json, and right after
Setup the workflow reads that off the baseline and adopts it, with
shape_provenance=agentx_measured_this_run. This is why no corpus average is hardcoded anywhere: the
number moves with the corpus, the tokenizer and the window, and a constant in the source would be
read as fact by every role long after it went stale. All kernel work is scheduled after the baseline,
so the measurement always exists before anything needs it.
Until the baseline lands the shape is openly 1024/1024 with
shape_provenance=agentx_pending_baseline, and role prompts mark it a placeholder that must not be
used for kernel sizing. If the baseline reports no shape at all (a client that never returned token
totals), the run continues on that placeholder and says so loudly rather than inventing a number.
To pin the shape yourself instead — targeting a regime deliberately, or feeding in a figure you measured elsewhere — declare it, and the measurement will not override you:
workload_spec: { kind: "agentx_trace_replay", corpus: "<yours>",
observed_isl: 120000, observed_osl: 800 }, // -> shape_provenance=agentx_observed
workload_kind expands to the graded setup: scenario inferencex-agentx-mvp, corpus
semianalysis_cc_traces_weka_062126, 393 entries, a 3600s canonical window with 900s inner search
legs, and e2e_norm_intvty_p50 as the metric basis. Override any part with the long spelling,
which is the same object Hyperloom puts on its handoff:
workload_spec: {
kind: "agentx_trace_replay",
corpus: "semianalysis_cc_traces_weka_062126", num_entries: 393,
duration_s: 3600, // canonical/parity window
geak_loop_duration_s: 900, // inner search legs (the scenario's own floor)
concurrency: 8, // also what every bench line passes as CONC; wins over args.conc
metric_basis: "e2e_norm_intvty_p50", // or e2e_norm_intvty_p90, p90_intvty_inferencex,
// aggregate_output_tok_s, aggregate_total_token_tok_s
canonical_corpus: "semianalysis_cc_traces_weka_062126", // optional; what results are
canonical_num_entries: 393, canonical_duration_s: 3600, // stamped canonical against
warmup_requests_per_lane: 10, warmup_grace_period_s: 1800,
failed_request_threshold: 0.10,
observed_isl: 0, observed_osl: 0, // optional; omit to measure it off the baseline
inferencex_path: "/opt/InferenceX", // optional; GEAK vendors map_aiperf.py
aiperf_bin: "aiperf", // optional
profile_warmup_s: 2700, profile_window_s: 20, // optional window placement
},
Three parts of that object do more than they look:
- The axis. A declared
metric_basiswins. Without one, anE2E_METRICalready exported in the environment decides, since an exported value outranksbench_env.shand is what the bench would measure anyway. A declared basis that disagrees with an exportedE2E_METRIC, or an exported valuebench_summarize.pycannot measure, is refused at start rather than an hour into the baseline. The acceptance noise band defaults to 0.5% on a trace replay too, though two same-config baseline replicas differed by 3.86% on P90 interactivity (3.43% on total tok/s): one kernel rarely moves e2e that far, so each A/B gates on the smaller band andinterface/run_e2e.pyholds the final pair to the KEEP rule.noise_band_pctsets a floor the Director's band can only widen; the TTFT-inclusivee2e_norm_intvty_p90moved 17% on the same pair, so pass one if you grade on it. - The reference. Overriding
corpus,num_entriesorduration_sdoes not move what a result is stamped canonical against, so a replay of anything else comes backsubmission_valid=false. To change the reference itself (a ~256k-context server's_256kcorpus, say), setcanonical_corpus/canonical_num_entries/canonical_duration_stoo. - The mapper. An
inferencex_pathcheckout'smap_aiperf.pywins over GEAK's vendored copy, and upstream's own fallback mapping predates the interactivity fields, so outside Hyperloom's runtime it cannot grade the default axis.agentx_smoke.shmaps a sample export through whichever copy the run would use and blocks when the graded field is missing.
Check the box first. Every AgentX prerequisite is invisible until the client has already launched and warmed a server, so a missing one costs 20+ minutes to discover:
bash e2e_workflow/scripts/agentx_smoke.sh # environment only
MODEL=/models/Kimi-K3 bash e2e_workflow/scripts/agentx_smoke.sh
BASE_URL=http://127.0.0.1:8000 bash e2e_workflow/scripts/agentx_smoke.sh # + a real short replayIt never launches a server. Its most important check is that aiperf actually supports --scenario:
a stock aiperf cannot replay the corpus at all, but pointed at a server it will still report a
throughput — a "successful" run that measured a different workload.
A handoff run checks the client before anything launches. run_e2e.py resolves the aiperf the
bench will run (AIPERF_BIN, else aiperf_bin, else aiperf on PATH), and when that is an absolute
path that is missing, not executable, or in a venv whose interpreter is gone, it writes
error_class: agentx_client_unavailable instead of launching a server. A bare name missing from
PATH only warns, since the bench's PATH can differ; GEAK_STRICT_AGENTX_PREFLIGHT=1 refuses it too.
The workflow composes one bench_env.sh and the Director writes it beside the copied bench script;
bench_e2e.sh and bench_replica.sh source it from next to themselves, so every bench in the run —
including the ones role agents issue from their own prompts — selects the trace client and the graded
axis. Each line assigns only an unset-or-empty name, so anything already exported still wins and you can
override one knob on the command line. Every role prompt also gains a workload-identity block stating
what the run measures. Without a declaration none of this exists: no file is written, the source is a
no-op, the prompts are byte-identical, and the fixed ISL/OSL path is exactly as before.
isl/osl are not a benchmark here. A trace corpus spans orders of magnitude in request length,
so there is no single ISL — read the real distribution off the run's own export. They are only the
shape to optimize for: what roles synthesize GEMM inputs and pick tiles against. Nothing is measured
at them, and measured on this stack a synthetic sweep at those lengths came out ~2.76x the
trace-replay throughput, so it is not a cheaper approximation of the real number.
Search legs are non-canonical by design. They run the scenario's 900s floor instead of the canonical
3600s, so the client stamps them submission_valid=false with the deviations attached. Both legs of an
A/B deviate identically, so the comparison is sound; the number simply cannot be reported as a
submission. Only a parity/validation leg runs the full window.
Profiling places its window at 75% into the replay (2700s on the canonical leg), because at load start aiperf is still resolving the corpus and draining per-lane warmups — a window opened there records the ramp, not the steady state. If the replay ends before the window opens, GEAK captures no trace rather than substituting a synthetic one that would look authentic.
One pipeline, three depths — selected by the fast_mode / deep_mode args (both default false =
default mode; they are mutually exclusive, deep takes precedence). Only the HeadKernel depth and
which phases run change; the throughput metric, the e2e gate, and the reversible-overlay contract are
identical. With both off, the run is byte-identical to the original (every mode knob is gated).
| Mode | arg | Phases | HeadKernel | Budget (default) | Use when |
|---|---|---|---|---|---|
| default | (none) | ConfigSweep + HeadKernel + Milestone | serial, 1 pass/head, ≤2 authored langs, single e2e gate | — | full pipeline incl. the editable-kernel Milestone loop |
| fast | fast_mode:true |
HeadKernel only (skips ConfigSweep + Milestone) | parallel head track (extract/bake/author fan out across GPUs), time-capped | fast_budget_ms = 5h |
a quick HeadKernel-only win under a wall-clock cap |
| deep | deep_mode:true |
ConfigSweep + HeadKernel (skips Milestone) | global cross-kernel×backend lane pool — every (head op × backend) optimizes in parallel, many rounds via STATE_DIR + reseed, cross-pollination (per-op SHARED_KB + run-global GLOBAL_KB), convergence-stop + agent-budget backstop, finalize banks a combined cross-kernel overlay | deep_head_budget_ms = 24h |
the deepest/broadest result: most backends, most rounds, hours available |
# default — full pipeline
args: { model_path, workflow_dir, backend:"vllm", tp:4, gpu_ids:"0,1,2,3", isl:1024, osl:1024, conc:64 }
# fast — HeadKernel-only, parallel, time-boxed
args: { ...same..., fast_mode:true, fast_budget_ms: 18000000 }
# deep — exhaustive, multi-backend, parallel (give it all GPUs + hours)
args: { ...same..., deep_mode:true, gpu_ids:"0,1,2,3,4,5,6,7", deep_head_budget_ms: 64800000 }
Pick fast for a bounded quick pass, default for the standard run, deep to chase the best achievable number (it is broader = more backends, deeper = more/faster rounds, parallel = lanes co-opt spare GPUs while the e2e gate runs on the serving slot, with matched in-window A/B so parallelism never corrupts a measurement).
A dedicated phase — after ConfigSweep, before HeadKernel — that runs the tuning skillset vendored at
<repo>/perf_knowledge/expert_skills/tuning/: an independently-validated method for tuning GPU ops on AMD Instinct (per-op
tuners, deploy paths into a live server, and the engagement checks that prove a tuned artifact is
actually what the machine runs).
It is vendored whole and run whole. The tree is byte-identical to the standalone repo it is validated
in (37 executable claims in validate/claims.py), hash-pinned by
e2e_workflow/knowledge/tuning_skillset.manifest.sha256, and consumed by exactly one thin adapter role,
roles/tuning_specialist.md. Its method is deliberately not paraphrased into knowledge/: a
standalone validation is evidence about a specific tree, and scattering it would keep the prose while
losing the guarantee. Fixes go upstream and come back via
scripts/tuning_skillset_sync.py --sync <dir>; never edit inside the vendored tree.
Why standalone, and why before the head track. The skillset is a complete six-step loop (scope → baseline → search → correctness gate → deploy → engagement verify). Folded into the head-kernel bake-off it degenerates into "one more candidate config" and most of it never runs. As its own phase it runs end to end, and — because it takes its own in-session interleaved pre/post A/B — the final report can say how much of the run's gain came from tuning. Running it first also means the expensive head budget goes to the ops still hot after tuning (an accept triggers a re-profile, exactly as a config win does), and its accepted env/flags fold into the carried config so every later A/B measures on top of a tuned stack. Corollary when reading the report: the tuning delta and the head deltas are not additive — tuning is already in the head track's reference leg.
An accept is not taken on trust. The orchestrator withholds it unless engagement was proven, both A/B
legs completed, correctness passed, and post > pre > 0; otherwise it is downgraded to no_win and the
run continues on the pre-tuning config. An unproven tuning artifact would otherwise sit silently in the
reference leg of every downstream measurement — which is the exact failure the skillset exists to catch.
Scope. The phase does not author kernels — that is the head/Milestone tracks' job, unchanged. It does
own the dispatch path: which kernel the seam selects, with which parameters, and the code that makes a
tuned artifact actually bind (a routing switch, a wrapper that drops the kernel selection). That code
half travels as a reversible overlay (apply_overlay → carried curOverlay → final/overlay), never as
a live-tree source edit. It is not a corner case: the skillset measures a correctly-tuned row deployed
behind a wrapper that ignores the kernel selection running 85.7% slower than doing nothing, with every
engagement gate passing.
How the win ships. The data half of a tuning win is a config table a library reads from inside its
own package dir, often with a derived cache that must be dropped or the new rows are silently ignored.
That cannot travel in final/overlay, which is a PYTHONPATH mechanism for code. So the phase writes
a deploy bundle (EVAL_DIR/tuning/deploy/: manifest, git-applyable diff, the files, and an idempotent
deploy.sh) and Finalize folds it into the existing deliverable handles — the diff is concatenated
into final_patch.diff, and final_launch.sh runs deploy.sh before the server starts. Finalize then
re-checks engagement on the assembled bundle, so a bundle that silently drops the tuning is reported as
broken instead of shipped as complete. Callers reusing final_launch.sh need no extra steps.
Results land in EVAL_DIR/tuning/, in final_report.md §2b, in
wfReturn.tuning_skillset (tuning_delta_pct, tuning_speedup, share_of_total_gain_pct), and in
result.json under a purely additive tuning_skillset key — no existing key changes name, type or
meaning, and a run without the phase produces a byte-identical result.json.
Fast mode skips the phase; deep mode keeps it for fixed-load workloads. AgentX skips
it as described below. Full contract:
knowledge/tuning_skillset_integration.md.
An explicit workload_kind: "agentx_trace_replay" (or matching workload specification)
activates two skills, run in order by one extractor:
kernel-profile (measured
baseline logs → observed workload → sampling points → runtime census, ranking and
selection → profile_handoff.json) and
kernel-ut (task boundaries →
source extraction → standalone GPU UTs qualified for correctness). Existing trace,
harness, GPU-lock and delivery helpers are reused from the repository; their regression
tests remain in one place.
UT inputs are fixed-seed generators at the handoff's shapes/dtypes/layouts; reference
outputs come from the frozen baseline in an isolated process and are not persisted.
UT execution does not launch serving, profile or capture, and extraction persists no
tensors: routing, indices, page tables and other structural metadata are reused or
reconstructed, and what cannot be is a reported gap. UT qualification runs
unittest.py --validation-mode correctness; timing legs run in optimization, where
the bare unittest.py measures them. Non-AgentX capture defaults are unchanged.
GEAK supplies baseline/configuration paths, GPU allocation, accepted overlays and budgets through the workflow handoff. The extractor completes scheduled UT work before returning a delivery path. The packaging adapter reads each task's saved declaration and return, preserves failed/deferred tasks and coverage, and feeds verified tasks into the existing optimization queues. It checks source/binding/UT evidence without repeating selection or GPU tests; changes to source, cases or recorded results invalidate reuse. Task-count budgets affect scheduling, not the selected inventory or its reported coverage.
AgentX follows baseline → B extraction and UT validation → head optimization → kernel milestones → E2E validation. Outer Profile/Strategize, ConfigSweep and Tune are skipped. B still uses bounded trace sampling to establish kernel identity and cost. All three head modes and the milestone loop reuse the prepared task directory and immutable UT, running it against optimization candidates instead of authoring another test. Workspace setup retains phase-local oracles, helpers and baseline resources; head and milestone use the workload-weighted result. Missing or changed preparation evidence fails the task locally. Current optimization lanes are single-GPU: completed multi-rank UTs retain their artifacts and are deferred for separate scheduling.
The default selection remains per-phase Top 5 intersected with whole-workload GPU-time share strictly greater than 3%, without backfilling. Explicit user scope wins. Head routing uses the prepared task kind; milestones consume the remaining kernel queue without Architect nomination or the fixed-load 5% filter. Optimization wins do not trigger another extraction; scheduling uses the original measured order and weights. Dispatched tasks leave the queue, pending tasks survive resume, and an empty queue stops dispatch. Fast/deep modes retain their head-only scheduling. Fixed ISL/OSL workloads keep their existing flow. Each optimization still runs its existing UT and E2E A/B gate; a UT pass alone does not establish an E2E improvement.
pct_gpu_time tells you where the time goes; it does not tell you whether that time is
recoverable. A kernel already running at the memory or compute ceiling has nothing left to give no
matter how much of the profile it owns. So after the Profiler emits the Top-N it runs one pluggable
analysis skill (knowledge/analysis_skills/<name>/SKILL.md) which estimates, per kernel:
roofline_pct → attainable_speedup → expected_e2e_gain_pct = pct_gpu_time × (1 − 1/attainable).
The Architect then reports both orderings — by %GPU and by expected gain — and says which it
followed; a disagreement between them is the useful signal, so it is never blended into one number.
Roofline is advisory and can never prune a candidate. Same doctrine as the TraceLens prior: the
measured pct_gpu_time is the judge. Confidence is staged — profile-time shape estimates are low
(display only, not ranked on), real extracted shapes are medium, rocprofv3 counter measurements
(FETCH_SIZE/WRITE_SIZE/MfmaFlops*) are high. Five degradation levels end in "emit nothing and
behave exactly as before", so a missing peak table, an unmodellable op or a bad number cannot fail a run.
A saturated head is rerouted, not dropped — the point that matters most for the largest kernel.
Being at the wall means it is done with micro-tuning, not done being optimized; it routes to a
byte-reduction track (fuse an adjacent op away, stop reading unrouted experts, layout/packing,
lower-precision weights). Those levers must preserve the measurement contract: the user-supplied
workload (isl/osl/conc/batch) is fixed and speculative decoding is not an optimization.
Calibrated on a real run (Qwen3.5-35B-A3B-FP8, gfx950, vLLM TP1, 1k/1k, conc 64) — see
scripts/tests/test_roofline_skill.py:
| kernel | %GPU | of roofline | attainable | predicted e2e | measured |
|---|---|---|---|---|---|
fused_moe_kernel |
26.45% | 88% (memory-bound) | 1.02× | +0.6% | 1.047× iso, −0.064% e2e |
kernel_paged_attention_2d |
8.86% | 18% | 2.8× | +5.7% | 1.56× iso |
Ranking by %GPU sends the budget to the MoE, where it was in fact wasted; ranking by headroom sends
it to attention, where the win was. Add a skill by dropping a directory into
knowledge/analysis_skills/; swap with analysis_skill=<name>; disable with analysis_skill=none.
By default the e2e gate accepts a kernel on throughput delta + greedy output parity
(accuracy_gate:"none"). For QUANTIZED kernels (MXFP8/fp8) byte-parity is too strict — a within-tolerance
kernel rounds differently and flips a few borderline greedy argmaxes — so you can switch the bar to
task accuracy:
args: { ...same..., accuracy_gate:"gsm8k", accuracy_limit:200, accuracy_tol:0.01 }
accuracy_gate:"gsm8k"→ the Integrator serves a fresh TRUE baseline vs the candidate, runs sampled gsm8k (5-shot, greedy, fixed seed), and accepts iffcand_em >= baseline_em - accuracy_tol.accuracy_limit= #questions (default 200; deep uses a larger sample at finalize to de-noise the boundary).accuracy_tol= allowed exact-match drop (default 0.01).- The eval client is
scripts/gsm8k_eval.py(model-agnostic; queries the OpenAI-compatible endpoint). - Leaving it unset (
"none") changes nothing vs before — the gate stays throughput + parity only.
An accuracy-gated speedup above the Amdahl estimate triggers one independent A/B review, not a
correctness rewrite. The existing implausible_speedup_margin option remains supported (default
1.0, review above twice the estimate; the runner forwards GEAK_IMPLAUSIBLE_SPEEDUP_MARGIN). A
confirmation uses fresh reference/candidate servers, at least two timed replicas per leg, and the
same correctness and engagement gates. If the gain reproduces, it is accepted even above the estimate.
Already confirmed evidence is reused only for the same candidate, reference, workload and measurement
protocol identities. The workload identity covers only what decides the served requests, so a profile
and an A/B of the same workload share it; bench/protocol details go in the separate protocol digest.
Missing provenance, a timeout or repeated old A/B artifacts leaves the candidate unconfirmed without
starting another kernel rewrite. On a timed AgentX trace replay, a confirmation that would not finish
before the final reserve (every timed replica counted as a leg) is not started, with the same result.
Final Validate still performs the normal combined-stack check.
The estimate uses the candidate's affected_gpu_time coverage when its profile matches the current
reference and workload: all affected shapes/phases and removed auxiliary kernels, counted once.
Per-path timings are used when available; applying the head speedup to unmeasured paths is explicitly
labelled an approximation. Stale/missing coverage falls back to the head estimate. The head's original
pct_gpu_time is preserved for ranking. Candidate checkpoints include the reviewed integration result,
so timeout recovery respects the same acceptance decision. See the integrator contract
for coverage and measurement-evidence fields.
Everything lands under <exp_root>/e2e_<model>_<timestamp>/:
env_report.{md,json}— the preflight capability report every phase routes onbaseline/bench_summary.json,env_info.txt,config/baseline_flags.json— the TRUE baselineprofile/round_*/profile_topN.{json,md}— the standardized Top-N each roundstrategy.md,config/sweep_results.json,insight_log.mdkernels/<short_name>_task/{kernel_src, reference_io.pt, unittest.py, meta.json}— extracted taskskernels/_exp/…— the recursive single-kernel runs (each with its own verified result)overlay/…— candidate + accepted reversible overlaystuning/{tuning_report.md, env_audit.txt, claims_report.json, bench_pre/, bench_post/, <op>/}— the standalone tuning phase + its attributable pre/post A/Bfinal/{overlay, final_patch.diff, final_launch.sh}— the deliverable bundlearchitect_report.md,director_e2e_validation.json— the official verified throughput result
e2e_workflow.js orchestration (deterministic; recursively calls ../kernel_workflow/kernel_workflow.js)
roles/ director, system_architect, profiler, config_tuner, tuning_specialist, kernel_extractor, op_benchmarker, e2e_integrator
knowledge/ e2e_optimization, profile_parse, preflight (env self-check), backend_playbook + gemm_attention_backends (persistent), sglang_internals, shape_capture
knowledge/analysis_skills/ pluggable profile-analysis skills (INDEX.md + one dir per skill; `roofline` ships by default)
knowledge/tuning_skillset_integration.md how the VENDORED ../tuning_skillset/ is wired in (+ its manifest)
scripts/ bench_e2e.sh (backend-agnostic dispatcher), adapters/{sglang,vllm,atom}.sh, parse_profile.py (Top-N), op_bench.py, capture_shapes.py, overlay_setup.py
scripts/adapters/clients/ pluggable BENCH CLIENTS (the timed load): agentx.sh (AgentX trace replay via aiperf) + map_aiperf.py vendored beside it so a standalone run needs no InferenceX checkout
scripts/agentx_smoke.sh AgentX readiness check: run it BEFORE a trace-replay run (never launches a server). See "Standalone AgentX" above.
scripts/tuning_skillset_sync.py integrity gate on the vendored skillset (--verify / --update / --sync)
scripts/server_teardown.sh the shared server-kill contract (identity verified at LAUNCH: pid, pgid, /proc start time). Every script that launches a server, including role-authored capture scripts, must source it instead of hand-rolling a kill.
The script never hard-codes a model or kernel. The workload (isl/osl/conc) drives both profiling and
benchmarking identically; the Profiler's classification + the Architect's Amdahl routing decide what
gets tuned vs rewritten. For a different model, only model_path (+ optional launch_script)
changes. The persistent backend_playbook.md carries learned per-class backend priors across runs.