量子控制平面
Quantum Control Plane

原始链接: https://github.com/mareksuchodolski12-hash/kwantowy

## 量子控制平面:开发者平台概要 量子控制平面 (QCP) 是一个开源开发者平台,旨在简化量子计算工作流程,类似于 MLflow 或 Airflow。它提供了一个 SDK、CLI 和 REST API,用于提交 QASM 电路、编排实验、基准测试提供商以及可视化结果。 QCP 结构分为三个层面:**控制平面**(管理实验、工作流和成本)、**执行平面**(通过工作节点、提供商和模拟器运行作业)以及用于监控和分析的 **仪表盘**。 主要功能包括提供商抽象、电路优化以及基于 PostgreSQL、Redis 和 Prometheus & Grafana 等可观察性工具构建的强大基础设施。快速入门指南方便使用 Docker 或轻量级本地开发环境进行快速设置。 该平台支持通过提供商插件扩展功能,并包含演示纠缠(贝尔态和 GHZ 态)和格罗弗搜索算法的示例实验。代码检查、类型检查和测试等开发工具通过 `make` 命令集成。

对不起。
相关文章

原文

An open developer platform for quantum computing — submit QASM circuits, orchestrate multi-step experiments, benchmark providers, and visualise results. Think MLflow or Airflow, but for quantum.

Python 3.11+ License: MIT

┌──────────────────────────────────────────────────────┐
│  Developer Platform: SDK · CLI · REST API (/v1/)     │
├──────────────────────────────────────────────────────┤
│  Control Plane: Experiments · Workflows · Cost Gov   │
├──────────────────────────────────────────────────────┤
│  Execution Plane: Workers · Providers · Simulators   │
├──────────────────────────────────────────────────────┤
│  Dashboard: Experiments · Leaderboard · Demo · Runs  │
└──────────────────────────────────────────────────────┘
Layer Components
Control Plane FastAPI API, experiments, workflows, cost governance, circuit optimisation
Execution Plane Async workers, provider adapters, local/Aer simulators, IBM Runtime
Developer Platform Python SDK, qcp CLI, OpenAPI REST API
Dashboard Next.js 14 web console, provider leaderboard, interactive demo
Infrastructure PostgreSQL, Redis queue, Prometheus, Grafana, OpenTelemetry

⚡ Quickstart (5 minutes)

Prerequisites: Python ≥ 3.11, Node 20, Docker

make bootstrap    # Install all dependencies (SDK, CLI, API, web)
make up           # Start Postgres + Redis (infrastructure only)
make migrate      # Apply database migrations
make api          # Start API server on port 8000 (terminal 1)
make worker       # Start job worker (terminal 2)
make web          # Start web console on port 3000 (terminal 3)

Tip: For zero-Docker local development using SQLite + fakeredis, run python start_local.py (or make dev) instead of steps 2–5 above, then make web in a separate terminal. start_local.py automatically creates apps/web/.env.local with the API key so the frontend can authenticate.

To run all services (including observability) via Docker:

make up-all       # Start all services in Docker (postgres, redis, api, worker, web, prometheus, grafana, loki)

To start infrastructure and observability only (then run api/worker/web locally):

make up-infra     # Start Postgres, Redis, Prometheus, Grafana, Loki
make migrate
make api          # terminal 1
make worker       # terminal 2
make web          # terminal 3
# Generate an API key
curl -X POST http://localhost:8000/v1/api-keys \
  -H "Content-Type: application/json" \
  -d '{"name": "dev"}' | python3 -m json.tool

export QCP_API_KEY=qcp_...
pip install -e packages/sdk
from quantum_sdk import QCPClient

client = QCPClient(api_key="qcp_...")
job = client.run_experiment(
    name="bell",
    qasm=open("bell.qasm").read(),
    shots=1024,
)
result = client.wait_for_result(job["job"]["id"])
print(result["result"]["counts"])
pip install -e packages/cli

qcp login
qcp experiment run bell.qasm --provider local_simulator
qcp experiment list
qcp run status <job_id>
qcp result show <job_id>

All endpoints are under /v1/ with OpenAPI documentation at /docs.

Method Endpoint Description
POST /v1/api-keys Create API key
POST /v1/experiments Submit experiment
GET /v1/experiments List experiments
GET /v1/jobs/{id} Get job status
GET /v1/results/{id} Get results
GET /v1/providers List providers
POST /v1/providers/select Smart provider routing
POST /v1/benchmarks Run benchmark
GET /v1/benchmarks List benchmarks
POST /v1/workflows Create workflow
POST /v1/budgets Create budget
POST /v1/circuits/optimise Optimise circuit
POST /v1/results/compare Compare results
├── services/api/          # FastAPI control plane
├── workers/
│   ├── quantum-runner/    # Job execution worker
│   └── benchmark-runner/  # Auto-benchmark worker
├── apps/web/              # Next.js dashboard
├── packages/
│   ├── sdk/               # Python SDK
│   ├── cli/               # CLI tool (qcp)
│   └── contracts/         # Shared Pydantic models
├── plugins/providers/     # External provider plugins
├── docs/                  # Documentation
├── infra/                 # Helm, Terraform, observability
└── examples/              # Quickstart scripts

Creates a maximally entangled pair of qubits using a Hadamard gate followed by a CNOT gate. Demonstrates quantum entanglement — measurement results are correlated: both qubits always agree (00 or 11, each ≈ 50%).

Extends the Bell State to 3 qubits using a Hadamard gate and two successive CNOT gates. Produces the Greenberger–Horne–Zeilinger state where all three qubits are entangled: only 000 and 111 appear (each ≈ 50%). No partial correlations exist, demonstrating genuine multipartite entanglement.

Implements Grover's search algorithm on 2 qubits to find a marked item in an unsorted list of 4 elements with a single query. Demonstrates quadratic quantum speedup over classical search.

External providers can be added under plugins/providers/:

from plugins.providers.base import BaseProvider, ProviderInfo

class MyProvider(BaseProvider):
    name = "my_provider"
    def info(self) -> ProviderInfo: ...
    async def execute(self, qasm: str, shots: int) -> dict[str, int]: ...

Included examples: aws_braket (stub), custom_simulator.

make lint       # ruff + eslint
make typecheck  # mypy + tsc
make test       # pytest
make format     # ruff format
make benchmark  # Run auto-benchmark worker
Target Description
make bootstrap Install all Python and Node dependencies
make up Start Postgres + Redis only
make up-infra Start Postgres, Redis, Prometheus, Grafana, Loki
make up-all Start all services via Docker Compose
make down Stop all Docker services
make migrate Apply database migrations (Alembic)
make api Start API server locally (port 8000)
make worker Start job worker locally
make web Start web console locally (port 3000)
make dev Start API + worker locally (SQLite + fakeredis, no Docker)
make lint Run ruff + eslint
make typecheck Run mypy + tsc
make test Run pytest
make build Build Docker images
make benchmark Run auto-benchmark worker
联系我们 contact @ memedata.com