Skip to content

Next app rebased - #38

Merged
myrfy001 merged 7 commits into
masterfrom
next-app-rebased
Sep 29, 2026
Merged

myrfy001 merged 7 commits into
masterfrom
next-app-rebased

Conversation

@myrfy001

Copy link
Copy Markdown
Collaborator

No description provided.

Bsgg1 and others added 7 commits September 28, 2026 15:03
Adds `pi` (https://pi.dev) as a third agent backend alongside claude and
codex. The orchestrator invokes `pi --mode json -p` and reuses the
operator's local ~/.pi provider settings; MetaInfer stores no API keys.

orchestrator/subagent_manager.py
  - AgentBackend Literal gains "pi"; _normalize_agent_backend accepts
    pi / pi-coding-agent / earendil.
  - pi_bin constructor param; _build_pi_command maps the orchestrator
    effort knob onto pi --thinking (low/medium/high/max) and reuses the
    operator's configured provider/model.
  - pi session isolation: when state_dir is provided, --session-dir is
    scoped to <state_dir>/pi-sessions so orchestrator sessions are
    invisible to a user running `pi --continue` from their shell (pi
    indexes sessions by cwd; without this a user could attach to a
    production orchestrator session mid-flight and corrupt the context
    that later --session <id> --continue turns rely on). The session id
    is captured from pi's leading events for resume.

orchestrator/_bootstrap.py
  - make_subagent_manager gains pi_bin and state_dir; both resolve from
    args or env (METAINFER_PI_BIN, METAINFER_AGENT_BACKEND) with claude
    remaining the default. state_dir is forwarded only to the pi
    backend.

orchestrator/token_budget.py
  - usage_from_result_event tolerates pi's camelCase usage names
    (input / output / cacheRead / cacheWrite / cost.total) so a raw pi
    event is accounted correctly.

tasks
  - Every task orchestrator that builds a SubAgentManager now passes
    state_dir=state_dir so the pi backend can scope its session store
    per task (calc_value, find_low_hanging_kernel, gen_cpp_infer_framework,
    gen_infer_framework, gen_infer_framework_cpp, opt_kernel,
    dcu_kernel_auto_opt, evolve_kernel). opt_GEMM_kernel and port_model
    already wired it. Other backends ignore the kwarg.

docs
  - README (en/zh): document the pi backend, install, env vars and the
    effort->thinking mapping.

tests
  - test_subagent_manager covers pi command building, thinking-level
    mapping, session-dir scoping and resume-id capture.
  - test_token_budget covers pi camelCase usage parsing.
The detail page could open a library kernel's code, but the code was
rendered as a plain <pre> with no line numbers and no way to see what a
kernel actually changed relative to a baseline — the key question when
reviewing an evolved kernel is "what did it change, vs the original or
vs the kernel it was derived from?".

Add a diff endpoint and an inspector panel:

- _state_readers.py: read_kernel_source() resolves one library kernel by
  id; read_kernel_diff() produces a unified diff against the original
  reference kernel or against the kernel's parent_id. Missing kernels, a
  root kernel with no parent, and an evicted parent (library caps at
  MAX_LIBRARY_SIZE) return exists=false with a reason instead of raising.
- routes.py: GET /kernels/{kernel_id}/diff?base=reference|parent.
- ok-runtime-api.js: getKernelDiff() client.
- ok-detail.js: KernelInspector panel with Source / Diff vs reference /
  Diff vs parent modes, a line-numbered source renderer, and a colored
  unified-diff renderer with +/- stats. The parent mode is disabled when
  the kernel has no parent.
- ok.css: .ok-source* / .ok-diff* styles.
- test_kernel_diff.py: 11 tests covering both readers and their
  non-raising failure paths.

Co-Authored-By: deepseek/deepseek-v4-flash-0731 <deepseek-ai@claude-code-best.win>
Content imported from the DCU dev container tree (/root/zth_agent/MetaInfer),
3-way merged onto the merged PR #26 head so the next-app alignment and CI fixes
stay in place. Scope is limited to this task plugin.

Added:
- orchestrator: planner.py (+ planner_policy/manifest/gates), gate_policy.py,
  gpu_preflight.py, harness_io.py, predictions.py, validation_budget.py,
  variant_promote.py
- harness_default/: planner_catalog.yaml, planner_policy.yaml, manifest.yaml,
  gates.yaml
- reports/: best-variant tables (csv/json/xlsx) and the summary scripts
- skills/: int8-w8a8-gemm foundations/decode/prefill skill packs
- tools/baseline/: Triton INT8 benchmark harness, baseline graph JSONs
- 11 new test modules (planner, gate policy, gpu preflight, harness io,
  predictions, validation budget, variant promote, plan render, prompt schema,
  planner wiring, planner policy)
- retuned variant kernels for glm52/TP8 and hy3/TP4, refreshed WORKFLOW.md

Changed:
- gen_and_opt_pipeline.py, w8a8_pipeline.py, real_pipeline.py, pipeline.py,
  skill_store.py, variant_store.py, server/routes.py, static (detail view,
  shape input, css), form.yaml, bridge/dsh/dsh_agent.py, api/assets helpers
- PR-side fixes kept: init_or_resume(task_id) alignment (73c213c) and the
  CPU-only-CI torch guards (3d70f58) / hermetic dsh tests (6a8f235)

Excluded: *.bak-* kernel backups.
…tainer

Import metainfer/tasks/harness_evolve/ verbatim from the DCU development
container, so the AHE outer loop lives in the repository alongside the
DKAO task it drives.

Source: 10.8.160.17:/root/zth_agent/MetaInfer/metainfer/tasks/harness_evolve
        73 files, imported without local modification.

What this adds:
- FLOW.md / README.md: the fixed variant-round protocol (HE only launches
  DKAO tasks; measurement, GPU gate and contamination stay inside DKAO).
- orchestrator/: pipeline, decision_engine, evolve, rounds, promotion,
  champion_selection, supervisor, process_control, variant, pool.
- server/ + static/: the HE web surface (routes, plugin, he-api/detail JS).
- tests/: 33 tests including test_flow_contract.py, which keeps FLOW.md
  and the code in sync.

Scope note: this commit is material-only. The package is NOT wired into
the framework yet and is not expected to import cleanly on this branch —
it depends on host APIs that are not part of the DKAO-only PR lineage:
- metainfer.orchestrator.gpu_broker (not in this tree)
- metainfer.server.* (StateStore / forms / registry, next-app lineage)
- metainfer.tasks.dcu_kernel_auto_opt.orchestrator.{harness_io,variant_promote}
plus 11 hardcoded /root/zth_agent/... paths carried over from the container.

Follow-up: reconcile the host API differences and drop the skipif guards
that currently stand in for this module (see the DKAO sync guide).
The metric cards only surface the *last* iteration's speedup and the library's
current best, so a run that is stuck — or that regressed after a good
iteration — looks identical to one that is climbing, and the per-iteration
"goal" (what the optimizer set out to do) was not visible anywhere.

Add an "Iteration Progress" panel rendered from the already-fetched
`/iterations` payload: one row per iteration with status, exec time, speedup,
library size, duration and goal. Rows that set a new best exec time are marked
green with a "▲" tag — the "is it actually improving?" signal.

- export `formatMs` from ok-kernel-library.js so both tables share one
  formatter instead of duplicating it
- coerce `perf.speedup` with Number() before toFixed: the value is stored
  straight from an LLM-generated perf harness report with no numeric
  validation, so a malformed row now degrades to "—" instead of throwing
- add tests/test_iteration_progress.py pinning the reader fields the table
  renders, plus that a partially written iteration record does not take the
  whole list down
…ainer

Updates the task plugin to the latest container content
(/root/zth_agent/MetaInfer/metainfer/tasks/dcu_kernel_auto_opt), applied as an
incremental 3-way merge so the PR-side alignment fixes stay intact
(init_or_resume(task_id), CPU-only-CI torch guards, hermetic dsh tests).

Added:
- orchestrator/contention.py, orchestrator/round_strategy.py and
  harness_default/systemprompt/round_strategy.yaml
- tools/retest_variant.py, tools/baseline/tp8_m8_* (Triton m8 baselines)
- reports/: down-proj diagnostic scripts and tooling checks
- tests: test_contention, test_execution_profile, test_gpu_mode,
  test_retest_tool, test_round_strategy, test_shape_catalog_panel,
  test_ahe_child_embed

Changed: planner/gate_policy/gpu_preflight/harness_io/config/prompts,
gen_and_opt_pipeline, w8a8_pipeline, w8a8_baselines, server/routes, static
detail/shape panels, form.yaml, WORKFLOW.md, bridge/dsh.

Dependency guards (tests only):
Three features measured by this plugin live outside this PR's scope for now —
metainfer.orchestrator.gpu_broker (GPU broker leases), the DCU toolchain
(/opt/dtk/bin/hipprof PMC profiling) and the harness_evolve sibling task.
Eleven tests that require them are marked with pytest.mark.skipif via
importlib.util.find_spec / path checks (same convention as the torch guards),
so the suite stays green in CI and they re-enable automatically once those
modules land.
@myrfy001
myrfy001 merged commit b3f6505 into master Sep 29, 2026
0 of 4 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.

4 participants