QuantinuumClaw – Quantum Guppy/Selene Stack
This skill provides everything needed to build production-ready quantum applications using Quantinuum (hardware/emulator), Guppy (quantum language), Selene (FastAPI backend), and Fly.io (deployment), with optional Lovable frontend. It is tuned for the OpenClaw Clinical Hackathon and general quantum web apps.
When to Use This Skill
Use when:
- - Building for the OpenClaw Clinical Hackathon or any clinical/healthcare quantum project
- Building web applications that use quantum computing (optimization, chemistry, ML, random, crypto)
- Deploying quantum algorithms as REST APIs or creating dashboards for quantum results
- User mentions: clinical, healthcare, drug discovery, treatment optimization, patient stratification, molecular simulation, clinical trials, Guppy, Selene, Fly.io
Example requests: "Build a quantum portfolio optimizer with a web interface" · "Deploy my Guppy algorithm to the cloud" · "Create a clinical molecular simulation demo" · "Set up a quantum ML service on Fly.io"
Stack at a Glance
| Component | Role |
|---|
| Quantinuum | Quantum hardware (H-series) or emulator |
| Guppy |
Quantum programming (circuits, gates, measurement) |
|
Selene | FastAPI backend that runs Guppy and exposes REST API |
|
Fly.io | Hosts the Selene backend in the cloud |
|
Lovable | React/TS frontend template; use
assets/lovable-template/ or any app that calls the Selene API |
Quick Start (One Command)
From the repo root:
CODEBLOCK0
Then set VITE_API_URL in the frontend to your Fly.io app URL (e.g. https://clinical-demo.fly.dev).
Clinical use-case → --use-case mapping:
| Clinical idea | INLINECODE4 | Notes |
|---|
| Drug discovery / molecular sim | INLINECODE5 | Molecules, energy, properties |
| Treatment / resource optimization |
optimization | QAOA-style optimization |
| Patient stratification / ML |
ml | Quantum ML models |
| Trial randomization |
random | Quantum RNG |
| Secure keys / protocols |
crypto | Quantum-safe crypto |
General use cases (portfolio, finance, etc.) also use optimization, chemistry, ml, random, crypto, or finance. See references/clinical-use-cases.md for detailed clinical mappings.
Full Workflow: Creating a Quantum Application
Step 1: Define the use case
Identify the problem (optimization, simulation, ML, cryptography, clinical, etc.).
Step 2: Create Selene backend
python3 scripts/setup_selene_service.py \
--app-name "my-quantum-app" \
--use-case "chemistry" \
--description "Quantum chemistry simulator"
This creates a backend dir with FastAPI, health check, Dockerfile, and
fly.toml.
Step 3: Implement your Guppy circuit
Edit
my-quantum-app/main.py →
QuantumService._run_real_quantum(). Use
references/guppy_guide.md for syntax. For clinical: chemistry (molecule, shots, precision), optimization (objective, constraints), ML (features, epochs).
Step 4: Deploy to Fly.io
python3 scripts/flyio_deploy.py --app-name "my-quantum-app" --service-dir "my-quantum-app" --region "lhr"
Set secrets with
fly secrets set; use emulator for demos if preferred.
Step 5: Frontend
Use
assets/lovable-template/ or run:
python3 scripts/lovable_integrate.py \
--app-name "my-frontend" \
--backend-url "https://my-quantum-app.fly.dev" \
--quantum-use-case "chemistry"
Then
npm install and
npm run dev in the frontend dir.
Step 6: Connect and test
Point frontend
VITE_API_URL to the Fly.io backend; hit
/health to verify.
Clinical Use Case Cheat Sheet
- - Drug discovery / molecular simulation:
chemistry — VQE-style energy/property in Guppy; expose molecule type and params via API. - Treatment / resource optimization:
optimization — Define objective (cost, wait time); run QAOA in Selene; display results in UI. - Patient stratification / classification:
ml — Map patient features to model inputs; return risk/stratum or classification. - Randomization (e.g. trials):
random — Quantum RNG from Guppy; expose bits/shots in API. - Security / key material:
crypto — Key generation or quantum-safe primitives; keep keys on backend only.
Data and Compliance (Clinical / Hackathon)
- - Demos: Use synthetic or de-identified data only. Do not send real PHI to quantum backends or store in Fly.io without a compliance plan.
- API keys: Store in Fly.io secrets (
fly secrets set), never in code or frontend. - Production: Add auth, rate limiting, and consider HIPAA/DPA; restrict CORS in Selene.
Resources
scripts/
- -
create_quantum_app.py — All-in-one: backend + deploy + frontend - INLINECODE34 — Scaffold Selene backend
- INLINECODE35 — Deploy to Fly.io
- INLINECODE36 — Frontend wired to backend URL
references/
- -
guppy_guide.md — Guppy syntax, gates, circuits, examples - INLINECODE38 — Endpoints, request/response, errors, jobs
- INLINECODE39 — Fly.io scaling, regions, secrets, monitoring
- INLINECODE40 — Frontend patterns, dashboard, API client
- INLINECODE41 — Detailed clinical use-case mappings and compliance notes
assets/
- -
selene-template/ — Backend boilerplate (main.py, Dockerfile, fly.toml, .env.example) - INLINECODE43 — React/TS frontend with QuantumDashboard and API client
Advanced: Multi-Quantum Use Cases
- - Optimization dashboard: Selene + QAOA/VQE; Lovable with sliders; Fly.io with scaling.
- Chemistry explorer: Guppy molecular simulations; 3D viewer; optional persistent storage.
- Quantum ML API: Selene exposing QNN/QSVM; Lovable for training/predictions; Fly.io (GPU if needed).
Performance, Cost, and Security
- - Queuing: Use job queues for long-running quantum jobs; WebSockets or polling in frontend.
- Caching: Cache identical computations to reduce quantum hardware cost.
- Fly.io: Scale to zero when idle (
min_machines_running = 0); use references/flyio_config.md for VM sizing. - Security: No API keys in frontend; rate limiting on Selene; HTTPS in production; see
references/selene_api.md for auth patterns.
Troubleshooting
- - Guppy import error:
pip install guppy in backend; or use mock mode for demos. - Selene not starting: Check
fly.toml, fly logs, and env vars. - Frontend can’t connect: Verify
VITE_API_URL, CORS in Selene, and curl .../health. - Fly.io deploy fails:
fly deploy --clean; fly logs --phase build; ensure fly auth login. - Quantum results wrong: Validate circuit logic and measurement; test with emulator first.
Next Steps
After initial setup: monitor quantum usage/costs; add auth to Selene if public; improve error handling and logging; consider persistence for job history.
For detailed clinical use-case specs and compliance reminders, see
references/clinical-use-cases.md.
QuantinuumClaw – Quantum Guppy/Selene 技术栈
本技能提供使用 Quantinuum(硬件/模拟器)、Guppy(量子语言)、Selene(FastAPI 后端)和 Fly.io(部署)构建生产级量子应用所需的一切,并可选择 Lovable 前端。它专为 OpenClaw 临床黑客马拉松 和通用量子 Web 应用进行了优化。
何时使用本技能
适用场景:
- - 为 OpenClaw 临床黑客马拉松或任何临床/医疗保健量子项目进行开发
- 构建使用量子计算(优化、化学、机器学习、随机数、加密)的 Web 应用
- 将量子算法部署为 REST API 或创建量子结果仪表板
- 用户提及:临床、医疗保健、药物发现、治疗方案优化、患者分层、分子模拟、临床试验、Guppy、Selene、Fly.io
示例请求: 构建一个带 Web 界面的量子投资组合优化器 · 将我的 Guppy 算法部署到云端 · 创建一个临床分子模拟演示 · 在 Fly.io 上设置量子机器学习服务
技术栈概览
| 组件 | 角色 |
|---|
| Quantinuum | 量子硬件(H 系列)或模拟器 |
| Guppy |
量子编程(电路、门、测量) |
|
Selene | 运行 Guppy 并暴露 REST API 的 FastAPI 后端 |
|
Fly.io | 在云端托管 Selene 后端 |
|
Lovable | React/TS 前端模板;使用 assets/lovable-template/ 或任何调用 Selene API 的应用 |
快速开始(一条命令)
从仓库根目录执行:
bash
python3 scripts/createquantumapp.py \
--app-name clinical-demo \
--use-case chemistry \
--description Clinical molecular simulation \
--deploy
然后在前端设置 VITEAPIURL 为你的 Fly.io 应用 URL(例如 https://clinical-demo.fly.dev)。
临床用例 → --use-case 映射:
| 临床想法 | --use-case | 说明 |
|---|
| 药物发现 / 分子模拟 | chemistry | 分子、能量、属性 |
| 治疗 / 资源优化 |
optimization | QAOA 风格优化 |
| 患者分层 / 机器学习 | ml | 量子机器学习模型 |
| 试验随机化 | random | 量子随机数生成器 |
| 安全密钥 / 协议 | crypto | 量子安全加密 |
通用用例(投资组合、金融等)也使用 optimization、chemistry、ml、random、crypto 或 finance。详细临床映射请参见 references/clinical-use-cases.md。
完整工作流:创建量子应用
步骤 1:定义用例
确定问题(优化、模拟、机器学习、加密、临床等)。
步骤 2:创建 Selene 后端
bash
python3 scripts/setup
seleneservice.py \
--app-name my-quantum-app \
--use-case chemistry \
--description Quantum chemistry simulator
这将创建一个包含 FastAPI、健康检查、Dockerfile 和 fly.toml 的后端目录。
步骤 3:实现你的 Guppy 电路
编辑 my-quantum-app/main.py → QuantumService.
runreal
quantum()。语法参考 references/guppyguide.md。临床场景:化学(分子、shots、精度)、优化(目标、约束)、机器学习(特征、epochs)。
步骤 4:部署到 Fly.io
bash
python3 scripts/flyio_deploy.py --app-name my-quantum-app --service-dir my-quantum-app --region lhr
使用 fly secrets set 设置密钥;演示时可按需使用模拟器。
步骤 5:前端
使用 assets/lovable-template/ 或运行:
bash
python3 scripts/lovable_integrate.py \
--app-name my-frontend \
--backend-url https://my-quantum-app.fly.dev \
--quantum-use-case chemistry
然后在前端目录中执行 npm install 和 npm run dev。
步骤 6:连接和测试
将前端 VITE
APIURL 指向 Fly.io 后端;访问 /health 进行验证。
临床用例速查表
- - 药物发现 / 分子模拟: chemistry — 在 Guppy 中使用 VQE 风格的能量/属性计算;通过 API 暴露分子类型和参数。
- 治疗 / 资源优化: optimization — 定义目标(成本、等待时间);在 Selene 中运行 QAOA;在 UI 中显示结果。
- 患者分层 / 分类: ml — 将患者特征映射到模型输入;返回风险/分层或分类结果。
- 随机化(例如试验): random — 来自 Guppy 的量子随机数生成器;在 API 中暴露比特/shots。
- 安全 / 密钥材料: crypto — 密钥生成或量子安全原语;仅在后端保留密钥。
数据和合规性(临床 / 黑客马拉松)
- - 演示: 仅使用合成或去标识化数据。未经合规计划,请勿将真实受保护健康信息发送到量子后端或存储在 Fly.io 中。
- API 密钥: 存储在 Fly.io 机密中(fly secrets set),切勿存储在代码或前端中。
- 生产环境: 添加身份验证、速率限制,并考虑 HIPAA/DPA;在 Selene 中限制 CORS。
资源
scripts/
- - createquantumapp.py — 一体化:后端 + 部署 + 前端
- setupseleneservice.py — 搭建 Selene 后端框架
- flyiodeploy.py — 部署到 Fly.io
- lovableintegrate.py — 前端连接到后端 URL
references/
- - guppyguide.md — Guppy 语法、门、电路、示例
- seleneapi.md — 端点、请求/响应、错误、任务
- flyioconfig.md — Fly.io 扩展、区域、机密、监控
- lovablepatterns.md — 前端模式、仪表板、API 客户端
- clinical-use-cases.md — 详细临床用例映射和合规说明
assets/
- - selene-template/ — 后端样板(main.py、Dockerfile、fly.toml、.env.example)
- lovable-template/ — 带有 QuantumDashboard 和 API 客户端的 React/TS 前端
高级:多量子用例
- - 优化仪表板: Selene + QAOA/VQE;Lovable 带滑块;Fly.io 带扩展。
- 化学探索器: Guppy 分子模拟;3D 查看器;可选持久化存储。
- 量子机器学习 API: Selene 暴露 QNN/QSVM;Lovable 用于训练/预测;Fly.io(如果需要 GPU)。
性能、成本和安全
- - 队列: 对长时间运行的量子任务使用任务队列;前端使用 WebSockets 或轮询。
- 缓存: 缓存相同计算以减少量子硬件成本。
- Fly.io: 空闲时缩放到零(minmachinesrunning = 0);VM 大小配置参考 references/flyioconfig.md。
- 安全: 前端不包含 API 密钥;Selene 上设置速率限制;生产环境使用 HTTPS;身份验证模式参见 references/seleneapi.md。
故障排除
- - Guppy 导入错误: 在后端执行 pip install guppy;或对演示使用模拟模式。
- Selene 无法启动: 检查 fly.toml、fly logs 和环境变量。
- 前端无法连接: 验证 VITEAPIURL、Selene 中的 CORS 配置以及 curl .../health。
- Fly.io 部署失败: fly deploy --clean;fly logs --phase build;确保 fly auth login。
- 量子结果错误: 验证电路逻辑和测量;先使用模拟器测试。
后续步骤
初始设置完成后:监控量子使用情况/成本;如果公开则向 Selene 添加身份验证;改进错误处理和日志记录;考虑为任务历史添加持久化存储。
有关详细的临床用例规范和合规提醒,请参见 references/clinical-use-cases.md。