Skip to content

feat(kernel_workflow): unify entry with mode dispatch (optimize/author/bakeoff) - #383

Draft
yueliu14 wants to merge 2 commits into
mainfrom
feat/kernel-workflow-mode-dispatch
Draft

feat(kernel_workflow): unify entry with mode dispatch (optimize/author/bakeoff)#383
yueliu14 wants to merge 2 commits into
mainfrom
feat/kernel-workflow-mode-dispatch

Conversation

@yueliu14

Copy link
Copy Markdown
Collaborator

Collapse kernel_workflow into a single entry point with mode dispatch, and add multi-backend bake-off.

  • kernel_workflow.js is now the dispatcher (entry point):
    • mode=optimize | author → passes straight through to the single-language worker; behavior identical to the old workflow (backward compatible).
    • mode=bakeoff → the dispatcher itself is the multi-backend bake-off orchestrator: Freeze → Discover → one parallel lane per language → pick the fastest. Pass backends to choose languages, or leave empty
      to auto-discover.
  • The unchanged single-language pipeline moves to kernel_lane.js (the worker; content identical, meta.name only).

Why

Kernel-only users had no entry for "one kernel, race several languages, keep the fastest", and e2e's existing bake-off wasn't reusable standalone. A single entry is friendlier for users while leaving the
single-language worker untouched.

How it stays correct

  • One frozen baseline: oracle_freezer freezes the input kernel into a single immutable oracle; every lane (including each language's author lane) is scored by the same unittest.py against the same
    baseline_src/ → speedups are directly comparable (anti-cheating).
  • Nesting stays 0→1: the dispatcher fans out workflow(kernel_lane.js) directly; e2e_workflow and kernel_workflow_bmk now call the worker directly, never through the dispatcher, so the one-level nesting limit
    is never exceeded.

…r/bakeoff)

kernel_workflow.js becomes a single ENTRY POINT / dispatcher; the unchanged
single-language pipeline moves to kernel_lane.js (content identical, meta.name only).

- mode=optimize|author  -> pass straight through to the kernel_lane worker (backward compatible)
- mode=bakeoff          -> dispatcher IS the multi-backend bake-off orchestrator (pass
    args.backends, or leave empty to auto-discover):
    Freeze (oracle_freezer) -> Discover (op_benchmarker: probe + OFFLINE per-backend tune) ->
    parallel one kernel_lane worker per backend language over the GPU pool ->
    rank ALL candidates on the SAME frozen baseline and pick the fastest.
    Candidates: input-language optimize lane, each authored language, AND the tuned
    env backend (aiter/CK) -- all scored against the one frozen input kernel (anti-cheating).
- new roles/oracle_freezer.md: serving-agnostic freeze of a kernel dir into an
  immutable op task dir (golden output + speedup denominator = the input kernel itself).
- standalone GEMM/quant tune is preserved WITHOUT editing the e2e op_benchmarker role:
  the dispatcher prompt redirects Tier-B to run offline (shapes from the frozen oracle,
  engagement verified in the isolated unittest), skipping only pure server-flag levers.
- e2e footprint is limited to the kernel_workflow.js -> kernel_lane.js repoint
  (e2e_workflow.js + the expert-skills identity test); no other e2e file is touched,
  so nested callers hit the worker directly and the fan-out stays at one nesting level.
- README updated for the dispatcher/worker split, bake-off mode, and offline tune.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yueliu14
yueliu14 force-pushed the feat/kernel-workflow-mode-dispatch branch from 0fd3fb8 to 71beac3 Compare July 27, 2026 09:18
…rop the `auto` mode

Adds scripts/test_mode_dispatch.js — 38 assertions run against the REAL kernel_workflow.js
source with the Workflow runtime globals stubbed, so it spawns no agent and needs no GPU
(the runtime wraps a script body in an async fn; the harness rebuilds it the same way).

Covered:
- mode dispatch: default -> optimize, case/whitespace normalization, empty/null fallback,
  unknown mode THROWS (never a silent downgrade), every arg forwarded to the worker
  unchanged, required-arg validation.
- bake-off lane routing: the live language optimizes its existing impl while other
  languages follow Discover's author_plan.route (rewrite -> optimize, author -> author);
  explicit args.backends overrides auto-discovery; comma-string backends parse and
  normalize; no viable lane aborts cleanly; the winner is the fastest lane on the one
  frozen baseline.
- documents the `planByLang[lang] || 'author'` fallback: an explicitly requested backend
  that Discover did not plan gets AUTHORED even if an editable impl exists. Leave
  args.backends empty to let Discover pick the route.

Also:
- `auto` was never an implemented mode (kernel_workflow.js only accepts optimize|author|
  bakeoff) but a stale e2e_workflow.js comment advertised `mode=bakeoff/auto`. The
  multi-language fan-out is spelled `bakeoff` and only `bakeoff`; a negative assertion
  keeps `auto` rejected.
- meta.whenToUse omitted `author` entirely — the one field a caller reads to map intent to
  args.mode. It now describes all three modes and states plainly that there is no
  natural-language mode detection: the caller picks.

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