Kashyapsinh/pytorch-sandbox-mech-interp
0
PyTorchSandbox — Mechanistic Interpretability Benchmark
An OpenEnv environment for mechanistic interpretability research. Agents inspect live PyTorch models, execute diagnostic code, and submit circuit-level answers across a four-task curriculum.
Tasks
Actions
# Inspect model internals
{"python_code": "print(model.layer.weight)"}
# Submit final answer
{"solution_target": [2, 5, 8]}Observation
MechInterpObservation:
stdout_or_error: str # Captured output or error from code execution
task_level: int # Current task (1–4)
done: bool # Episode terminated
reward: float # Score in (0.01, 0.99)
metadata: dict # task_id, grader info, seed, stepSetup
# Install dependencies
python3.10+ -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'
# Generate model artifacts (if needed)
python -c "
import sys; sys.path.insert(0, 'server')
import os; os.makedirs('artifacts', exist_ok=True)
from gen_art import main; main()
"
# Run locally
uvicorn server.app:app --host 0.0.0.0 --port 8000
# Run inference
HF_TOKEN=your_token \
ENV_URL=http://localhost:8000 \
MODEL_NAME=Qwen/Qwen2.5-72B-Instruct \
python inference.pyDocker
docker build -t mech_interp .
docker run -p 8000:8000 mech_interpGraders
All graders return scores strictly within (0.01, 0.99).
Submission Checklist
- [ ]
inference.pyin project root - [ ] OpenAI client used for all LLM calls
- [ ]
HF_TOKENenvironment variable required at runtime - [ ] Strict
[START]/[STEP]/[END]stdout format - [ ] 4 tasks with programmatic graders
- [ ] Scores in
[0.0, 1.0]range - [ ]
docker buildsucceeds - [ ] HF Space URL submitted before deadline
Environment Variables
*Either ENV_URL (for HF Space) or LOCAL_IMAGE_NAME (for Docker image) must be set.
Validation
chmod +x validate-submission.sh
./validate-submission.sh https://your-space.hf.space .