Exp run

From Lambenthan/empiricalwiki · View interactive version

Exp run is an AI agent skill from the GitHub repository Lambenthan/empiricalwiki. Full experiment execution pipeline — prepare code → deploy → monitor → collect results, supporting three run modes

How to use this skill

Skill file

/exp-run

Execute an experiment that has been planned in wiki/experiments/.

Three run modes for different scenarios:

- Default (deploy): Phase 1-2 only — deploy and return immediately. Best for experiments that take hours or days.

- --collect: Phase 3-4 only — check whether a deployed experiment has finished; collect results if so (--check is an alias).

- --full: All four phases end-to-end. Best for short local experiments that finish in minutes.

Recommended flow: /exp-run <slug> to deploy → /exp-status to monitor → /exp-run <slug> --collect to collect.

Inputs

Outputs

Wiki Interaction

Reads

Writes

Graph edges created

Workflow

Precondition: confirm working directory is the wiki project root (directory containing wiki/, raw/, tools/).


Deploy Mode (default, status == planned)

Phase 1: Prepare

  1. Read experiment page:
  1. Load implementation context:
  1. Write experiment code to experiments/code/{slug}/:
  1. Optional Review LLM code review (--review):

```

mcpllm-reviewchat:

system: "You are a senior ML engineer reviewing experiment code.

Focus on: correctness of the training loop, proper evaluation protocol,

fair baseline comparison, reproducibility (seeds, determinism),

proper metric computation, and common pitfalls (data leakage,

wrong split, gradient accumulation bugs)."

message: |

## Experiment

{experiment title and hypothesis}

## Code

{generated code}

## Expected Behavior

{setup details from wiki page}

Review for correctness and potential issues.

```

Fix code based on Review LLM feedback.

  1. Sanity check (small-scale validation):

Phase 2: Deploy

Local mode (`--env local` or default)
  1. Check GPU: nvidia-smi to confirm GPU available and sufficient VRAM
  2. Launch:

```bash

screen -dmS exp-{slug} bash -c \

"cd $(pwd) && bash experiments/code/{slug}/run.sh 2>&1 | tee logs/exp-{slug}.log"

```

  1. Update wiki/experiments/{slug}.md:
  1. Estimate runtime and write to frontmatter:

Estimate based on setup.hardware (GPU model/count), setup.model (parameter count), setup.dataset (scale):

| Typical scenario | Estimated range |

|-----------------|-----------------|

| Single GPU + small dataset (CIFAR / small NLP benchmark) | 0.5 – 3h |

| Single A100 + medium dataset (ImageNet / GLUE) | 4 – 12h |

| Multi-GPU or large model fine-tuning (≥7B) | 8 – 48h |

```bash

python3 tools/research_wiki.py set-meta \

wiki/experiments/{slug}.md started "{YYYY-MM-DDTHH:MM}"

python3 tools/research_wiki.py set-meta \

wiki/experiments/{slug}.md estimated_hours {N}

```

  1. Append log:

```bash

python3 tools/research_wiki.py log wiki/ \

"exp-run | deployed {slug} | env: local | session: exp-{slug} | eta: {N}h"

```

Remote mode (`--env remote`)

Prerequisite: user has configured config/server.yaml.

  1. Confirm connectivity: python3 tools/remote.py status
  1. Find free GPU: python3 tools/remote.py gpu-status
  1. Sync code: python3 tools/remote.py sync-code
  2. Install dependencies (first time or if requirements changed): python3 tools/remote.py setup-env
  3. Launch remote experiment:

```bash

python3 tools/remote.py launch \

--name "exp-{slug}" \

--cmd "bash experiments/code/{slug}/run.sh" \

--gpu {gpu_index}

```

  1. Update wiki/experiments/{slug}.md frontmatter — all of these fields already exist (empty) because /exp-design wrote the full CLAUDE.md template:

```bash

# Top-level scalar fields — use set-meta

python3 tools/research_wiki.py set-meta wiki/experiments/{slug}.md status running

python3 tools/research_wiki.py set-meta wiki/experiments/{slug}.md run_log "logs/exp-{slug}.log"

```

The nested remote: block cannot be updated via set-meta (it only handles top-level scalar fields). Use the Edit tool directly to replace the five empty sub-field values in place. The pre-existing block in the file looks like:

```yaml

remote:

server: ""

gpu: ""

session: ""

started: ""

completed: ""

```

Use five Edit calls (one per sub-field) to set server, gpu, session, started. Leave completed: "" — Phase 4 fills that. If you find the remote: block missing from the file, that means /exp-design did not write the full CLAUDE.md template; stop and report the bug rather than trying to append the block here (appending would drift the file away from the canonical order and break future edits).

  1. Estimate runtime and write to frontmatter (same estimation logic as local mode):

```bash

python3 tools/research_wiki.py set-meta \

wiki/experiments/{slug}.md started "{YYYY-MM-DDTHH:MM}"

python3 tools/research_wiki.py set-meta \

wiki/experiments/{slug}.md estimated_hours {N}

```

  1. Append log:

```bash

python3 tools/research_wiki.py log wiki/ \

"exp-run | deployed {slug} | env: remote | server: {host} | gpu: {gpu} | eta: {N}h"

```

Print DEPLOY_REPORT to terminal:

# Deploy Report: {experiment title}

### Status: DEPLOYED ✅

- Session: exp-{slug}
- Environment: local | remote ({host} GPU {gpu})
- Log file: logs/exp-{slug}.log
- Code: experiments/code/{slug}/
- Estimated: ~{N}h (expected completion: {YYYY-MM-DD HH:MM})

### Next Steps

1. Monitor progress: `/exp-status`
2. Check this experiment: `/exp-run {slug} --collect`
3. In /research pipeline: progress saved to wiki/outputs/pipeline-progress.md

### Quick Commands

Local: check if still running

screen -ls | grep exp-{slug}

Local: tail log

tail -f logs/exp-{slug}.log


Collect Mode (`--collect` or `--check`, status == running)

Phase 3: Monitor / Check Run Status

  1. Read deployment info: from wiki/experiments/{slug}.md frontmatter, get environment (local or remote) and session name.
  1. Check whether the process is still alive:
  1. If experiment is still running (alive == true):

```

Experiment {slug}: RUNNING

Progress: step {N} / epoch {E}

Latest metric: {metric} = {value}

Anomalies: {none | NaN detected | ...}

Estimated remaining: ~{N} hours

Run /exp-status to monitor all running experiments.

```

  1. If experiment has finished (alive == false / session gone):

Phase 4: Collect Results

  1. Pull remote results (remote mode only):

```bash

python3 tools/remote.py pull-results \

--remote-path "results/{slug}/" \

--local-path "./results/{slug}/"

python3 tools/remote.py pull-results \

--remote-path "logs/exp-{slug}.log" \

--local-path "./logs/"

```

  1. Check result files exist: results/{slug}/seed_*.json
  1. Parse results:
  1. Update experiment page wiki/experiments/{slug}.md:
  1. Append log:

```bash

python3 tools/research_wiki.py log wiki/ \

"exp-run | completed {slug} | outcome: {outcome} | key: {key_result}"

```

  1. Print RUN_REPORT to terminal:

```markdown

# Run Report: {experiment title}

## Outcome: {succeeded / failed / inconclusive}

## Results

| Metric | Baseline | Ours (mean±std) | Δ |

|--------|----------|-----------------|---|

| {metric} | {baseline-value} | {mean}±{std} | +{delta} |

## Key Finding

{key_result}

## Next Steps

```


Full Mode (`--full`, status == planned)

Execute all 4 phases in sequence (Phase 1 → Phase 2 → Phase 3 → Phase 4) without returning.

Use case: quick local CPU/GPU experiments that finish in minutes (sanity checks, toy dataset validation, etc.).

In Phase 3, instead of checking "is it still running", wait for the screen session to actually exit before executing Phase 4:

# Wait for session to end (polling)
while screen -ls | grep -q "exp-{slug}"; do
  sleep 30
done
# Session gone, proceed to Phase 4

Constraints

Error Handling

Dependencies

Skills(via Skill tool)

Tools(via Bash)

Configuration

MCP Servers

Claude Code Native

Called by

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.