Spaces:
Sleeping
Sleeping
Day-0 placeholder: stim+pymatching+fastapi+openenv-core, /healthz live
Browse files- Dockerfile +25 -0
- README.md +42 -4
- app.py +78 -0
Dockerfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 4 |
+
PIP_NO_CACHE_DIR=1 \
|
| 5 |
+
PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 6 |
+
|
| 7 |
+
RUN useradd -m -u 1000 user
|
| 8 |
+
USER user
|
| 9 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 10 |
+
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
|
| 13 |
+
# Day-0 deployment-substrate dependencies (Section 11 of the plan):
|
| 14 |
+
# stim + pymatching + fastapi + openenv-core, plus uvicorn for the server.
|
| 15 |
+
RUN pip install --user --no-cache-dir \
|
| 16 |
+
"stim>=1.13,<2.0" \
|
| 17 |
+
"pymatching>=2.2,<3.0" \
|
| 18 |
+
"fastapi>=0.110" \
|
| 19 |
+
"uvicorn[standard]>=0.27" \
|
| 20 |
+
"openenv-core>=0.2.1"
|
| 21 |
+
|
| 22 |
+
COPY --chown=user app.py /app/app.py
|
| 23 |
+
|
| 24 |
+
EXPOSE 7860
|
| 25 |
+
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -1,11 +1,49 @@
|
|
| 1 |
---
|
| 2 |
title: QuantumScribe
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: QuantumScribe
|
| 3 |
+
emoji: 🩺
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
license: mit
|
| 10 |
+
short_description: Day-0 placeholder for the Qubit-Medic OpenEnv server.
|
| 11 |
+
tags:
|
| 12 |
+
- openenv
|
| 13 |
+
- reinforcement-learning
|
| 14 |
+
- quantum-error-correction
|
| 15 |
+
- stim
|
| 16 |
+
- pymatching
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# QuantumScribe — Day-0 placeholder
|
| 20 |
+
|
| 21 |
+
This Space is the **deployment-substrate placeholder** for the
|
| 22 |
+
**Qubit-Medic** OpenEnv server, an RL training environment that teaches
|
| 23 |
+
an LLM to decode errors on the rotated surface code.
|
| 24 |
+
|
| 25 |
+
## Try it
|
| 26 |
+
|
| 27 |
+
* `GET /` — root metadata.
|
| 28 |
+
* `GET /healthz` — liveness probe; returns `{"ok": true, "stim_version": "...", ...}`.
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
curl https://ronitraj-quantumscribe.hf.space/healthz
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## What's coming
|
| 35 |
+
|
| 36 |
+
This placeholder will be replaced by the real **Qubit-Medic** environment:
|
| 37 |
+
|
| 38 |
+
| Endpoint | What it does |
|
| 39 |
+
|---|---|
|
| 40 |
+
| `POST /reset` | Sample a fresh syndrome + observation for the LLM. |
|
| 41 |
+
| `POST /step` | Score the LLM's predicted Pauli frame with five independent rewards (logical correction, syndrome consistency, Hamming overlap, format compliance, PyMatching beat-rate). |
|
| 42 |
+
| `GET /health` | Curriculum + episode statistics. |
|
| 43 |
+
| `GET /healthz` | Liveness (already live on this placeholder). |
|
| 44 |
+
|
| 45 |
+
## Stack
|
| 46 |
+
|
| 47 |
+
* [Stim](https://github.com/quantumlib/Stim) — Clifford circuit simulator.
|
| 48 |
+
* [PyMatching](https://github.com/oscarhiggott/PyMatching) — minimum-weight matching baseline.
|
| 49 |
+
* [FastAPI](https://fastapi.tiangolo.com/) + [openenv-core](https://pypi.org/project/openenv-core/) — server + RL contract.
|
app.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""QuantumScribe - Day-0 deployment-substrate placeholder.
|
| 2 |
+
|
| 3 |
+
This minimal FastAPI app proves the Hugging Face Spaces deployment
|
| 4 |
+
substrate works for the Qubit-Medic / QuantumScribe project:
|
| 5 |
+
|
| 6 |
+
* Stim + PyMatching + FastAPI + openenv-core install cleanly in HF's
|
| 7 |
+
build environment (Day-0 step 2).
|
| 8 |
+
* GET /healthz returns {"ok": true, "stim_version": "..."}, proving the
|
| 9 |
+
server boots and the heavy quantum dependency loads (Day-0 step 3).
|
| 10 |
+
* The endpoint is reachable from a browser (Day-0 step 4) and from a
|
| 11 |
+
Colab `requests.get(...)` call (Day-0 step 5).
|
| 12 |
+
|
| 13 |
+
Once all Day-0 gates pass, this file is replaced by the real Qubit-Medic
|
| 14 |
+
OpenEnv server (qubit_medic.server.app) at the same Space URL, inheriting
|
| 15 |
+
the warm build cache.
|
| 16 |
+
"""
|
| 17 |
+
from __future__ import annotations
|
| 18 |
+
|
| 19 |
+
import sys
|
| 20 |
+
|
| 21 |
+
import stim
|
| 22 |
+
from fastapi import FastAPI
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
app = FastAPI(
|
| 26 |
+
title="QuantumScribe (Qubit-Medic) - Hello Space",
|
| 27 |
+
description="Day-0 deployment-substrate placeholder for the Qubit-Medic "
|
| 28 |
+
"OpenEnv server. Will be replaced by the real env shortly.",
|
| 29 |
+
version="0.0.1-placeholder",
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
_PYMATCHING_VERSION: str
|
| 34 |
+
try:
|
| 35 |
+
import pymatching as _pm
|
| 36 |
+
_PYMATCHING_VERSION = getattr(_pm, "__version__", "unknown")
|
| 37 |
+
except Exception as exc:
|
| 38 |
+
_PYMATCHING_VERSION = f"import-error: {exc}"
|
| 39 |
+
|
| 40 |
+
_OPENENV_VERSION: str
|
| 41 |
+
try:
|
| 42 |
+
import openenv as _oe
|
| 43 |
+
_OPENENV_VERSION = getattr(_oe, "__version__", "unknown")
|
| 44 |
+
except Exception as exc:
|
| 45 |
+
_OPENENV_VERSION = f"import-error: {exc}"
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
@app.get("/")
|
| 49 |
+
def root() -> dict:
|
| 50 |
+
return {
|
| 51 |
+
"service": "QuantumScribe (Qubit-Medic)",
|
| 52 |
+
"status": "Day-0 placeholder live",
|
| 53 |
+
"next": "POST /reset and /step will become available once the real "
|
| 54 |
+
"DecoderEnvironment is pushed.",
|
| 55 |
+
"endpoints": ["/", "/healthz"],
|
| 56 |
+
"links": {
|
| 57 |
+
"github": "https://github.com/ronitraj (replace with repo URL once public)",
|
| 58 |
+
"openenv_docs": "https://meta-pytorch.org/OpenEnv/",
|
| 59 |
+
},
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
@app.get("/healthz")
|
| 64 |
+
def healthz() -> dict:
|
| 65 |
+
"""Day-0 liveness probe.
|
| 66 |
+
|
| 67 |
+
Returns the Stim version - so curl-ing this in a browser or from Colab
|
| 68 |
+
proves both that networking works AND that the heavy quantum deps
|
| 69 |
+
actually loaded. This is the literal endpoint the plan calls for.
|
| 70 |
+
"""
|
| 71 |
+
return {
|
| 72 |
+
"ok": True,
|
| 73 |
+
"stim_version": stim.__version__,
|
| 74 |
+
"pymatching_version": _PYMATCHING_VERSION,
|
| 75 |
+
"openenv_version": _OPENENV_VERSION,
|
| 76 |
+
"python_version": sys.version.split()[0],
|
| 77 |
+
"service": "QuantumScribe",
|
| 78 |
+
}
|