lab-gpu-steward
by WhoJay0609
README.md
# Lab GPU Steward
**Zero-dependency Python 3.11+ CLI, Agent Skill (`SKILL.md`), and stdio MCP server** for shared multi-GPU research servers—built to plug directly into both **Codex** and **Antigravity (AGY)**.
Shared lab servers rarely have Slurm, yet multiple humans and coding agents routinely collide on GPUs, contaminate wall-clock timing runs, crash vLLM startup with OOMs, or fill `/data` with teacher logits while risking frozen experiment evidence. `lab-gpu-steward` turns those brittle prose rules into deterministic, JSON-first checks.
## Capabilities
- **UUID-First GPU Inventory (`status`, `select`)**: Queries `nvidia-smi` + `/proc/<pid>` to map every GPU UUID to memory, SM utilization, active processes, and usernames.
- **Timing vs. Accuracy Policy Separation (`select`, `attest`, `run`)**:
- `timing` mode enforces strict idle (or allowlisted tiny resident processes with `--allow-small-mib` + `--max-sm-util`) and writes a machine-verifiable `timing_attestation.json` with pre/post snapshots.
- `accuracy` mode permits `shared_gpu: true` within free VRAM budgets while protecting resident servers (`--exclude-uuid`, `--protect-process`).
- **Cooperative Multi-Agent Leases (`lease`, `release`, `leases`)**: `flock`-backed lease registry with automatic dead-PID and TTL reaping so parallel agents never double-book a GPU.
- **vLLM Memory-Utilization Ladder (`vllm-launch`)**: Steps down `--gpu-memory-utilization` (`0.98 -> 0.97 -> 0.96 -> 0.95`) on OOM and exits cleanly with `wait_recommended` instead of force-killing unrelated processes.
- **Evidence-Safe Artifact GC (`gc`, `disk`)**: Dry-run by default; never deletes `validation*.json`, `metrics*.json`, `timing_attestation*.json`, `failed.json`, `*.tex`, or `*.pdf`; gzips large `.jsonl`/`.log` files; removes regenerable caches only on `--apply`; appends an auditable `CLEANUP_*.md` ledger.
- **Native Codex + Antigravity Integration (`mcp`, `install-config`, `SKILL.md`)**: Pure-stdlib JSON-RPC 2.0 stdio MCP server (zero `pip` deps) supporting both newline-delimited and `Content-Length` framing.
## Install
Requires Python 3.11+ (no third-party packages required; `nvidia-smi` is needed for live GPU queries):
```bash
git clone https://github.com/WhoJay0609/lab-gpu-steward.git
cd lab-gpu-steward
python3 -m pip install --no-build-isolation -e .
```
Or run without installing:
```bash
PYTHONPATH=src python3 -m lab_gpu_steward status --json
```
### Wire into Codex and Antigravity (AGY)
Print copy-ready MCP and Skill symlink snippets:
```bash
lab-gpu-steward install-config
```
- **Codex MCP** (`~/.codex/config.toml`):
```toml
[mcp_servers.lab_gpu_steward]
command = "lab-gpu-steward"
args = ["mcp"]
```
- **Antigravity MCP** (`~/.gemini/config/mcp_config.json`):
```json
{
"mcpServers": {
"lab-gpu-steward": {
"command": "lab-gpu-steward",
"args": ["mcp"]
}
}
}
```
- **Skills**: symlink the repository directory into `${CODEX_HOME:-$HOME/.codex}/skills/lab-gpu-steward` and `$HOME/.gemini/config/skills/lab-gpu-steward`.
## Quick Examples
```bash
# Inspect live GPUs by UUID, PID owners, and cooperative leases
lab-gpu-steward status --json
# Pick a GPU for strict wall-clock timing vs shared accuracy
lab-gpu-steward select --mode timing --allow-small-mib 650 --max-sm-util 5 --json
lab-gpu-steward select --mode accuracy --min-free-mib 24000 --json
# Dry-run vLLM memory-utilization ladder
lab-gpu-steward vllm-launch --ladder 0.98,0.97,0.96,0.95 --json -- \
python3 -m vllm.entrypoints.openai.api_server --model Qwen/Qwen3-8B
# Dry-run evidence-safe GC, then apply with cleanup ledger
lab-gpu-steward gc --root ./runs --json
lab-gpu-steward gc --root ./runs --apply --ledger ./runs/CLEANUP.md --json
```
## Verify
```bash
PYTHONPATH=src python3 -m unittest discover -s tests -v
```
## License
MIT © 2026 WhoJay0609. See [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues