File size: 12,546 Bytes
57111ed 9abd52c 57111ed d75f483 57111ed 9abd52c 57111ed d75f483 9974082 d75f483 57111ed 9974082 57111ed 9abd52c 57111ed 9abd52c 57111ed 9abd52c 57111ed d75f483 57111ed 9974082 287b961 57c8796 57111ed 9974082 57111ed 9abd52c 57111ed 9abd52c 57111ed 9abd52c 57111ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | # Batch Evaluation Reference
`scripts/run_batch.py` is the convenience wrapper for running a materialized task
selection with Pier. It does not build task images. It reads the immutable
environment and verifier references from each `task.toml`, pulls those images
for `linux/amd64`, writes a redacted run record, and invokes Pier with
`--no-force-build --no-delete --yes`.
## Prerequisites
From a downloaded release directory:
~~~bash
uv tool install --python 3.12 "datacurve-pier==0.3.0"
docker login
python3 scripts/materialize.py \
--task-id 002,005-007 \
--output tasks-selected-small --force
~~~
The pinned `datacurve-pier==0.3.0` release requires Python 3.12 or newer.
Docker Engine 28 or newer is required for isolated bridge gateway mode.
The `--path` passed to `run_batch.py` must be a materialized directory containing
`task_NNN/task.toml` directories. The runner never selects tasks implicitly and
never reads task definitions from GitHub at runtime.
## Provider Profiles
Use an env file outside the checkout. The parser accepts `KEY=value`, optional
`export KEY=value`, comments, and quoted values. It never prints credential
values or writes them to `batch-run.json`.
### Codex and OpenAI-compatible gateways
`run_batch.py` translates the following fields into Pier's Codex provider
configuration when `--agent codex` is used:
| Variable | Required | Meaning |
| --- | --- | --- |
| `MODEL` | No | Exact model route sent to the gateway; default `gpt-5` |
| `OPENAI_API_KEY` | Yes for a real run | Gateway credential |
| `CODEX_BASE_URL` | No | OpenAI-compatible gateway URL; defaults to `https://api.openai.com/v1` |
| `CODEX_WIRE_API` | No | `responses` or `chat`; defaults to `responses` |
| `CODEX_VERSION` | No | Codex runtime version passed to Pier |
| `CODEX_REASONING_EFFORT` | No | Reasoning effort passed to the Codex adapter |
Example:
~~~dotenv
MODEL=gpt-5
OPENAI_API_KEY=replace-with-your-key
CODEX_BASE_URL=https://gateway.example.edu/v1
CODEX_WIRE_API=responses
CODEX_VERSION=latest
CODEX_REASONING_EFFORT=high
~~~
`CODEX_BASE_URL` selects the model gateway. It is different from a network
proxy. A network proxy is configured with standard `HTTP_PROXY`, `HTTPS_PROXY`,
and `NO_PROXY` variables. For Docker Desktop, a proxy running on the host is
usually reached from a container as `host.docker.internal`, not `127.0.0.1`.
Responses gateways use HTTP/SSE (`supports_websockets=false`). Include the API
path in `CODEX_BASE_URL`, for example `http://gateway.example:4000/v1`.
Nonstandard gateway ports are allowed only for their configured gateway host.
The benchmark's generated Codex configuration disables hosted web search.
### Chat-only gateways through LiteLLM
Use an independent LiteLLM proxy when the upstream deployment exposes only
Chat Completions. Codex continues to use its native Responses interface; the
benchmark does not rewrite model requests or add model-specific adapters.
LiteLLM provides the
[Responses-to-Chat bridge](https://docs.litellm.ai/docs/response_api#opt-in-bridge-for-openai-models-with-custom-api_base).
Install a separate gateway environment:
~~~bash
uv venv --python 3.12 .venv-gateway
uv pip install --python .venv-gateway/bin/python 'litellm[proxy]==1.103.2'
~~~
Create `litellm.yaml`, replacing the deployment name and upstream URL:
~~~yaml
model_list:
- model_name: my-deployment
litellm_params:
model: openai/my-deployment
api_base: https://upstream.example/v1
api_key: os.environ/UPSTREAM_API_KEY
use_chat_completions_api: true
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
litellm_settings:
turn_off_message_logging: true
~~~
Set `UPSTREAM_API_KEY` and a separate `LITELLM_MASTER_KEY` in the gateway
process's environment, then start it:
~~~bash
.venv-gateway/bin/litellm --config litellm.yaml --host 127.0.0.1 --port 4001
~~~
For Docker Desktop, configure the evaluation profile as follows:
~~~dotenv
MODEL=my-deployment
OPENAI_API_KEY=replace-with-your-litellm-master-key
CODEX_BASE_URL=http://host.docker.internal:4001/v1
CODEX_WIRE_API=responses
CODEX_VERSION=latest
~~~
Only the LiteLLM proxy key enters the Agent container. The upstream key stays
in the gateway process. The configured host and port are added to the inference
allowlist; direct Agent internet access remains blocked. On Linux, use a gateway
address reachable from the proxy's egress network rather than enabling host
networking for the Agent. The gateway is a separate local service, not part of
the task images or verifier.
### Claude Code and mini-swe-agent
These harnesses receive their provider variables through Pier's `--env-file`:
~~~dotenv
# Claude Code
ANTHROPIC_AUTH_TOKEN=replace-with-your-gateway-key
ANTHROPIC_BASE_URL=https://api.anthropic.com
ANTHROPIC_CUSTOM_HEADERS=
~~~
~~~dotenv
# mini-swe-agent with an OpenAI-compatible provider
OPENAI_API_KEY=replace-with-your-gateway-key
OPENAI_BASE_URL=https://gateway.example.edu/v1
~~~
The model route is selected with the repeatable `--model` option. Provider
variables not listed here can be added to the env file and are passed through to
the selected harness by Pier.
## Basic Commands
Run a no-model infrastructure smoke:
~~~bash
python3 scripts/run_batch.py \
--path tasks-selected-small \
--agent nop \
--n-concurrent 1 \
--n-attempts 1 \
--jobs-dir jobs \
--job-name smoke
~~~
Run Codex through a gateway:
~~~bash
python3 scripts/run_batch.py \
--path tasks-selected-small \
--agent codex \
--env-file ~/.config/swe-bench-science/codex.env \
--n-concurrent 2 \
--n-attempts 1 \
--max-retries 1 \
--jobs-dir jobs \
--job-name codex-small
~~~
Run Claude Code or mini-swe-agent:
~~~bash
python3 scripts/run_batch.py \
--path tasks-selected-small \
--agent claude-code \
--env-file ~/.config/swe-bench-science/claude.env \
--model anthropic/claude-opus-4-7 \
--n-concurrent 1 \
--jobs-dir jobs \
--job-name claude-small
~~~
For an approximately 120-second agent-stage smoke, add
`--agent-timeout-multiplier 0.0223`. For an approximately 30-second agent-stage
smoke, use `--agent-timeout-multiplier 0.0055556`. These options do not shorten
the verifier timeout or any native build timeout.
## Offline Network Isolation
The batch runner selects the shared `ScienceBenchDocker` environment for every
harness, including Codex, Claude Code, and mini-swe-agent. Agent containers join
only an internal bridge with `gateway_mode_ipv4=isolated` and IPv6 disabled.
The inference proxy also joins a separate egress network, enforces the harness's
provider allowlist, and has IPv4/IPv6 forwarding disabled. Both containers drop
`NET_ADMIN` and `NET_RAW`. Verifiers and agents without inference egress use
`network_mode=none`.
Before the agent starts, the runner inspects the actual container and network
configuration. Unsupported engines, a host gateway, additional Agent networks,
or elevated network capabilities fail the trial. Clearing proxy variables,
`NO_PROXY='*'`, `curl --noproxy '*'`, and Git proxy overrides cannot create a
direct route to external source repositories.
Each trial records `network-policy-<session>.json`; `batch-run.json` records
the network policy and configured gateway authorities without credentials.
Task image digests are unchanged by this runtime policy. Pier installs the
selected harness during a separate image-build stage before the isolated agent
stage starts.
Run the opt-in Docker regression with an already pulled environment image:
~~~bash
SCI_BENCH_NETWORK_TEST_IMAGE='<environment image from task.toml>' \
python3.12 -m unittest tests.test_network_policy_e2e -v
~~~
This regression lives in the GitHub checkout. It uses a reachable local HTTP
fixture to test permitted gateway traffic, denied source hosts, and direct
proxy bypass attempts without a paid model call.
Use `scripts/run_batch.py` for this policy. A direct `pier run` command must
also supply `--environment-import-path scripts.pier_network:ScienceBenchDocker`
and any nonstandard gateway URLs through
`--environment-kwarg 'inference_urls=["http://gateway.example:4000"]'`.
The validated release backend is Docker.
## Patch and Verifier Boundary
Each materialized task contains a Pier `pre_artifacts.sh` hook. Pier runs this
hook after the agent exits and before it collects artifacts. The hook computes
`artifacts/model.patch` against the task image's original baseline root commit,
so an agent-created commit is still included in the patch. A clean or timed-out
agent produces an explicit empty patch rather than a missing artifact.
For tasks with a separate verifier image, the verifier entrypoint applies that
patch to its clean task workspace before running public and private tests. The
verifier result therefore evaluates the agent workspace, not the untouched
baseline. A missing `pre_artifacts.sh` is rejected by `run_batch.py`; rerun
`materialize.py` with the current tools to regenerate the task selection.
Private-test collection is directory-based. The verifier runs pytest on
`/tests/private_tests`, so task authors may use names such as
`test_res_export.py` or `test_scientific_invariants.py`; no
`test_task_NNN.py` filename is required. The task's Compose override mounts the
bundle's dynamic grader into an existing prebuilt verifier image, so correcting
test discovery does not require rebuilding the image.
## Option Reference
| Option | Default | Description |
| --- | --- | --- |
| `--path` | required | Materialized task directory |
| `--agent` | `nop` | Pier harness, such as `codex`, `claude-code`, `mini-swe-agent`, or `nop` |
| `--env` | `docker` | Docker backend with the Science benchmark offline policy |
| `--env-file` | unset | Provider/harness env file |
| `--model` | unset | Model route; repeat for multiple Pier model arguments |
| `--agent-env KEY=VALUE` | repeatable | Extra environment value passed to the harness |
| `--agent-kwarg KEY=VALUE` | repeatable | Extra Pier agent keyword; useful for adapter-specific settings |
| `--n-concurrent` | `1` | Number of simultaneous tasks |
| `--n-attempts` | `1` | Attempts per task |
| `--max-retries` | `0` | Pier retries after an attempt-level failure |
| `--agent-timeout-multiplier` | Pier default | Multiplier for the agent stage timeout |
| `--verifier-timeout-multiplier` | Pier default | Multiplier for verifier/build timeout |
| `--jobs-dir` | `jobs` | Directory for Pier jobs and summaries |
| `--job-name` | unset | Stable job name used in result paths |
| `--platform` | `linux/amd64` | Docker pull and derived Pier image platform |
| `--pier-bin` | `pier` | Pier executable or absolute path |
| `--skip-pull` | off | Skip Docker pulls when immutable refs are already local |
| `--no-auto-provider` | off | Do not translate `CODEX_*` profile values into Codex kwargs |
| `--no-auto-agent-adapter` | off | Use Pier's built-in Codex agent instead of the Science Bench adapter |
| `--agent-import-path` | unset | Explicit Pier agent import path |
| `--dry-run` | off | Pull/validate images and write metadata, but do not invoke Pier |
The wrapper always records the selected task IDs, selection hash, image refs,
platform, Pier version, agent/model settings, and a redacted Pier command in
`<path>/batch-run.json`.
## Results
Pier writes its job output under the selected jobs directory. The wrapper then
generates:
~~~text
jobs/<job-name>/result.json
jobs/<job-name>/summary.json
jobs/<job-name>/summary.csv
jobs/<job-name>/<task>__<trial>/verifier/reward.json
jobs/<job-name>/<task>__<trial>/verifier/ctrf.json
jobs/<job-name>/<task>__<trial>/verifier/test-stdout.txt
~~~
The summary CSV is the convenient per-task result table. Use `pier view jobs`
for trajectories and inspect `result.json`, `reward.json`, and
`test-stdout.txt` together when diagnosing a failure.
## Common Variants
Pull nothing and inspect the fully rendered command:
~~~bash
python3 scripts/run_batch.py \
--path tasks-selected-small \
--agent codex \
--env-file ~/.config/swe-bench-science/codex.env \
--skip-pull \
--dry-run
~~~
Run the 91-task science-knowledge ablation selection after materialization:
~~~bash
python3 scripts/materialize.py \
--task-id 002-082,084,086,090,097-101,111,114 \
--allow-restricted-licenses \
--output tasks-science-knowledge-ablation --force
python3 scripts/run_batch.py \
--path tasks-science-knowledge-ablation \
--agent codex \
--env-file ~/.config/swe-bench-science/codex.env \
--n-concurrent 4 \
--jobs-dir jobs \
--job-name codex-science-ablation
~~~
|