CoolFace
Apppublic

catmcgee/mech-interp-runner

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
App README

mech-interp-runner

Backend kernel for the learn-mech-interp curriculum site. Runs Python code submitted by the frontend in a per-session namespace and returns stdout, stderr, and matplotlib figures.

This Space is not meant to be browsed directly — it's the execution backend for the curriculum site.

endpoints

  • —GET /healthz — liveness
  • —POST /run — body { session_id, code } → { stdout, stderr, figures, error }. Figures are base64-encoded PNGs.
  • —POST /reset — body { session_id } → drops the namespace
  • —GET / — tiny status page

Per-session kernel namespaces live in process memory and are reaped after 10 minutes idle.

deploy

This is a Hugging Face Spaces "Docker" Space. To deploy:

bash
# from the site repo:
cd space/
git init
git remote add origin https://huggingface.co/spaces/catmcgee/mech-interp-runner
git add . && git commit -m "init"
git push origin main

Or use the HF web UI: create a new Space, SDK "Docker", upload these files. First build takes a few minutes (PyTorch + transformer_lens).

hardware

Free CPU tier is enough for steps 0, 1, and 5 (toy models). For steps 2, 3, and 4 (transformers) bump to a T4 small (paid).

local dev

bash
cd space/
pip install -r requirements.txt
uvicorn app:app --reload --port 7860

Then hit http://localhost:7860/healthz.