Skip to content

fix(journey): fold a return-named acceptance into its overlay entry - #408

Merged
iraj465 merged 1 commit into
mainfrom
fix/journey-overlay-return-alias
Aug 19, 2026
Merged

fix(journey): fold a return-named acceptance into its overlay entry#408
iraj465 merged 1 commit into
mainfrom
fix/journey-overlay-return-alias

Conversation

@iraj465

@iraj465 iraj465 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Branch: fix/journey-overlay-return-aliasmain
Base: ab9dd2db
Closes: #407

What was wrong

build_kernel_journey adds acceptances "named only in the workflow return"
after it has written one entry per overlay. It tests that "only" with the
emitted kernel_id. The two substreams do not name a kernel the same way: an
overlay directory carries the candidate tag (cand_c0_triton) and the
return carries the kernel symbol (dsa_sparse_attn_prefill_main_kernel).
The ids never collide, so one acceptance is emitted twice — once measured, once
with gpu_pct: null and the same e2e_gain_pct, both marked KEEP.

Full evidence, worked example, and the affected session list are in the issue.

What this changes

integrate_result.json is the file that ties the two spellings together: it
records cand_tag and short_name. The fix reads the overlay's claim from
there and dedupes pass 2 against it.

Two small helpers, no change to any emitted field:

  • _overlay_claim(ir) — what an integrated overlay says it optimized, or
    None. An overlay whose gate is not accepted/stack claims nothing, so
    a rejected or cut-off overlay still leaves a return acceptance as new
    information.
  • _claim_for(name, gain, claims) — the claim that already covers this
    return-named acceptance. Symbol first, on the same normalization
    _match_profiler uses. Integrated e2e delta as the fallback, for the runs
    where the overlay recorded no usable symbol: the return copies that number
    from the overlay's own A/B rather than recomputing it, so an exact hit is the
    same measurement. The delta only folds when exactly one unconsumed
    overlay claims it.

A claim is consumed at most once, so one overlay can never absorb two distinct
acceptances.

This is deliberately not a name-similarity heuristic and not a rounded-gain
match. Every join is a value GEAK itself wrote to integrate_result.json.

Why it is safe on real decompositions

/shared_nfs/hyperloom-claw/Qwen3-14B-FP8/20260816T050457Z/geak/e2e_cycle0 has
one overlay (cand_c0_aiter, delta 7.53) and two accepted records — a
down_proj-shaped and a gate_up-shaped GEMM, deltas 6.779 and 0.705. Those are a
decomposition, not an alias. The consume-once rule keeps both entries. Verified
in the replay below and pinned by
test_one_overlay_is_consumed_by_at_most_one_return_acceptance.

Verification 1 — replay over the live campaign

Rebuilt the journey for every workflow_return.json under
/shared_nfs/hyperloom-claw/*/*/geak/e2e_cycle*/, on ab9dd2db and on this
branch, and diffed the emitted entries.

before after
e2e cycles replayed 77 77
kernels[] entries 97 87
entries removed 10
entries added 0
entries altered 0
KEEP entries 36 26

Every removed entry carried gpu_pct: null and an e2e_gain_pct identical to a
surviving measured entry. Nothing measured was dropped. Ten sessions changed;
they are listed in the issue.

Downstream, Hyperloom's collector credited 8 of these duplicates as real
kernels, so the number on the TOP Model CI dashboard was over-counting GEAK's
kernels by 35 %.

Verification 2 — tests

Eight new tests in the existing interface/test_run_e2e_dispatch.py journey
suite. Each pins one rule, and each is modelled on a real session:

test pins
test_return_acceptance_already_on_disk_as_an_overlay_is_not_re_emitted the defect itself; the measured entry survives
test_sibling_candidates_for_one_symbol_each_stay_their_own_entry folding is against the return, never between overlays
test_symbol_less_overlay_folds_the_return_on_its_integrated_delta the delta fallback (Kimi-K3 case)
test_an_ambiguous_delta_never_folds_two_kernels two overlays sharing a delta fold nothing
test_one_overlay_is_consumed_by_at_most_one_return_acceptance the decomposition case above
test_a_rejected_overlay_claims_nothing do-no-harm; a REVERT is not an acceptance
test_an_incomplete_ab_overlay_claims_nothing no integrate_result at all
test_folded_return_acceptance_is_absent_from_synthetic_discovery a folded entry does not return as a synthesized hot_kernel

Full interface/ suite, same interpreter, same machine:

base ab9dd2db : 168 passed, 1 skipped, 0 failed
this branch   : 176 passed, 1 skipped, 0 failed

Reproduce the replay

python - <<'PY'
import json, glob, importlib.util
from pathlib import Path
spec = importlib.util.spec_from_file_location("rx", "interface/run_e2e.py")
rx = importlib.util.module_from_spec(spec); spec.loader.exec_module(rx)
n = 0
for wfp in sorted(glob.glob('/shared_nfs/hyperloom-claw/*/*/geak/e2e_cycle*/workflow_return.json')):
    d = str(Path(wfp).parent)
    j = rx.build_kernel_journey(json.load(open(wfp)), {"eval_dir": d})
    n += len(j["kernels"])
print("journey entries:", n)   # 97 on ab9dd2db, 87 on this branch
PY

Not addressed here

  • Pass 1 still names an entry after the candidate tag even when
    integrate_result.short_name holds the real profiler symbol. Changing the
    emitted kernel_id would move the fold key the orchestrator's assembler uses,
    so it belongs in its own change.
  • Hyperloom's defensive collapse (AMD-AGI/Hyperloom 8d108b0) stays. It has to:
    the 77 journeys already written to disk still contain the duplicates, and the
    dashboard reads those files. Once this ships, that collapse is a no-op on new
    runs.

@iraj465

iraj465 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Cross-workload view: how often the twin actually fires

Per-workload breakdown of the duplicate this PR removes, measured 17 Aug 2026
over /shared_nfs/hyperloom-claw/66 GEAK CI runs across 15 workloads.

"Claim" below means a KEEP + integrated row in
geak/e2e_cycle*/kernel_journey.json, counted across all cycles.

workload runs runs with a claim KEEP rows distinct kernels twins
Qwen3-0.6B 9 2 4 3 1
Qwen3-14B-FP8 9 3 6 5 1
MiniMax-M3-MXFP4 7 0 0 0 0
Qwen3-8B 7 0 0 0 0
gemma-4-26B-A4B-it 7 3 9 6 3
DeepSeek-V4-Pro 5 0 0 0 0
Kimi-K3 5 1 2 1 1
Mixtral-8x7B-Instruct-v0.1 5 1 2 2 0
Llama-3.1-8B-Instruct 4 1 2 2 0
Qwen3.5-122B-A10B-FP8 2 2 4 2 2
Qwen3.8-2.4T-A95B-Quark-MXFP4 2 0 0 0 0
GLM-5.2-MXFP4 1 1 3 2 1
MiniMax-M3-MXFP8 1 1 4 3 1
Qwen3.5-397B-A17B-MXFP4 1 0 0 0 0
gpt-oss-120b 1 0 0 0 0
TOTAL 66 15 36 26 10

10 of 36 accepted-kernel rows are twins — 28%. They appear in 8 of the 15
workloads
, in every workload that claims more than one kernel. This is not
specific to one model, one backend or one operator kind.

Two workloads are worth reading closely:

  • Qwen3.5-122B-A10B-FP8 — 4 rows, 2 real. Half the claimed kernels in this
    workload are duplicates.

  • gemma-4-26B-A4B-it — the largest claimant, 9 rows and 3 twins. Its
    20260815T130915Z run shows the shape plainly:

    fused_moe_kernel_c0_triton                     gpu=35.22  gain=14.973
    fwd_grouped_kernel_stage1_c0_triton            gpu=33.59  gain=18.9148
    fwd_grouped_kernel_stage1_stage2_c0_triton     gpu=35.22  gain=14.973
    fwd_grouped_kernel_stage1_stage2_c0_triton_v2  gpu=35.22  gain=10.512
    fwd_grouped_kernel_stage1                      gpu=None   gain=18.9148   <- twin of row 2
    

    Row 5 is row 2 under its symbol instead of its candidate tag: no gpu_pct,
    identical gain. Note rows 1 and 3 also share a gain (14.973) and both carry
    a gpu_pct — two measured rows, so they are not a twin pair and both survive.

The replay result already in the PR body — 97 → 87 journey entries, 10 removed,
0 added, 0 altered — is the same 10 seen here, distributed across those 8
workloads.

Reproduce

python3 - <<'PY'
import glob, json
from collections import defaultdict
per = defaultdict(lambda: {"runs": 0, "keeps": 0, "twins": 0})
seen_runs = set()
for kj in sorted(glob.glob('/shared_nfs/hyperloom-claw/*/*/geak/e2e_cycle*/kernel_journey.json')):
    m = kj.split('/')[3]
    rows = []
    for k in (json.load(open(kj)).get("kernels") or []):
        e = k.get("e2e") or {}
        if str(e.get("decision") or "").upper() == "KEEP" and e.get("integrated"):
            rows.append((k.get("gpu_pct"), e.get("e2e_gain_pct")))
    per[m]["keeps"] += len(rows)
    groups = defaultdict(list)
    for i, (gpu, gain) in enumerate(rows):
        groups[round(gain, 3) if isinstance(gain, (int, float)) else i].append(gpu)
    for g in groups.values():
        meas = [x for x in g if x is not None]; un = [x for x in g if x is None]
        if meas and un: per[m]["twins"] += len(un)
for m, d in sorted(per.items(), key=lambda kv: -kv[1]["keeps"]):
    if d["keeps"]: print(f"{m:32} keeps={d['keeps']:3}  twins={d['twins']:3}")
PY

@iraj465

iraj465 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up: what the 26 claimed kernels are worth downstream

Extending the cross-workload view above, over the same 66 GEAK runs across 15
workloads
in /shared_nfs/hyperloom-claw/, 17 Aug 2026.

GEAK claims 26 distinct KEEP+integrated kernels in 15 runs — 36 journey
rows before the alias twins this PR removes are collapsed.

Hyperloom credits 0 of them with an end-to-end gain:

  • reports/kernel_optimization_summary.json is readable in 54 of the 66
    sessions and holds 375 by_kernel rows — UNATTEMPTED 357,
    ATTEMPTED_REJECTED 14, IN_FLIGHT 4, accepted 0.
  • In the 62 sessions with a readable decision_trace.jsonl, patches land as
    change == "integrate_patch"REVERT 106, KEEP 29, no_promote 13 — and
    the row records component: "orchestration", operation_kind: "other", never
    the kernel it integrated. There is no kernel value anywhere in
    decision.kind.
  • 15 sessions hold a GEAK KEEP kernel claim. 11 hold a Hyperloom
    integrate_patch KEEP with a gain. The intersection is 1, and there the
    gain is null.

Four runs show GEAK and Hyperloom both positive and within 3x. In all four,
Hyperloom's whole gain is one server argument — --max-running-requests 64,
--max-model-len 6144, --context-length 13312, --tp-size 1 --dp-size 2.
None is a kernel.

This does not weaken the case for this PR. It sharpens it: the claim count is
currently inflated by 10 of 36 rows, so the first thing to get right is what
GEAK actually claims. Full measurement, including the per-workload table and the
worked GLM case, is on the Hyperloom side:
AMD-AGI/Hyperloom#1209 (comment)

build_kernel_journey emits one kernels[] entry per optimization overlay, then
augments with acceptances "named only in the workflow return". It tests that
"only" with the emitted kernel_id — but the two substreams do not name a kernel
the same way. An overlay directory is named for its CANDIDATE TAG
(cand_c0_triton); the workflow return names the KERNEL SYMBOL
(dsa_sparse_attn_prefill_main_kernel). The ids therefore never collide, and one
acceptance is written twice: once measured from integrate_result.json, and once
from the return with gpu_pct null and the same e2e_delta_pct.

integrate_result.json is the file that ties the two spellings together: it
records cand_tag AND short_name. Read the overlay's claim from there and dedupe
pass 2 against it.

  * only an INTEGRATED overlay claims anything (gate accepted/stack); a rejected
    or cut-off overlay leaves a return acceptance as new information,
  * the symbol is compared on the same normalization the profiler match uses,
  * when the overlay recorded no usable symbol, the integrated e2e delta folds
    it — the return copies that number from the overlay's own A/B rather than
    recomputing it — but only when exactly one unconsumed overlay claims it,
  * a claim is consumed at most once, so a single overlay can never swallow two
    distinct acceptances.

Replayed over all 77 e2e cycles under /shared_nfs/hyperloom-claw: 97 -> 87
journey entries, 10 duplicates removed, 0 added, 0 altered. Every removed entry
carried gpu_pct null and a gain identical to a surviving measured entry. Two
acceptances that decompose one overlay into differently-shaped GEMMs
(Qwen3-14B-FP8/20260816T050457Z, deltas 6.779 and 0.705 against an overlay
delta of 7.53) are correctly left alone.

Tests: interface/ 168 -> 176 passed, 0 failed.
@iraj465
iraj465 force-pushed the fix/journey-overlay-return-alias branch from 5c891d9 to 7a63544 Compare August 19, 2026 14:41

@sdubagun-amd sdubagun-amd 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.

LGTM

@iraj465
iraj465 merged commit 73937c8 into main Aug 19, 2026
9 checks passed
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.

3 participants