AlexWelcing/glim-mlip-bench
glim-mlip-bench (HF ZeroGPU Space)
Foundation-MLIP elastic-constant predictions on a ZeroGPU A100 — the companion compute substrate for the Lupine Science research pipeline.
Why this exists
The pipeline needs MLIP rows in its D1 ledger to validate h4_mlip_invariance. Three obstacles made local execution painful:
- The dev workstation runs Python 3.14 and
ase 3.28won't import (spglib wheel not yet published for 3.14). - CHGNet/MACE-MP/M3GNet on a free GitHub-hosted runner pay a 5-minute cold install per workflow run.
- The glim-think Cloudflare Worker can't run PyTorch.
This Space owns the heavy compute substrate once. Everything else (local CLI, GitHub Actions, the worker itself) calls it via HTTP. ZeroGPU on the HF Pro tier means an A100 (40 GB) for free per-call, ~5 min/request limit.
Endpoints (Gradio API)
Both are callable as plain HTTP — see glim mlip predict in the parent repo's tools/glim.py for a thin CLI client.
When references_json is non-empty in the batch call, the output schema matches the glim-think worker's BenchmarkRecord exactly, so the response can be wrapped in {"records": [...]} and POSTed to /ingest/batch with no transformation.
Deploy
Uses the modern hf CLI (huggingface_hub ≥ 0.30; huggingface-cli is the legacy alias).
# One-time auth (paste an HF Pro write token):
hf auth login
# Create the Space repo:
hf repo create <HF_USERNAME>/glim-mlip-bench \
--repo-type space --space_sdk gradio
# Upload everything in this directory (excluding tests + caches):
cd archive/swarm_preprint_review/scripts/mlip_benchmark/hf_space
hf upload <HF_USERNAME>/glim-mlip-bench . . --repo-type space \
--exclude "__pycache__/*" --exclude "test_app.py" \
--commit-message "deploy glim-mlip-bench"
# Subsequent updates: re-run the upload command above. hf upload diffs
# locally and only sends changed files.After deploy, link the Space to your Pro account in Settings → Variables and secrets → Hardware → enable ZeroGPU. First call has ~5 min cold-init while the GPU pool spins up the container; subsequent calls in the same session are warm (sub-second per element).
Hardware tier
zero-a10g (default in this README's frontmatter) — A10G GPU on the ZeroGPU shared pool. For heavier MACE-MP-0 / batch sweeps, switch to zero-a100-large in Settings.
Local testing (without ZeroGPU)
cd archive/swarm_preprint_review/scripts/mlip_benchmark/hf_space
pip install -r requirements.txt
python app.py # opens Gradio on http://127.0.0.1:7860The @spaces.GPU decorator becomes a no-op when spaces isn't importable (see _gpu_decorator in app.py), so local dev works on CPU.
