Available backends
- modal (default) - Serverless containers via Modal.com
- docker - Local Docker containers
- gcp - Google Cloud Platform Batch jobs
Using backends
Specify backend in run()
Specify backend in evaluate()
Backend comparison
| Feature | Modal | Docker | GCP Batch |
|---|---|---|---|
| Setup | Requires Modal account | Local Docker only | GCP project required |
| Speed | Fast startup | Instant | Slower startup |
| Concurrency | High (100+) | Limited by local CPU | Very high (1000+) |
| Cost | Pay per second | Free (local) | Pay per hour |
| Best for | Development, medium scale | Local testing, debugging | Large-scale evaluation |
Backend API
All backends implement theEvalBackend protocol:
Sandbox interface
ExecResult structure
Using backends programmatically
Get backend instance
Create and use sandbox
Modal backend
Setup
- Install Modal:
- Authenticate:
- Use in CooperBench:
Features
- Serverless execution (no infrastructure to manage)
- Fast cold starts (typically under 10 seconds)
- Auto-scaling based on concurrency
- Pay-per-second billing
Configuration
Modal is configured via environment variables:Docker backend
Setup
- Install Docker:
- Pull required images:
- Use in CooperBench:
Features
- Runs locally (no internet required)
- No additional costs
- Full control over environment
- Good for debugging
Configuration
GCP Batch backend
Setup
- Install GCP SDK:
- Authenticate:
- Set project:
- Use in CooperBench:
Features
- Massive parallelism (1000+ concurrent tasks)
- Batch job optimization (single VM startup for many tasks)
- Cost-effective for large-scale runs
- Auto-cleanup of resources
Batch evaluation
For GCP, evaluation uses batch mode by default:- Single VM startup amortized across all tasks
- Tasks run in parallel on the VM
- Automatic cleanup after completion
Configuration
Advanced usage
Custom backend implementation
You can implement custom backends:Use custom backend
Direct sandbox usage
Best practices
Choose the right backend
- Development: Use Modal for fast iteration
- Debugging: Use Docker for local control
- Large-scale: Use GCP for cost-effective parallelism
Optimize concurrency
Handle timeouts
Related functions
- run() - Execute tasks with backends
- evaluate() - Evaluate with backends
- get_backend() - Get backend instance