← Back to Pull requests

feat: write AgentX E2E accuracy as aisim-eval records #1171

Open
simone-chen opened this pull request with 650 lines diff across 8 files
View on GitHub
simone-chen simone-chen commented on Dec 04, 2026 05:08 UTC
Author

Why and what changed

AISim can write step accuracy as aisim-eval/v1 records (write_step_eval_records.py), but there was no in-repo writer for end-to-end AgentX serving accuracy. This PR adds scripts/fpm_accuracy/write_e2e_eval_records.py next to the step writer.

It reads the AgentX benchmark bundles of one serving configuration and the engine replay of each point. It writes two records, one for TTFT (ttft_ms) and one for TPOT (tpot_ms).

Inputs (one --point per lane count):

  • silicon: an AgentX benchmark bundle directory, read by aisim_core.data.agentx_convert. All bundles must be one serving configuration.

  • prediction: the engine replay output directory of scripts/e2e_accuracy/agentx_predict.py (native.json, compiled-replay.json, config.json, outcome.json), as agentx_cache_points.py run and run_agentx_accuracy.py run write it.
  • Scoring reuses the AgentX implementation; nothing is re-implemented:

  • normalize_native and agentx_contract.score pair the silicon and replay requests;

  • agentx_metrics.request_metrics gives each point's mean (e2e) and p5 to p95 quantile (quantile) errors with their bootstrap SEs, stored under results.replay_coverage.points.<point>.
  • Output per record:

  • One case per request (<point>:<request_id>, point = l<lanes>). inputs_json holds the point, request ID, conversation, turn index, tokens and cached tokens; for TPOT of a drafting replay it also holds accept_len.

  • A per-case Parquet (aisim-eval-cases/v1, the step writer's columns) with predicted, predicted_cached_tokens, predicted_queue_ms and predicted_accept_len.

  • Official counts only. Every request of a point's profile phase (which must number the bundle's measured_requests) is either a case or a counted entry of truth_drops. A request the replay missed or mismatched is an exclusion with a prediction_error:<scorer status> reason, never dropped. No warm-up rule is added. Silicon TPOT under 1 ms stays a case; the AgentX metric reports it in excluded.

  • Host-cost assumptions: host_cost_path, engine.tokenization, engine.extra_cpu_overhead, engine.detokenization (in the engine config's per_*_us units, null when not priced), host_cost_source (hand-entered, the --host-cost-pin <repo>@<revision> when the measured lookup filled it, or none) and serving_cpu. A stage is verified only when the lookup supplied it for the stated serving CPU.

  • Prediction identity: code_path engine_replay, code_version, and the data pins op (SHA-256 of op_latency_pin.json), host_cost (SHA-256 of host_cost_pin.json, only when the lookup was used) and replay_config (the replay configs by point, with corpus paths replaced by the corpus digest).

  • Truth identity: the converter's configuration identity plus offload_mode from the bundle's cache.g2/cache.g3 features. A drafting cell names speculative_algorithm and speculative_num_steps, given with --identity-setting when the bundle lacks them; speculative_num_steps must equal the replay nextn.

  • Provenance: the runtime (framework_version), the bundle's implementation identity (image digest, framework commit), each bundle's SHA-256, the replay worker timing, gpu_time from --gpu-time, --snapshot-id and --frontend.
  • Refusals:

  • a directory that is not an engine replay (no native.json per-request rows and compiled-replay.json, for example a cli_estimate result);

  • an incomplete replay;

  • a worker not priced by the op-level model with fallback_policy deny;

  • a replay of other hardware, backend, TP or lanes than the bundle;

  • mixed configurations;

  • a profile phase that does not match measured_requests.
  • Example:

    python -m scripts.fpm_accuracy.write_e2e_eval_records \
        --point bundles/l4 replays/l4 --point bundles/l8 replays/l8 \
        --code-version "$CODE_VERSION" --op-latency-pin op_latency_pin.json --host-cost-pin host_cost_pin.json \
        --system-spec b300_sxm.yaml --evaluator-revision "$EVALUATOR_REVISION" --producer-name e2e-writer \
        --gpu-time gpu-time.json --root dataset/
    

    The README section "AgentX E2E records" in scripts/fpm_accuracy/README.md documents every field and refusal.

    Review map

  • Risk level: low. The PR adds a script, its tests and docs, and changes no existing code path.

  • Start with: build_cases (case vs truth drop vs exclusion, official-count invariant), load_replay (what counts as an engine replay), host_costs/host_cost_assumptions, cell_identity.

  • Public or serialized contract changed: no schema change. The PR adds a new producer of aisim-eval/v1 records (code_path engine_replay, layer e2e) and the assumption names listed above.

  • Feature Support Matrix: unaffected.

  • Compatibility or rollback concern: none; nothing reads the new script.
  • Evidence

  • Tests: python -m pytest -c pytest.ini tests/fpm_accuracy/test_write_e2e_eval_records.py (14 passed). The tests cover:

  • - one record per metric;
    - per-case rows and inputs;
    - TPOT drops and the under-1-ms rule;
    - official counts, including a refused bundle whose profile phase does not match measured_requests;
    - AgentX metrics equal to request_metrics(score(...));
    - multi-point cells and lane pairing;
    - host costs: none, lookup, hand-entered;
    - refusal of cli_estimate, aggregate-only, fpm_learned, fallback and failed replays;
    - deployment mismatch;
    - speculative identity and accept lengths;
    - the validators: load_record, the aisim-eval/v1 JSON schema from aisim_core.data.schemas, aisim_core.data.mirror.validate_tree, and the benchmark skill's check_eval_record.py, found by glob rather than a hard-coded path;
    - malformed options.
  • Neighbouring suites run locally: tests/fpm_accuracy/test_write_step_eval_records.py, tests/test_agentx_metrics.py, tests/test_agentx_accuracy.py, tests/test_agentx_inputs.py (241 passed; the only skips need the native runtime, which this checkout had not built).

  • Without AISim installed (the Pages job), the new test module skips like the step writer's.

  • ruff check and ruff format --check with python/aisim/pyproject.toml, and the documentation link checks, pass.

  • Fast CI: pending.

  • Full CI: pending.

  • CodeRabbit reviewed commit: pending.

  • Codex reviewed commit: not required for low risk.

  • Negative or boundary cases: listed under Tests.

  • Expected-value derivation: the fixture values are hand-computed. For example, TTFT has 6 cases: 7 official requests minus 1 failed measurement. 4 of them are scored; one replay request is missing and one has a mismatched output length. The AgentX numbers are compared against the scorer's own output, not hard-coded.

  • Before/after output: N/A (new script).
  • Modeling or data provenance

    N/A. The writer records measured and predicted values; it does not change a model or collect data. The records state each host-cost stage as measured (verified) or not (estimated), and the GPU time and its authority from --gpu-time (unknown without it).

    Tracking

  • Closes: none

  • Related PRs or issues: #1050 (AgentX metrics), #1169 (W1 removal)
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: None requested Review duration: 1595m
    All Vouch review confidence checks passed
    Residual risk 0.38 = Change Risk (0.64) × (1 − Review Confidence (0.40)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.64 · 650 lines diff across 8 files
    0.64
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    1 comments
    "Review active on #1171"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    simone-chen simone-chen
    Labels
    risk: medium confidence: 40.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 64% (MEDIUM) · Higher = larger blast radius
    64%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.5% · Lower = rushed or shallow review
    40.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 38.1% · Moderate risk
    38.1%