What this does
SWE-bench tests whether language models can fix real bugs in real repositories. Each task applies a patch, runs the test suite, and checks if the fix works. You can run SWE-bench locally with Docker, but your machine’s resources limit you. CoreWeave sandboxes let you run evaluations at scale on CoreWeave infrastructure. Spin up dozens or hundreds of sandboxes concurrently without managing any of it yourself. The script pulls pre-built images from Epoch AI’s registry on GHCR, so no local Docker build step is needed.Setup
Complete the following steps to install the required tools and configure authentication before running any evaluations.-
Install the Python SDK and evaluation dependencies:
-
Clone the repo for the example evaluation scripts:
-
Set your
CWSANDBOX_API_KEYto a CoreWeave API access token for authentication. Replace[ACCESS-TOKEN]with your CoreWeave API access token:
Quick start
Before you scale up, start with a single-instance run to confirm your environment, credentials, and network access to GHCR all work. Thegold option uses the known-correct fix from the dataset:
Run in parallel
Run multiple instances at once:Evaluate model predictions
To test custom model output:Options
Adjust resources
The default is 2 CPUs and 4Gi memory per sandbox. Change this inrun_evaluation.py:
How it works
This section explains the moving parts behind the script so you can adapt it to your own evaluation workflows.Container images
Epoch AI hosts pre-built images on GHCR. Each instance has its own image with the repo checked out at the right commit, dependencies installed, and test environment ready. Image format:ghcr.io/epoch-research/swe-bench.eval.x86_64.{instance_id}:latest
Sandboxes pull these directly from GHCR. No local builds are needed.
Evaluation flow
Each instance goes through these steps:
Steps 2 to 5 and 8 run remotely. Steps 1, 6, and 7 run on your machine.
Parallel execution
The script usesThreadPoolExecutor to run instance workflows concurrently. Each thread drives one instance through its workflow. While one instance runs tests, another can apply its patch, another grade locally, another start up. The overlap is where the speed comes from.
Results come back as workflows finish through as_completed().
Cleanup
The script uses a CoreWeave sandboxSession to track sandboxes. When the session exits (normal exit, exception, or Ctrl+C), the session cleans up all sandboxes.
Output
Results go to{output-dir}/{run-id}/{model-name}/{instance-id}/:
Report format
Troubleshooting
Patch application fails
If you seeAPPLY_PATCH_FAIL in logs, the patch is probably malformed, targets the wrong commit, or has whitespace issues. Run git apply --check locally to see what’s wrong. Make sure the instance ID matches the prediction.
Test timeouts
Some test suites take longer than 30 minutes. Model-generated code might also have infinite loops. If needed, increase--timeout, or check the test output to see where it’s stuck.
Image pull errors
If the container fails to start with an image pull error, either the instance ID doesn’t exist in Epoch AI’s registry, or a network issue prevents reachingghcr.io. Verify the instance ID is in the SWE-bench dataset.
See also
- Command execution guide: details about
exec()patterns. - Cleanup patterns: managing sandbox lifecycle.