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. Each sandbox starts from a pre-built image in Epoch AI’s registry on GitHub Container Registry (GHCR). The sandbox platform pulls the image, not your machine, so you don’t need Docker or a local build step.Setup
Complete the following steps to install the required tools and configure authentication before running any evaluations.-
Prepare and activate a Python virtual environment, then install the evaluation dependencies. Keep this environment active for all commands in this guide:
-
Clone the repo for the example evaluation scripts:
sandbox_auth.py file beside the Python script that uses it. This file stores only the authentication choice. Import AUTH from that file. When you create a sandbox or session, pass AUTH explicitly or set it in SandboxDefaults.
- Forge API key
- CoreWeave API access token
Use your Forge API key with the
wandb integration in the software development kit (SDK). Replace [WANDB-API-KEY] with your API key:sandbox_auth.py
placement_mode="cks" when you create a sandbox or in SandboxDefaults.
To authenticate a session and the sandboxes it owns, create the session with auth=AUTH. When you reconnect, list, or clean up sandboxes, keep the same credential.
Save the sandbox_auth.py file in the examples/swebench/ directory. In the examples/swebench/run_evaluation.py file, add from sandbox_auth import AUTH to the imports and auth=AUTH to the existing SandboxDefaults(...) call. This applies your authentication choice to every sandbox in the evaluation session.
For CKS placement, add placement_mode="cks" to the same call.
Quick start
Before you scale up, start with a single-instance run to confirm that your environment and credentials work and that a sandbox can start from its GHCR image. 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
Theresources argument controls CPU and memory per sandbox. The default is 2 CPUs and 4Gi memory. In the examples/swebench/run_evaluation.py file, replace only the resources value in the existing SandboxDefaults(...) call. Use this dictionary:
auth=AUTH, any placement_mode="cks" setting, and the other arguments in that call.
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 repository checked out at the right commit, dependencies installed, and test environment ready. The image name has this format:ghcr.io/epoch-research/swe-bench.eval.{arch}.{instance_id.lower()}:latest
The script lowercases the instance ID for the image name. It takes arch from the test specification’s arch attribute. If that attribute is absent, the script uses x86_64.
The sandbox platform pulls each image from GHCR when it starts the sandbox. On your own CKS capacity, your cluster’s Nodes do the pull. Your machine needs no access to ghcr.io, and 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 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
This simplified example shows a resolved result with test-status details. When present,tests_status groups test names by transition category, with success and failure arrays in each category. The grader can return before producing these details, so tests_status can be absent.
report.json also contains "errored": true and an error_message string. It can omit the test results and sandbox_id.
The format is compatible with standard SWE-bench tooling.
Inspect failed or errored instances
Check the script’s per-instanceComplete: log messages, then open the corresponding report.json file in the instance’s output directory. For the single-instance quick start, the default path is logs/swebench/test/gold/astropy__astropy-12907/report.json.
Complete: failed: the instance wasn’t resolved. Inspect itsresolvedvalue and any available test-status details in thereport.jsonfile, then read thetest_output.txtfile for the test output.Complete: error: readerror_messagein thereport.jsonfile, which also records"errored": true. Image pulls, sandbox startup, patch application, or test execution can fail even with gold patches. If thetest_output.txtfile exists, check it. Failures before tests run can leave no test output file.
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 sandbox platform can’t pull an instance’s image, that sandbox fails to start. The script logs the error with the instance ID, such as[astropy__astropy-12907] Error: ..., and records it in the error_message field of that instance’s report.json. The pull runs on CoreWeave infrastructure, not on your machine, so your local network access to ghcr.io isn’t the cause. Read the error message, then check the likely causes:
- Image not found: verify that Epoch AI publishes an image for the instance ID. An instance ID that isn’t in the
--datasetdataset never reaches a sandbox: the script logsInstance IDs not found in datasetand skips it. - Your own CKS capacity: if you set
placement_mode="cks", your cluster’s Nodes pull the image, so they need outbound access toghcr.io. The runner’s sandbox policy must also allow images fromghcr.io/epoch-research.
See also
- Command execution guide: details about
exec()patterns. - Cleanup patterns: managing sandbox lifecycle.