feat(enablement): turn baseline accuracy failure into a self-healing enablement trigger - #1054
Open
ZhengGong-amd wants to merge 37 commits into
Open
feat(enablement): turn baseline accuracy failure into a self-healing enablement trigger#1054ZhengGong-amd wants to merge 37 commits into
ZhengGong-amd wants to merge 37 commits into
Conversation
…lidator, and state fields Add the shared foundation for routing a baseline accuracy-eval failure into enablement: - _accuracy_gate: canonical readers for INFERENCE_OPTIMIZER_ENABLEMENT_ON_EVAL_FAIL (default on) and INFERENCE_OPTIMIZER_ENABLEMENT_ACCURACY_FLOOR (finite [0,1], invalid -> warn + default); a strict score validator (None/non-numeric/NaN/Inf/ <=0/<floor all fail) with distinct failure kinds; and an eval-contract fingerprint helper. Result-dict key and kind constants for the executor and writeback to share. - integrate_patch: read the enablement accuracy floor from the canonical reader instead of a hardcoded module constant. - SharedState: eval-origin enablement carriers (origin, floor, probe config, contract fingerprint, evidence, kind, observed accuracy/task/metric, pending); additive dataclass fields, auto-persisted, resume-safe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…gger When a genuine first baseline runs single-node with the eval-on-fail flag enabled, an accuracy-eval failure now yields an explicit eval-failure contract instead of salvaging throughput or stopping the run: - __call__: an eval-rooted subprocess failure stamps the result with the contract (kind, evidence, floor, fingerprint) and returns, skipping the RUN_EVAL=false salvage retry. - _maybe_stop_on_missing_baseline_accuracy: a succeeded baseline whose accuracy is missing/non-finite/non-positive or below the floor is stamped and returns instead of calling request_baseline_accuracy_stop. - _eval_failure_evidence returns bounded evidence alongside detection; _is_eval_rooted_failure kept as a thin bool wrapper. - failure results now carry materialized_config/result_dir/run_eval_disabled so the contract can be fingerprinted and re-run. Flag-off and multi-node keep the existing salvage/stop behavior. Existing tests pin the legacy path via a flag-off fixture; new tests cover the routed path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…t the trigger Route an eval-failed baseline into enablement via the existing boot-fail machinery: - _is_promotable_result: a baseline result flagged baseline_eval_failed is not promotable (throughput is kept for diagnostics but never anchors); profile is unaffected. - _handle_unpromotable_result: persist the eval origin, floor, probe config, contract fingerprint, evidence, kind and observed accuracy, and seed enablement_launch_log so the pump dispatches. On a single-node eval-pending tick the baseline_failed stop is suppressed (the streak still advances so the pump can fire); multi-node keeps the strict backstop. - _promote_baseline: a genuine anchor clears the sticky eval-origin state. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lement chain Carry the eval origin, effective accuracy floor, probe config path and eval-contract fingerprint from SharedState to every downstream task so an eval-triggered enablement round keeps the original workload/eval contract: - framework: _enablement_carrier_params feeds the specialist params and the targeted-build launch probe; the launch probe prefers the eval probe config over the (unpromoted) baseline config. - explore: both autosubmit bridges forward the carriers onto the integrate task and bench against the probe config instead of the shipped default. - integrate_patch: the enablement runnable gate reads the threaded floor when present, else the canonical reader. Carriers live on resume-safe SharedState, so serial rearm, resume and the build->launch-probe path inherit them without extra plumbing. Boot-origin enablement is unchanged (carriers are empty). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The enablement runnable gate now enforces accuracy for eval-origin rounds: - eval-origin: a missing accuracy fails closed (REVERT) instead of a provisional KEEP; a finite score must be >0 and >= the effective floor to KEEP. - eval-contract fingerprint drift (dataset/task/metric/config changed vs the captured baseline contract) forces a REVERT so a score run under a different contract can never earn KEEP. - _bench_patch surfaces the observed task/metric and computes the candidate's contract fingerprint; the gate records origin, observed accuracy, floor, task/metric, fingerprint, drift and failure kind on every outcome. Boot-origin enablement is unchanged (missing accuracy stays provisional). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… before success An eval-origin enablement KEEP is no longer terminal: the patch passed the gate, but tput/accuracy only become official once a real baseline re-runs the original eval contract. - _maybe_rearm_enablement: eval-origin KEEP sets enablement_validation_pending (not enablement_succeeded) and keeps the stall streak so repeated KEEP->revalidation-fail cycles still reach the stall cap. - new _maybe_enqueue_enablement_baseline_revalidation pump enqueues exactly one genuine baseline with the probe config and RUN_EVAL on; the specialist pump is blocked while validation is pending. - _promote_baseline finalizes enablement_succeeded only when the revalidation baseline promotes with accuracy at/above the floor; a still-failing revalidation clears pending, reopens authoring, and counts a stall (capped by enablement_stalled). - close guard stays active while validation is pending, even with a stray tput. - new SharedState.enablement_validation_pending (resume-safe). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…surface in breakdown/docs Round out eval-origin enablement awareness across classifier, prompts, Critic, observability and docs: - classifier: add accuracy_below_floor (high priority) and eval_runtime_failure (lowest priority so a co-occurring import/serve-flag/tokenizer root cause still wins) kinds, seed keywords and ladder rows. - prompts: generalize the boot-only enablement framing to "boot or accuracy" in the specialist identity, mandate GOAL/invariants, domain description and the stale UNKNOWN-dispatch docstring; add an anti-gaming rule against altering the eval contract. - Critic: eval-origin enablement patches boot but may miss the accuracy floor; the downstream gate re-runs the accuracy eval, so approve on the structural bar without requiring a throughput before/after. - breakdown: EnablementBreakdown gains origin/trigger_kind/observed accuracy/ floor/task/metric/probe config/fingerprint/validation_pending, collected for eval-origin sessions. - docs: document INFERENCE_OPTIMIZER_ENABLEMENT_ON_EVAL_FAIL and INFERENCE_OPTIMIZER_ENABLEMENT_ACCURACY_FLOOR (env reference + .env.template) and the eval trigger in the optimization-loop conceptual doc. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a __call__-level test that a single-node eval crash with the flag on is stamped as an eval-failure contract (kind, origin, materialized config, fingerprint) with no RUN_EVAL=false salvage retry, closing the last gap in the eval-origin capture matrix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…and fingerprint Direct coverage for the eval-accuracy foundation: the on/off flag, the floor reader's finite-[0,1] validation and fallback, the accuracy validator across None/bool/str/NaN/Inf/negative/zero/at-floor, the failure-kind classifier, and the eval-contract fingerprint's stability, config-byte sensitivity and missing-file safety. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the config-bytes+task/metric fingerprint with one derived from stable YAML contract fields (framework, model, script, precision, workload shape, RUN_EVAL, MAGPIE_EVAL_TASKS/LIMIT). Result-level task/metric are excluded so an eval crash and a successful eval on the same workload produce identical fingerprints. Missing or unreadable configs return an empty string (invalid) that the gate treats as fail-closed. Persist MAGPIE_EVAL_TASKS and MAGPIE_EVAL_LIMIT into the materialized YAML so bypass_runner reads them from the YAML-layer authority rather than os.environ, making them trackable by the fingerprint. For enablement runs in integrate_patch, force RUN_EVAL=true onto the variant envs after all overlays are applied so no candidate can suppress it. Preserve list/dict structure in runtime_override (stop coercing nested values to str before apply_runtime_override sees them). Compute the candidate fingerprint unconditionally at bench time (not only on success) so an eval-crash round still produces a comparable digest. Update tests to verify server-arg changes do not drift the fingerprint, workload/eval-control changes do, crash and success produce identical digests, and missing configs return the empty invalid sentinel. Co-authored-by: Cursor <cursoragent@cursor.com>
Add enablement_accepted_config_path to SharedState to record the actual materialized config from the KEEP'd candidate bench. This is the config with server fixes already baked in, distinct from the original trigger probe config. integrate_patch now carries this path in the KEEP result so _maybe_rearm_ enablement can persist it. _maybe_enqueue_enablement_baseline_revalidation prefers the accepted config over the probe config when launching the genuine baseline, and also picks up the KEEP'd FrameworkRuntime to set runtime_override on the revalidation task. baseline._run_once applies runtime_override from params into the materialized YAML so the revalidation baseline boots under the same framework runtime (PATH/PYTHONPATH/framework_bin) as the KEEP'd candidate. Also carry the materialized config path in _bench_patch's bench result so the gate can surface it in the KEEP result. Tests verify that accepted_config_path takes precedence over probe_config, that active runtime override is propagated, and that both fields survive save/load roundtrip. Co-authored-by: Cursor <cursoragent@cursor.com>
Add enablement_revalidation_task_id and enablement_revalidation_generation to SharedState. Each eval-origin KEEP increments the generation so the next revalidation window gets a fresh idempotency key, preventing silent reuse of terminal TaskRegistry rows. _maybe_enqueue_enablement_baseline_revalidation now checks if the tracked task is still alive before creating a new one, and persists the new task_id immediately after creation. The old baseline_tput > 0 short-circuit is removed; a positive baseline tput is not a valid reason to skip enqueuing a revalidation for a pending KEEP. _promote_baseline is now task-aware: it only finalizes enablement when the promoting baseline matches the tracked revalidation task_id or carries the "enablement_eval_revalidation" reason. An unrelated baseline only anchors tput; it does not consume the pending state. Sub-floor accuracy on the tracked task increments the stall streak and reopens the specialist loop without clearing the frozen trigger identity. All non-success outcomes of the tracked revalidation task (boot failure, OOM, timeout, sub-floor accuracy) now share a unified recovery path in _handle_unpromotable_result that clears pending, clears the tracked task_id, increments stall, and rearns the specialist loop, bounded by the existing _ENABLEMENT_MAX_STALL cap. _resume_consistency_pass gains a new _resume_recover_pending_revalidation step: on restart, if the tracked revalidation task is already terminal or missing, the pending flag is cleared and stall is incremented so a fresh revalidation can be dispatched. Tests cover: tracked-task-only finalization, unrelated baseline isolation, sub-floor rearm, boot failure recovery, generation increment, resume cleanup, and the aligned stale-tput semantics. Co-authored-by: Cursor <cursoragent@cursor.com>
collect_enablement now detects eval-origin sessions via enablement_baseline_eval_kind (which is not cleared on success) rather than relying solely on the active enablement_origin (which is reset to "" after successful promotion). This means the trigger_kind, observed accuracy, floor, contract fingerprint and probe config remain visible in session_breakdown.json even after the revalidation baseline promoted. Add succeeded and revalidation_task_id to the EnablementBreakdown schema and to the collector, exposing the final validation outcome and the tracked revalidation task identity. Add accepted_config_path to the schema so the accepted (post-fix) config used for revalidation is surfaced alongside the original probe config. Record richer eval-verdict fields in _promote_integrate_patch audit_extras (correctness_verified, eval_kind, observed_accuracy, drift flag, provisional) so the integrate_patch attempt history carries per-round accuracy verdicts. Record revalidation context in _promote_baseline audit_extras (is_revalidation, enablement_succeeded, floor) so the baseline attempt history tracks which promotions are revalidations and what their outcome was. Update .env.template comment to clarify score==floor pass semantics, strict-positive-required invariant and single-node scope. Tests verify: history is preserved after origin is cleared; succeeded flag is exposed correctly; combined origin/succeeded state works end to end. Co-authored-by: Cursor <cursoragent@cursor.com>
… max position lookup Add "model_max_length" to _MAXPOS_CONFIG_KEYS so the gate can resolve max position embeddings from HuggingFace tokenizer_config fields and custom models such as kimi_linear.
…chor A genuine baseline exists to establish the accuracy reference, but _maybe_stop_on_missing_baseline_accuracy let any run that had turned the eval off skip the guard entirely. Orchestration found that door: after a baseline measured throughput fine but failed the accuracy gate (so it was correctly not promoted), the LLM re-proposed the same baseline with disable_run_eval=true purely "to set baseline_tput on throughput", the Critic approved it, and the eval-less retry anchored the run. That single promotion poisons everything downstream. The materialized YAML it writes carries RUN_EVAL=false and becomes SharedState.baseline_config_path, which later explore/integrate tasks inherit as their config_path, so their variants render with the eval off too. baseline_accuracy stays 0.0, and both _grade_accuracy and _framework_run_eval_envs key on baseline > 0, so the per-variant accuracy gates silently degrade to throughput-only KEEPs. Remove the opt-out. Disabling the eval does not make a missing accuracy acceptable; it only means the reference was never measured, which is exactly what the guard exists to reject. With eval-on-fail enablement active (the default) the result is stamped as an eval-failure contract and routed to enablement, and _is_promotable_result then keeps it from anchoring baseline_tput / baseline_accuracy / baseline_config_path. This also removes the incentive: disable_run_eval no longer buys a baseline_tput at all. The kernel lane drives this same executor through synthetic tasks that carry kind="baseline" literally (integrate re-baseline, the paired-A/B pristine arm, stack validation). Those are throughput-only A/B probes against an already-anchored baseline and must not be caught by the guard -- stack validation in particular passes the live SharedState, so a missing accuracy there would have dragged a healthy run back into enablement. They now opt out via params["quality_ref_exempt"], handled in _should_establish_quality_ref so the exemption also stops them from overwriting the scriptable image-quality reference via establish_quality_ref -- previously a patched candidate could redefine the very reference it was being judged against. Verified by replaying the two real baselines from the Kimi-Linear-48B session (20260726T162542Z) through the fixed path: both now report promotable=False, where the eval-less retry previously promoted and anchored baseline_tput.
Bringing up Kimi-K3 (1454 GiB MXFP4 MoE, vLLM, TP=8) from scratch failed at two separate gates before any measurement could happen. install.sh (both the inference_optimizer entrypoint and the chained kernel-agent one) rejected the single-gateway SAFE_API_KEY + OPENAI_BASE_URL setup that SKILL.md documents as the common deployment and that the CLI's own _validate_credentials() accepts, so IR-2 could never pass. Derive the Anthropic aliases from the gateway pair the same way _resolve_llm_endpoints() does (strip a trailing /v1, reuse the gateway key), with explicit values still winning. The baseline executor bumped its subprocess timeout on COLD_START but left Magpie's server_ready_timeout_s at the flat 2700s default, so the inner gate always fired first and the cold-start bump was unreachable for any slow-booting model. A healthy server 82% through loading weights was killed at 2881s and reported as subprocess_nonzero, then leaked its VRAM and cascaded the next attempt into server_init_dead. Weight loading dominates boot on large checkpoints and scales with bytes, not with aiter JIT warmth, so size the budget from the checkpoint instead: models under 200 GiB keep the old default, larger ones add an allowance at a pessimistic 0.20 GiB/s floor, capped at 6h so a genuine hang still times out. Because this lands in inject_lifecycle, explore/sweep/integrate rounds benefit too. Also floor the subprocess timeout above the boot budget so the outer kill can no longer preempt a legitimate load. test_aiter_jit was reading $MODEL_PATH from the ambient shell, which now changes the resolved timeouts; pin it hermetic. Co-authored-by: Cursor <cursoragent@cursor.com>
… defaults Catch microbenchmark timeouts during gpu_arch_json population, derive the PR Monitor MCP URL from PRIMUS_CORTEX_PR_API, support grouped run_lm_eval parsers for --concurrent-requests, and skip commit-on-KEEP for non-git framework roots. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve conflicts in baseline executor, magpie patcher, and eval-fallback tests by combining main's eval-concurrency hardening, MoE runner fallback, and fail-fast baseline path with this branch's eval-on-fail enablement routing. Co-authored-by: Cursor <cursoragent@cursor.com>
…he eval A baseline that never ran the eval characterizes nothing: it lands in _persist_eval_failure as accuracy_unavailable with no task/metric/source. Because that path wrote every field unconditionally, such a round overwrote a stored accuracy_below_floor trigger -- so the next enablement attempt lost the very measurement it was supposed to reproduce. Make the overwrite one-way. An incoming accuracy_unavailable that carries no observed accuracy now leaves the stored characterization intact, while still registering the round as an eval-rooted failure (origin, pending, and the stall accounting that lets enablement_stalled terminate). A real measurement still replaces an earlier empty trigger. Contract fingerprints cannot gate this: RUN_EVAL is itself a contract field, so the eval-less run's fingerprint never matches the measured one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Resolves the single conflict in inference_optimizer/cli/parser.py, an adjacent-edit collision at the top of the module: - This branch added `_default_pr_monitor_mcp_url()` immediately above `class _RetiredFlag`, deriving the PR Monitor MCP URL from `$PRIMUS_CORTEX_PR_API` so one env var wires both the REST client and the specialist MCP server. - main (lean-5 dead-code sweep) deleted `_RetiredFlag` along with its only user, the retired `--enable-proposal-scoring` flag. Both edits are kept as intended: the helper stays, `_RetiredFlag` goes. The class is genuinely dead afterwards -- main already rewrote test_retired_enable_proposal_scoring_flag_rejected to expect argparse's native "unrecognized arguments" error rather than the custom migration hint, and no other call site references it. Everything else auto-merged. Verified that for each of the six files touched on both sides (parser.py, shared_state.py, coordinator.py, writeback.py, kernel/request_handlers.py, specialist_prompt_builder.py, test_shared_state_evolution.py) the merged content equals main's version plus exactly this branch's delta, with no line main added missing and no line main deleted resurrected. Confirmed no surviving reference to anything main retired (`_RetiredFlag`, `--legacy-action-scores`, `--migration-mode`, the dropped `load_or_init`/`from_dict` kwargs, and the helpers consolidated into `common.gain_math` / `common.jsonio` / `_grid_base` / `patch_path_safety`), and that main's `--pd-mode colocated -> aggregated` rename has no stale consumers. Nothing from main needed manual mirroring onto this branch: the two sides touch disjoint files under `phases/` and `docs/`, and pyproject.toml is unchanged from main. Checks: whole-package import sweep clean (0 failures); the enablement / accuracy-gate suites this branch owns pass (236 passed); parser smoke test confirms `pd_mode=aggregated`, `--enable-proposal-scoring` exiting 2, and `PRIMUS_CORTEX_PR_API` resolving to `<base>/mcp/`. The 3 pre-existing failures in test_cli_backends_unit.py reproduce identically on a clean origin/main worktree -- they are local-env artifacts (ANTHROPIC_BASE_URL set in the shell), not merge fallout. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The cold-start guard splits one baseline into two rounds: warmup_round runs with RUN_EVAL=true and is the only round that measures accuracy, while measure_round runs with RUN_EVAL=false to get a hot throughput number off the already-warm server. The accuracy decision is then made on the measure_round result, which by construction never carries an accuracy. With enablement active (INFERENCE_OPTIMIZER_ENABLEMENT_ON_EVAL_FAIL=1, the default) that missing value hit the enablement branch first and dispatched an authoring specialist to chase a quality regression that never happened. The sibling-salvage path that already exists to recover exactly this value sat below the branch's `return` and was unreachable, so baseline_tput was never anchored and the run spun in PRELUDE at gain 0 for the rest of its budget. Move the salvage ahead of the enablement branch so a sibling round's score is recovered first. A salvaged score at/above the floor anchors the baseline as usual; one below the floor is a real quality signal and still falls through to enablement, now with the observed value instead of None. Observed on Kimi-K3 (vllm, mi355x, mxfp4, TP=8): measure_round reported 1452.7 tok/s/GPU with no accuracy while warmup_round held gsm8k 0.8954, and the run stalled. After the fix the same session anchors baseline_tput=1444.4 with baseline_accuracy=0.9287. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…t-sec The flag is declared as ``--framework-discover-timeout-sec``, so argparse stores it on ``args.framework_discover_timeout_sec``. The wiring read ``args.framework_agent_discover_timeout_sec`` instead, which never exists, so ``getattr`` fell through to its 0.0 default and the override was silently discarded -- passing the flag had no effect at all. Consequence: discovery always ran on DEFAULT_FA_PHASE_TIMEOUT_SEC (180s), which phases/framework.py then divides across the repo list. With six repos that is 30s each, matching the floor in _FRAMEWORK_MIN_PER_REPO_TIMEOUT_SEC, while one real ``fa phase-discover`` call (Primus Cortex query + LLM ranking) needs ~60s. On 2026-07-29 every GitHub repo timed out at exactly 30.0s and the phase ran on Primus Cortex results alone; re-running a failed request by hand returned rc=0 with 9 candidates, confirming a budget shortfall rather than a broken call. Read the parser's dest first and keep the longer name as a fallback for callers that set the attribute directly. Verified: --framework-discover-timeout-sec 900 now resolves to 900.0 (150s per repo across six repos), and omitting the flag still yields 0.0 so the 180s default path is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both framework KB writeback paths left accuracy_delta_pct at 0.0. integrate_patch looked the value up in the specialist payload, which never carries it, and framework_agent did not pass the field at all. Every lessons.jsonl row therefore claimed the candidate had no accuracy impact. The measured score was already in scope at all five call sites: _bench_patch returns it as gate_evidence["accuracy"], and the baseline is resolved a few lines above for the KEEP gate. Derive the delta from that pair and pass it through; the payload lookup stays as the fallback when a caller has nothing to supply. Observed on Kimi-K3 (vllm, mi355x, mxfp4): AITER_SITUV2_A8W4 dropped gsm8k from 0.9060 to 0.0008 and was reverted, yet the ledger recorded accuracy_delta_pct 0.0 alongside tps_delta_pct +5.07 -- reading as a purely throughput-driven revert. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
prior_score summed tps_delta_pct across every associated record regardless of outcome, so a candidate that was reverted for destroying accuracy still raised the prior of the next candidate matching its gap. Accuracy was not an input to the score at all. Count throughput only from records that were actually integrated, and scale the result down by the associated share that regressed accuracy. Genuine KEEPs are unaffected; a gap whose history is entirely accuracy failures now scores 0. Measured against the Kimi-K3 ledger: a reverted +5.07% record with a -99.9% accuracy delta scored 0.2887 for an unrelated new candidate and now scores 0.0, while an integrated +6.0% record still scores 0.755. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A specialist may reduce an upstream PR to a set of server args and envs, and distinct PRs routinely reduce to the same set. The KB is keyed by pr_url and pr_sha, so those retries looked like new candidates and were benchmarked again. Record the canonical fingerprint of the applied args / envs in the record's applicability field, and check it before routing a config-lever deliverable to integrate_patch: a fingerprint whose ledger entry shows an accuracy regression is skipped. The gate reuses canonical_fingerprint, the same hash the explore ledger dedups on, so the two cannot drift. It is advisory -- any lookup error falls through to the existing dispatch path. Observed on Kimi-K3 (vllm, mi355x, mxfp4): ROCm/vllm PRs 970, 899 and 1066 each reduced to AITER_SITUV2_A8W4, and each spent roughly 95 minutes rediscovering that it drops gsm8k from 0.9060 to 0.0008. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… eval origin by candidate's own task/metric The enablement KEEP gate defaulted its accuracy floor to 0.0, so it degenerated to `accuracy > 0` and once KEPT a candidate scoring gsm8k=0.00076 (0.08% of a 0.906 baseline). Raise the default floor to 0.05 so collapsed-output models are rejected when no operator override is set. Also remove the eval-contract fingerprint drift veto. The stored fingerprint could be poisoned by an eval-less re-baseline, causing every later candidate to be reverted without ever reading its accuracy. Instead, require an eval-origin score to carry the task and metric stamped by the candidate's own run; a bare number with no provenance fails closed. Update tests and writeback to match.
Removing the fingerprint drift veto left its producer and carrier chain with no consumer. The candidate-side digest is computed on every enablement round, threaded through gate_evidence, and read by nothing; the two carrier hops that forwarded the trigger's digest into the integrate task are likewise dead -- correctness is now judged from the task/metric the candidate's own run stamps beside its accuracy. Delete the producer, the gate_evidence key and both carrier hops. The nested enablement/succeeded conditions collapse into one now that the digest no longer has to be computed regardless of bench outcome. The trigger-side chain stays: baseline stamps the digest, writeback persists it and the breakdown collector reads it, so session_breakdown.json keeps emitting eval_contract_fingerprint unchanged. It is diagnostic-only now -- no code path gates on it. Verified in a clean worktree at eae18d5: same 8212 passed, and the 13 pre-existing environment-dependent failures are identical before and after. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…_failed A specialist routinely writes both a superset patch and the subset it contains -- e.g. an FLA state-layout revert, plus that same revert bundled with the config fix that is the other half of the same enablement. Whichever lands first makes the other's hunks a no-op, and both POSIX `patch` and `git apply --check` report that with a non-zero exit indistinguishable from "does not apply". The executor read it as a hard failure, aborted the combo and reverted a fix that was in fact fully and correctly applied. That cost a real 7-hour run: the Kimi-Linear-48B enablement specialist had root-caused the vLLM 0.20.0 KDA breakage and validated the two-part fix at gsm8k 0.875 (from 0.0008), and it was thrown away at apply time. The lost round pushed the stall streak to its cap and the session stopped at `enablement_stalled` with baseline_tput=0. Resolve the ambiguity with a reverse dry-run, which succeeds only when every hunk's post-state is already in the tree -- exactly what a forward apply would have produced. Fully satisfied => success with no backups (the patch that made the edits owns the backups a revert needs). Partial overlap and non-applying patches keep failing with reauthor feedback, so the narrow no-op cannot swallow a real edit. Also close stdin on the `patch` invocations: it prompts "Assume -R? [n]" on an already-applied hunk and could otherwise block until the 60s timeout. The three failures in the touched trees (artifact stash, isolated venv, specialist gpu gate) are pre-existing and environment-dependent -- identical before and after this change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The KB writeback read gate_evidence["accuracy"], a key _bench_patch never emitted: it graded the eval into an accuracy_pass bool and dropped the score. The raw value survived only on the enablement branch. accuracy_delta_pct therefore stayed 0.0 on every record even after the delta was threaded through. Parse the score alongside the existing grade and return it as gate_evidence["accuracy"]. The baseline side had the same gap -- it only fell back to shared_state.baseline_accuracy when the accuracy gate was required -- so read that fallback unconditionally for the record. Observed on Kimi-K3 (vllm, mi355x, mxfp4): ROCm/vllm PR 1045 dropped gsm8k to 0.0015 against a 0.8393 baseline and was reverted, yet its record still carried accuracy_delta_pct 0.0, leaving the fingerprint dedup gate nothing to match on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…d import The enablement-gate docstring still described the pre-eval-origin behaviour: "accuracy is None -> correctness_ok=None (KEEP but provisional)". Since 25f8d6e that is only true for boot-origin; an eval-origin candidate with no score fails closed, because the trigger *was* an accuracy failure and a candidate producing no score has not shown it fixed anything. The docstring also omitted the eval-origin task/metric requirement entirely. Document the verdict per origin, and say why the two differ. `import math as _math` in the same function lost its last use when the NaN branch folded into accuracy_meets_floor() / classify_accuracy_failure(). Found reviewing the branch's 29 commits after merging origin/main. Docs and an unused import only -- no behaviour change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ng/enable-accuracy
dd26917 sized the server-boot budget from checkpoint bytes because a 1.4 TiB MXFP4 MoE was being killed mid-load at the flat 2700s default. That failure mode is gone: the boot path no longer needs the allowance, so the scaling is dead weight on every model that reaches the executor. It was also only ever reachable above CHECKPOINT_SCALING_MIN_GIB (200 GiB) -- every checkpoint below that already took the flat default unchanged, so the revert is a no-op for them by construction. Verified against the live Kimi-Linear-48B run (92 GiB): resolve_server_ready_timeout() returned the plain 2700s and the materialized lifecycle YAML carries server_ready_timeout_s 2700, i.e. the removed code never fired. Removes resolve_server_ready_timeout / _checkpoint_size_gib and their constants, the _apply_server_ready_floor subprocess-timeout floor, and the test_aiter_jit fixture that existed only to keep the ambient $MODEL_PATH from perturbing the scaled timeouts. No references remain. Deliberately NOT reverted from the two [Temp] commits, having checked each against the current code and the live session: - install.sh single-gateway credential derivation (dd26917). Not dead: .env.template ships SAFE_API_KEY + OPENAI_BASE_URL uncommented as the default with the ANTHROPIC_* block commented out, so removing it breaks IR-2 for anyone following the documented setup. - integrate_patch non-git commit-on-KEEP skip (c203474). Live right now: this session's framework root is a pip-installed vLLM in site-packages with no .git, where the old path fails `git add` with rc=128 and logs a spurious commit-on-KEEP failure on every enablement KEEP. - tracelens_arch_benchmark timeout catch (c203474). A microbench overrun raises subprocess.TimeoutExpired, not RuntimeError, so without it trace_analyze dies instead of taking its fallback. - _magpie_patcher grouped run_lm_eval parser (c203474). Superseded and extended by 3166da7 / b4fd4b7 / 74b549e / 1f63b48, all already in origin/main; the file is now byte-identical to main and owned upstream. 729 passed / 1 skipped across the baseline, lifecycle and magpie test subset. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
resolve_build_ref() understood PR URLs and bare "PR:{n}" refs but had no
branch for issues, so an "issue:{n}" string fell through to the plain
tag/branch/sha case and was handed to `git worktree add` verbatim. An issue
is a discussion thread, not a branch: GitHub publishes refs/pull/{n}/head for
a pull request but nothing checkoutable for an issue, so the build aborts in
workspace preparation with `fatal: invalid reference: issue:41292`.
Observed live on the Kimi-Linear-48B run: the enablement specialist correctly
root-caused the KDA chunked-prefill state-layout defect, requested a
from-source vLLM build, and cited upstream vllm issue 41292 as the rationale.
The build died 123s in, before compiling anything, and the round was lost.
Citing an issue is a normal and useful signal, so drop the issue number rather
than reject the request: an empty ref makes the builder autoselect the newest
matching tag, which is where an issue fix would have landed anyway. Handle
both the bare "issue:{n}" / "issues:{n}" form and a full issue URL, keeping
the URL as source provenance so the audit trail retains the citation.
The caller in phases/framework.py merged the result with `ref = _ref or ref`,
which would have restored the very string resolution had just rejected. Take
the resolved ref verbatim, empty included -- empty now carries the meaning
"not checkoutable, autoselect a tag".
The 7 failures in the touched trees (test_cli_backends_unit,
test_preflight_auth_override) are pre-existing and environment-dependent --
identical with this change stashed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CI E2E report — ❌ Failed
|
…r docs Two review P0s on #1054. test_setup_cli: the single-gateway branch added by this PR reads ${SAFE_API_KEY:-} in memory to derive ANTHROPIC_BASE_URL/ANTHROPIC_API_KEY (mirroring the CLI's _resolve_llm_endpoints), which tripped a blanket "SAFE_API_KEY:- not in script_text" assertion and broke CI. The invariant that test exists to protect is that the gateway credentials are never *persisted* -- not that they are never read. Scope the assertions to write_env_file() accordingly, and additionally pin the scrubbing behaviour (remove_dotenv_var for SAFE_API_KEY / OPENAI_BASE_URL / OPENAI_API_KEY) so a regression that starts writing them back out still fails. docs/template: DEFAULT_ENABLEMENT_ACCURACY_FLOOR moved 0.0 -> 0.05 in this PR, but .env.template and the environment-variables table still advertised 0.0. Sync both and spell out the semantics the code implements: a score of exactly 0.0 fails regardless of the floor, otherwise score >= floor passes, and the default is a collapse guard rather than a quality bar.
ZhengGong-amd
force-pushed
the
feat/zgong/enable-accuracy
branch
from
July 30, 2026 11:44
9597e1b to
6f94aa1
Compare
ZhengGong-amd
marked this pull request as draft
July 30, 2026 12:01
The whitelist gating parse_reference_script covered the AITER and NCCL channel knobs but not three switches the Kimi-K3 MI355X recipe sets: VLLM_ALLREDUCE_USE_FLASHINFER, VLLM_USE_RUST_FRONTEND and NCCL_DMABUF_ENABLE. A recipe carrying them lifted its serve flags but no envs, so the baseline never recorded them and EXPLORE had no ablation handle for them. All three are boolean serving switches, matching what the list already holds. Deliberately left out: VLLM_ENGINE_READY_TIMEOUT_S, a startup-wait bound with no throughput effect — lifting it would only add a meaningless ablation axis. The list stays an explicit enumeration rather than a VLLM_* glob, so path-valued and secret vars are still excluded; the existing VLLM_CACHE_ROOT / SOME_SECRET assertions cover that and are unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ZhengGong-amd
marked this pull request as ready for review
July 31, 2026 08:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hyperloom only entered the enablement path when the model failed to boot. But on ROCm there is a more common — and more dangerous — class of failure:
That failure was silent. Take Kimi-Linear-48B-A3B-Instruct: vLLM 0.20.0's KDA path corrupts recurrent state under batched concurrency, so baseline throughput sits at a completely healthy ~6600 tok/s while gsm8k scores 0.0038. The old logic had two possible outcomes, and neither was right:
stop_reason=baseline_accuracy_failed, the whole run halts, no repair is attempted.cumulative_gainis fiction.This PR makes a third outcome the default: treat accuracy failure as an enablement trigger, dispatch a specialist to localize and fix it, then re-verify with a genuine baseline and only accept the fix once that passes.
What changed
1. Accuracy failure becomes an enablement trigger
eval_runtime_failure/accuracy_unavailable/accuracy_below_floor.SharedStateand threaded down the enablement chain to the specialist, so it knows which eval contract it has to reproduce.INFERENCE_OPTIMIZER_ENABLEMENT_ON_EVAL_FAIL(on by default).2. An eval-failed baseline may not anchor
This is the safety floor of the PR. A baseline that failed eval is stopped by
_is_promotable_resultand never writesbaseline_tput/baseline_accuracy/baseline_config_path, so nothing can "chase gains against garbage output".The bypass routes are closed too:
disable_run_evaland an explicitRUN_EVAL=falsecan no longer launder "accuracy was never measured" into "accuracy is acceptable".3. Accuracy floor raised from 0.0 to 0.05
ENABLEMENT_ACCURACY_FLOORwas0.0while the KEEP gate isaccuracy > floor— which reduces to "anything non-zero counts as correct". A real run once KEPT a candidate at gsm8k 0.00076 (0.08% of a 0.906 baseline) as correct.The new
0.05default is only a backstop: it rejects the collapsed regime where the model answers essentially nothing, and makes no quality judgement (that belongs to the operator'sINFERENCE_OPTIMIZER_ENABLEMENT_ACCURACY_FLOORoverride). The same floor is shared by the trigger side and the KEEP side, so the two cannot drift apart.4. An eval-origin KEEP requires genuine-baseline revalidation
Even when an eval-origin candidate produces a passing accuracy inside the gate, that is still only the candidate's own single measurement. A new
enablement_validation_pendingwindow holds the KEEP: it re-runs a real baseline with the accepted config, andenablement_succeededis set only once that promotes. A failed revalidation counts toward the stall cap, so it cannot loop forever.5. "Did the eval actually run?" is now judged from the candidate's own task/metric
An earlier version used an eval-contract fingerprint as a drift veto — but
RUN_EVALis itself one of the hashed contract fields, so a single re-baseline that skips the eval poisons the stored digest and then vetoes every subsequent candidate without ever looking at its accuracy. That is precisely how a correct fix was thrown away in a real run.The check now reads the
task+metricthat the candidate's own run recorded (stamped right next to its accuracy value): a score with no task/metric did not come from a real eval, so it fails closed. The fingerprint chain is retained but demoted to diagnostic only — it gates nothing.6. An already-applied patch counts as satisfied, not as an apply failure
Specialists routinely write both a superset patch and the subset it contains (e.g. "FLA layout revert" and "FLA layout revert + config fix"). Whichever lands first turns all of the other's hunks into no-ops — and POSIX
patchandgit apply --checkreturn exactly the same code for "already applied" as for "does not apply".The old logic called that a hard failure, reverted the entire combo, and discarded a fix that had been completely and correctly applied. On Kimi-Linear this destroyed a 7-hour run: the specialist had already localized two defects and taken gsm8k from 0.0008 to 0.875, only for the fix to be thrown away at apply time. That round drove the stall streak to its cap and the run ended at
enablement_stalledwithbaseline_tput=0.The fix disambiguates with a reverse dry-run (both channels changed): a reverse apply only passes cleanly when every hunk's target state is already present — which is exactly the state a forward apply would produce. Fully satisfied → success, and no backups are recorded (backups belong to the patch that actually made the edits, so a revert does not double-restore). Partially overlapping and genuinely non-applying patches still fail, with reauthor feedback, so this no-op cannot swallow a real change.
Also closed stdin on the
patchinvocations — it promptsAssume -R? [n]on an already-applied hunk and could otherwise block until the 60s timeout.7. KB records the real accuracy delta
Nothing ever wrote the
gate_evidence["accuracy"]key (_bench_patchgraded the eval into a bool and dropped the score), soaccuracy_delta_pctwas permanently 0.0 and the fingerprint dedup gate had nothing to match on. The raw score is now parsed out alongside the grade; the baseline-side fallback is read unconditionally too.Supporting changes: reverted and accuracy-losing candidates no longer count as "gained"; config-lever deliverables are deduped by content fingerprint.
8. Independent fixes carried along
.env.templateshipsSAFE_API_KEY+OPENAI_BASE_URLas the default (theANTHROPIC_*block is commented out), butinstall.sh'spreflight_validate_credentialsonly recognizedANTHROPIC_*, so an operator following the documented setup could not pass IR-2. It now derives them the same way the CLI's_resolve_llm_endpoints()does; explicit values still win..git, and the old logic rangit addunconditionally and failed withrc=128, logging a boguscommit-on-KEEP failedwarning on every enablement KEEP. Durability for such roots is already provided bysnapshot_source_layer.subprocess.TimeoutExpired, notRuntimeError; the old code caught only the latter, so the wholetrace_analyzedied instead of taking its documented fallback.model_max_length.--framework-discover-timeout-secread the wrong argparse dest.9. Reverted: checkpoint-scaled server-ready timeout
dd2691728scaled the server boot budget by checkpoint bytes (to stop a 1.4 TiB MXFP4 MoE being killed under the 2700s default). That failure scenario no longer exists, so the whole thing is reverted (5238a8693).The logic only ever engaged above 200 GiB; checkpoints below the threshold always took the original
2700sdefault, so for the vast majority of models it was a no-op by construction. Verified on the live Kimi-Linear-48B run (92 GiB):resolve_server_ready_timeout()returns2700and the materialized lifecycle YAML also carries2700— the removed code never fired.Scope
5238a8693revert)INFERENCE_OPTIMIZER_ENABLEMENT_ON_EVAL_FAIL,INFERENCE_OPTIMIZER_ENABLEMENT_ACCURACY_FLOOR(both documented indocs/reference/environment-variables.md)SharedStategains 14enablement_*fields; theenablementsection ofsession_breakdown.jsonis extended to match (schema updated)origin/main(including the forge/installFORGE_PATHconsolidation).install.shhad one overlapping region; the auto-merge result was reviewed by hand.Behavioral changes (please focus review here)
INFERENCE_OPTIMIZER_ENABLEMENT_ON_EVAL_FAIL=0for the old behavior.INFERENCE_OPTIMIZER_ENABLEMENT_ACCURACY_FLOORexplicitly.correctness_oksemantics fork by origin: when accuracy isNone, eval-origin fails closed (the trigger was an accuracy failure, so producing no score does not count as fixed) while boot-origin stays provisional (it only ever promised to make the model boot, and must not block eval-less runs).Verification
test_artifact_install_failed_restores_user_stash,test_isolated_venv_discovers_plan,test_bench_specialist_without_explicit_needs_gpu_is_gated. Additionallytest_build_backends_kernel_codexalso fails standalone on the merged-inccda68204.accuracy_below_floor→ anchoring refused → enablement specialist dispatched, with the trigger evidence carrying a complete task/metric.Follow-ups / open items
c20347403anddd2691728still carry[Temp]/[temp]prefixes. Their contents have been reviewed hunk by hunk: the parts that went stale are reverted by5238a8693, and the rest (single-gateway credential derivation, non-git commit skip, microbench timeout capture) is still live logic. Only the titles need changing — recommend renaming before merge.patch -Ncould apply only the missing hunks, but that requires parsing reject files and carries more risk; deferred to a separate evaluation.