Skip to content

feat: swe bench scorer#342

Open
tianmu-li wants to merge 11 commits into
mlcommons:mainfrom
tianmu-li:feat/swe_bench_scorer
Open

feat: swe bench scorer#342
tianmu-li wants to merge 11 commits into
mlcommons:mainfrom
tianmu-li:feat/swe_bench_scorer

Conversation

@tianmu-li

@tianmu-li tianmu-li commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds SWE-bench accuracy evaluation to the agentic inference workflow (per #310). A new SWEBench dataset loads SWE-bench_Verified/_Lite, and SWEBenchScorer drives the eval by shelling out to mini-swe-agent and the swebench harness in an isolated uv subproject, bypassing the built-in accuracy phase.

Agent-run parallelism (extras.workers) defaults to the load pattern's target_concurrency when unset. Includes example configs, an optional Qwen tool-call patch, and docs.

Type of change

  • New feature
  • Documentation update

Related issues

Closes #310

Testing

  • Tests added/updated
  • All tests pass locally
  • Manual testing completed

Checklist

  • Code follows project style
  • Pre-commit hooks pass
  • Documentation updated

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for SWE-bench accuracy evaluation by adding a new accuracy-only SWEBench dataset, a SWEBenchScorer that runs evaluations using mini-swe-agent in an isolated environment, and associated configuration templates, tests, and runbooks. Feedback on the changes focuses on improving the robustness of the SWEBenchScorer implementation, specifically by safely handling missing or null values when parsing configuration templates, benchmark configurations, and evaluation results, as well as gracefully handling cases where the Docker binary is missing from the system's PATH during preflight checks.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
@tianmu-li tianmu-li force-pushed the feat/swe_bench_scorer branch 2 times, most recently from aa7f559 to bb9b307 Compare June 15, 2026 05:16
@tianmu-li tianmu-li marked this pull request as ready for review June 21, 2026 17:28
@tianmu-li tianmu-li requested review from a team and Copilot June 21, 2026 17:28
@tianmu-li tianmu-li changed the title WIP feat: swe bench scorer feat: swe bench scorer Jun 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class SWE-bench accuracy support to the benchmarking system by introducing an external (subprocess-driven) scorer and a predefined SWE-bench dataset, plus wiring in config/schema handling and examples to run the workflow.

Changes:

  • Introduces SWEBenchScorer (external evaluation via uv run --project ... mini-extra + swebench harness) and integrates it into the scoring/benchmark lifecycle (preflight, phase skipping, reporting).
  • Adds predefined swe_bench dataset with caching + an ACCURACY_ONLY guard to prevent using it as a performance dataset.
  • Updates schema/templates/examples and adds unit tests for the scorer + dataset + benchmark wiring.

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Locks pyyaml as a direct dependency.
pyproject.toml Adds pyyaml==6.0.3 to runtime dependencies.
src/inference_endpoint/evaluation/scoring.py Adds scorer preflight hooks, shared subprocess logging helper, and new SWEBenchScorer implementation.
src/inference_endpoint/dataset_manager/predefined/swe_bench/init.py Adds SWE-bench predefined dataset with HF download + parquet cache and ACCURACY_ONLY=True.
src/inference_endpoint/dataset_manager/dataset.py Introduces Dataset.ACCURACY_ONLY class flag.
src/inference_endpoint/dataset_manager/init.py Exposes/imports SWEBench dataset.
src/inference_endpoint/config/schema.py Adds swe_bench_scorer to ScorerMethod and injects concurrency → SWE-bench workers default.
src/inference_endpoint/commands/benchmark/execute.py Runs scorer preflight(), prevents accuracy-only datasets as perf, skips endpoint phases for external scorers, and improves sample counting/reporting.
src/inference_endpoint/config/templates/online_template_full.yaml Documents swe_bench_scorer as an accuracy scorer option.
src/inference_endpoint/config/templates/offline_template_full.yaml Documents swe_bench_scorer as an accuracy scorer option.
src/inference_endpoint/config/templates/concurrency_template_full.yaml Documents swe_bench_scorer as an accuracy scorer option.
examples/10_Agentic_Inference/swebench_template.yaml Adds a SWE-bench/mini-swe-agent config template used by the external scorer.
examples/10_Agentic_Inference/swe_bench_accuracy.yaml Adds a runnable example config for SWE-bench external accuracy evaluation.
examples/10_Agentic_Inference/README.md Documents how to sync/run the SWE-bench accuracy subproject.
examples/10_Agentic_Inference/qwen_agentic_benchmark.yaml Adds SWE-bench accuracy dataset to an agentic benchmark example.
examples/10_Agentic_Inference/kimi_agentic_benchmark.yaml Adds SWE-bench accuracy dataset to an agentic benchmark example.
examples/10_Agentic_Inference/accuracy/RUNBOOK.md Adds an ops runbook for validating the SWE-bench accuracy pipeline.
examples/10_Agentic_Inference/accuracy/pyproject.toml Adds isolated uv subproject deps for SWE-bench evaluation tooling.
tests/unit/evaluation/test_swe_bench_scorer.py Adds unit coverage for scorer behavior, config patching, and preflight.
tests/unit/dataset_manager/test_swe_bench_dataset.py Adds unit coverage for dataset registration, caching, and subset mapping.
tests/unit/commands/test_benchmark.py Adds tests for concurrency→workers injection, ACCURACY_ONLY enforcement, preflight propagation, and phase skipping behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/dataset_manager/predefined/swe_bench/__init__.py Outdated
Copilot AI review requested due to automatic review settings June 21, 2026 23:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 21 changed files in this pull request and generated 7 comments.

Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread examples/10_Agentic_Inference/swebench_template.yaml
Comment thread examples/10_Agentic_Inference/README.md
Comment thread examples/10_Agentic_Inference/swe_bench_accuracy.yaml Outdated
Copilot AI review requested due to automatic review settings June 25, 2026 13:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.

Comment thread examples/10_Agentic_Inference/accuracy/RUNBOOK.md Outdated
Comment thread examples/10_Agentic_Inference/qwen_agentic_benchmark.yaml Outdated
Copilot AI review requested due to automatic review settings July 6, 2026 18:13
@tianmu-li tianmu-li force-pushed the feat/swe_bench_scorer branch from 8d66f43 to ae04494 Compare July 6, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated 3 comments.

Comment thread src/inference_endpoint/commands/benchmark/execute.py
Comment thread src/inference_endpoint/commands/benchmark/execute.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
@codecov-commenter

codecov-commenter commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.41414% with 51 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@e9ad7fd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/inference_endpoint/evaluation/scoring.py 91.26% 42 Missing ⚠️
...c/inference_endpoint/commands/benchmark/execute.py 84.74% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #342   +/-   ##
=======================================
  Coverage        ?   80.52%           
=======================================
  Files           ?      130           
  Lines           ?    17852           
  Branches        ?        0           
=======================================
  Hits            ?    14375           
  Misses          ?     3477           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings July 6, 2026 22:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated 3 comments.

Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 22:09
@tianmu-li tianmu-li force-pushed the feat/swe_bench_scorer branch from da45a99 to fe442f8 Compare July 9, 2026 22:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.

Comment thread examples/10_Agentic_Inference/accuracy/actions_toolcall.py
Comment thread examples/10_Agentic_Inference/accuracy/actions_toolcall.py
Copilot AI review requested due to automatic review settings July 9, 2026 23:10
tianmu-li and others added 2 commits July 13, 2026 09:28
litellm>=1.92.0 imports fastapi (proxy-only extra, not installed here)
as soon as a completion() call passes tools, breaking every
tool-calling request with ImportError/ModuleNotFoundError retries and
producing empty SWE-bench patches for all submitted instances.
Move swebench templates into accuracy/ so they aren't accidentally
edited by participants, move the SWE-specific module-level helper
functions into SWEBenchScorer as staticmethods (hvagadia review
feedback), close the accuracy-only dataset guard bypass via
`name::preset` suffixes in execute.py, and treat an explicit YAML
`null` as a missing value in _get_extra_int/_get_extra_bool instead of
raising.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 13, 2026 16:31
@tianmu-li tianmu-li force-pushed the feat/swe_bench_scorer branch from 5fffd61 to 32eceaa Compare July 13, 2026 16:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.

Comment thread examples/10_Agentic_Inference/accuracy/actions_toolcall.py
Comment thread src/inference_endpoint/evaluation/scoring.py
Copilot AI review requested due to automatic review settings July 13, 2026 16:44
@tianmu-li tianmu-li force-pushed the feat/swe_bench_scorer branch from 32eceaa to 7224b2b Compare July 13, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated 4 comments.

Comment thread src/inference_endpoint/config/schema.py
Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread examples/10_Agentic_Inference/accuracy/litellm_model.py Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 17:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated 1 comment.

Comment thread src/inference_endpoint/evaluation/scoring.py
Copilot AI review requested due to automatic review settings July 13, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.

Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread examples/10_Agentic_Inference/accuracy/actions_toolcall.py

@arekay-nv arekay-nv 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.

Review Council — Multi-AI Code Review

Reviewed by Codex + Claude · Depth thorough

Posting 10 inline findings on the new SWE-bench scorer. See the summary comment for the tiered breakdown. Findings already covered by existing Copilot/Gemini/human threads (many now fixed) were deduplicated out.

Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread examples/10_Agentic_Inference/accuracy/actions_toolcall.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py Outdated
Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread tests/unit/evaluation/test_swe_bench_scorer.py
@arekay-nv

Copy link
Copy Markdown
Collaborator

Review Council — Multi-AI Code Review

Reviewed by: Codex + Claude | Depth: thorough

Found 13 issues; posted 10 inline (3 filtered as duplicates of existing Copilot/Gemini/human threads — _prepull_images shutdown, max_eval_workers validation timing, view_range awk quoting — most already fixed on this branch). All 10 anchor to the new SWE-bench accuracy scorer.

🔴 Must Fix (high)

Silently discards a real result after the full (expensive) agent + eval run.

# File Line Category Reviewer(s) Summary
1 src/inference_endpoint/evaluation/scoring.py 2582 bug Codex Result-file lookup checks only output_dir + a non-recursive glob; swebench may write the report under logs/run_evaluation/<run_id>/, so a successful eval can fall through to return None (no score).

🟡 Should Fix (medium)

Real correctness/integrity issues that trigger under supported configurations.

# File Line Category Reviewer(s) Summary
2 src/inference_endpoint/evaluation/scoring.py 2451 bug Codex Relative swe_bench_project_path/$SWE_BENCH_PROJECT_PATH isn't .resolve()d; subprocesses run with cwd=output_dir, so uv --project <relative> resolves under the report dir and fails.
3 examples/10_Agentic_Inference/accuracy/actions_toolcall.py 164 bug Codex finish builds the patch via git diff HEAD, which omits untracked files — fixes that create a new source file submit an incomplete patch and score unresolved.
4 src/inference_endpoint/evaluation/scoring.py 2602 data-integrity Claude resolved / submitted denominator excludes no-prediction instances, inflating the score vs. the reported num_samples = num_instances; can pass a compliance gate resolved/total would fail.
5 src/inference_endpoint/evaluation/scoring.py 2360 design Claude _install_toolcall_patch mutates shared venv site-packages restored only in finally; a crash during the (≤24h) run leaves minisweagent permanently patched → later non-Qwen runs silently wrong. Also races concurrent runs.
6 src/inference_endpoint/evaluation/scoring.py 2598 data-integrity Claude Early None-score returns never set self.complete = False, so a fully-failed eval serializes as {"score": null, "complete": true} — defeating the flag's purpose.

🔵 Consider (low)

Valid hardening / coverage; could be follow-ups.

# File Line Category Reviewer(s) Summary
7 src/inference_endpoint/evaluation/scoring.py 2411 security Claude Endpoint API key is written in cleartext to report_dir/swe_bench_output/swebench_patched.yaml, which persists in the report tree — inconsistent with the pipeline's keep-secrets-out-of-artifacts rule.
8 src/inference_endpoint/evaluation/scoring.py 2021 bug Claude num_instances lacks min_value=1 (unlike workers); num_instances: 0 passes preflight then yields slice "0:0" and a silent None score.
9 src/inference_endpoint/evaluation/scoring.py 2069 bug Claude Preflight derives the prepull slice from the full dataset length; score() clamps to the loaded (possibly subsampled) dataframe — mismatched instance sets defeat the image prepull.
10 tests/unit/evaluation/test_swe_bench_scorer.py 933 testing Claude The "eval ran but emitted no result file" branch (empty candidatesNone) is never exercised — the same path finding #1 says a real failure hits.

Reviewer coverage. Codex focused on functional path/submission bugs in the newly added workflow (findings 1–3); Claude covered scoring semantics, crash-safety, the complete contract, secret handling, and test gaps (4–10). Findings #1 and #10 independently converge on the same fragile result-file path.

ℹ️ This branch is heavily pre-reviewed (Copilot, Gemini, and human reviewers) with 9 commits (5 fix: fixups) resolving prior rounds; the council intentionally surfaces only issues not already raised there.

Posted with event: COMMENT — no approve/request-changes.

Copilot AI review requested due to automatic review settings July 13, 2026 20:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 4 comments.

Comment thread src/inference_endpoint/evaluation/scoring.py
Comment thread examples/10_Agentic_Inference/accuracy/RUNBOOK.md Outdated
Comment thread AGENTS.md Outdated
Comment thread examples/10_Agentic_Inference/accuracy/actions_toolcall.py
Copilot AI review requested due to automatic review settings July 13, 2026 20:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 26 changed files in this pull request and generated 2 comments.

Comment on lines +191 to +194
bash_cmd = (
f"awk 'NR>={start} && NR<={end} "
f'{{printf "%6d\\t%s\\n", NR, $0}}\' {shlex.quote(path)}'
)
Comment on lines +109 to +114
command = actions[0]["command"]
assert (
command == "awk 'NR>=2 && NR<=4 "
'{printf "%6d\\t%s\\n", NR, $0}\' /testbed/pkg/file.py'
)
assert r"\'" not in command

@arekay-nv arekay-nv 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.

Can we remove docker as a dependency - ideally we would like to have the container be launched/orchestrated from outside the client and only a port/path be passed to the scorer like we do for LCB.

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.

[Feature]: SWE-bench using mini-swe-agent

5 participants