qtwist 0.1.0b0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qtwist-0.1.0b0/LICENSE +15 -0
- qtwist-0.1.0b0/MANIFEST.in +15 -0
- qtwist-0.1.0b0/PKG-INFO +186 -0
- qtwist-0.1.0b0/README.md +143 -0
- qtwist-0.1.0b0/pyproject.toml +57 -0
- qtwist-0.1.0b0/qtwist/__init__.py +15 -0
- qtwist-0.1.0b0/qtwist/__main__.py +5 -0
- qtwist-0.1.0b0/qtwist/aer_compat.py +265 -0
- qtwist-0.1.0b0/qtwist/api.py +2308 -0
- qtwist-0.1.0b0/qtwist/cli.py +694 -0
- qtwist-0.1.0b0/qtwist/payments.py +392 -0
- qtwist-0.1.0b0/qtwist/pricing.py +192 -0
- qtwist-0.1.0b0/qtwist/qpu_backend.py +437 -0
- qtwist-0.1.0b0/qtwist/qsim.py +14 -0
- qtwist-0.1.0b0/qtwist/router.py +211 -0
- qtwist-0.1.0b0/qtwist/web/__init__.py +1 -0
- qtwist-0.1.0b0/qtwist/web/api.py +608 -0
- qtwist-0.1.0b0/qtwist/web/app.py +664 -0
- qtwist-0.1.0b0/qtwist/web/dispatch.py +31 -0
- qtwist-0.1.0b0/qtwist/web/jupyter_proxy.py +184 -0
- qtwist-0.1.0b0/qtwist/web/qiskit_sandbox.py +134 -0
- qtwist-0.1.0b0/qtwist/web/static/app.js +832 -0
- qtwist-0.1.0b0/qtwist/web/static/index.html +64 -0
- qtwist-0.1.0b0/qtwist/web/static/styles.css +448 -0
- qtwist-0.1.0b0/qtwist/web/store.py +408 -0
- qtwist-0.1.0b0/qtwist/web/worker.py +124 -0
- qtwist-0.1.0b0/qtwist/zne.py +76 -0
- qtwist-0.1.0b0/qtwist.egg-info/PKG-INFO +186 -0
- qtwist-0.1.0b0/qtwist.egg-info/SOURCES.txt +84 -0
- qtwist-0.1.0b0/qtwist.egg-info/dependency_links.txt +1 -0
- qtwist-0.1.0b0/qtwist.egg-info/entry_points.txt +2 -0
- qtwist-0.1.0b0/qtwist.egg-info/requires.txt +35 -0
- qtwist-0.1.0b0/qtwist.egg-info/top_level.txt +2 -0
- qtwist-0.1.0b0/qtwist_core/__init__.py +17 -0
- qtwist-0.1.0b0/qtwist_core/certification/__init__.py +15 -0
- qtwist-0.1.0b0/qtwist_core/certification/consistency_checker.py +130 -0
- qtwist-0.1.0b0/qtwist_core/certification/cross_validator.py +147 -0
- qtwist-0.1.0b0/qtwist_core/certification/error_budget.py +675 -0
- qtwist-0.1.0b0/qtwist_core/certification/generalization.py +348 -0
- qtwist-0.1.0b0/qtwist_core/certification/knn_baseline.py +86 -0
- qtwist-0.1.0b0/qtwist_core/certification/models/mlp_mitigator.pt +0 -0
- qtwist-0.1.0b0/qtwist_core/certification/models/mlp_mitigator_scalable.pt +0 -0
- qtwist-0.1.0b0/qtwist_core/certification/models/mlp_mitigator_scalable_scaler.json +1 -0
- qtwist-0.1.0b0/qtwist_core/certification/models/mlp_mitigator_scaler.json +1 -0
- qtwist-0.1.0b0/qtwist_core/certification/models/xgb_gap_predictor.json +1 -0
- qtwist-0.1.0b0/qtwist_core/certification/models/xgb_gap_predictor_scalable.json +1 -0
- qtwist-0.1.0b0/qtwist_core/certification/neural_features.py +371 -0
- qtwist-0.1.0b0/qtwist_core/certification/noise_oracle.py +191 -0
- qtwist-0.1.0b0/qtwist_core/certification/reference_circuits.py +152 -0
- qtwist-0.1.0b0/qtwist_core/core/__init__.py +20 -0
- qtwist-0.1.0b0/qtwist_core/core/circuit.py +333 -0
- qtwist-0.1.0b0/qtwist_core/core/engine_a.py +274 -0
- qtwist-0.1.0b0/qtwist_core/core/engine_b.py +337 -0
- qtwist-0.1.0b0/qtwist_core/core/engine_b_mpdo.py +238 -0
- qtwist-0.1.0b0/qtwist_core/core/engine_c.py +901 -0
- qtwist-0.1.0b0/qtwist_core/core/engine_d_adaptive.py +1628 -0
- qtwist-0.1.0b0/qtwist_core/core/engine_f_tnt.py +610 -0
- qtwist-0.1.0b0/qtwist_core/core/gate_conventions.py +471 -0
- qtwist-0.1.0b0/qtwist_core/core/zne.py +562 -0
- qtwist-0.1.0b0/qtwist_core/physics/__init__.py +17 -0
- qtwist-0.1.0b0/qtwist_core/physics/calibration_ingest.py +235 -0
- qtwist-0.1.0b0/qtwist_core/physics/consistency_checker_200q.py +291 -0
- qtwist-0.1.0b0/qtwist_core/physics/drift_tracker.py +142 -0
- qtwist-0.1.0b0/qtwist_core/physics/hardware_interface.py +621 -0
- qtwist-0.1.0b0/qtwist_core/physics/hardware_validation.py +585 -0
- qtwist-0.1.0b0/qtwist_core/physics/lindbladian.py +499 -0
- qtwist-0.1.0b0/qtwist_core/physics/mock_qpu.py +73 -0
- qtwist-0.1.0b0/qtwist_core/physics/mock_qpu_200q.py +200 -0
- qtwist-0.1.0b0/qtwist_core/physics/snapshot.py +91 -0
- qtwist-0.1.0b0/qtwist_core/physics/spl_noise_model.py +288 -0
- qtwist-0.1.0b0/qtwist_core/py.typed +0 -0
- qtwist-0.1.0b0/qtwist_core/router/__init__.py +11 -0
- qtwist-0.1.0b0/qtwist_core/router/dispatcher.py +1078 -0
- qtwist-0.1.0b0/qtwist_core/router/lightcone.py +72 -0
- qtwist-0.1.0b0/qtwist_core/router/snake_mapper.py +172 -0
- qtwist-0.1.0b0/qtwist_core/tests/test_cross_engine.py +1203 -0
- qtwist-0.1.0b0/qtwist_core/tests/test_fallback_tnt.py +195 -0
- qtwist-0.1.0b0/qtwist_core/utils/__init__.py +9 -0
- qtwist-0.1.0b0/qtwist_core/utils/bitstring_mapper.py +144 -0
- qtwist-0.1.0b0/qtwist_core/utils/transpiler.py +625 -0
- qtwist-0.1.0b0/setup.cfg +4 -0
- qtwist-0.1.0b0/tests/conftest.py +11 -0
- qtwist-0.1.0b0/tests/test_cli.py +37 -0
- qtwist-0.1.0b0/tests/test_dispatch.py +71 -0
- qtwist-0.1.0b0/tests/test_engine.py +38 -0
- qtwist-0.1.0b0/tests/test_web.py +99 -0
qtwist-0.1.0b0/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Q-TWIST — PROPRIETARY SOFTWARE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Q-TWIST. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software is the proprietary property of Q-TWIST. It is licensed for
|
|
6
|
+
use only under the terms of a separate written license agreement with
|
|
7
|
+
Q-TWIST. No rights are granted except as expressly set forth in such an
|
|
8
|
+
agreement. Unauthorized reproduction, distribution, or use is prohibited.
|
|
9
|
+
|
|
10
|
+
The Q-TWIST Python SDK (`pip install qtwist`) and web console are provided
|
|
11
|
+
"AS IS" without warranty of any kind, express or implied, including but not
|
|
12
|
+
limited to the warranties of merchantability, fitness for a particular
|
|
13
|
+
purpose, and non-infringement.
|
|
14
|
+
|
|
15
|
+
For licensing inquiries, contact Q-TWIST.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
include pyproject.toml
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
|
|
5
|
+
recursive-include qtwist *.py
|
|
6
|
+
recursive-include qtwist/web *.py *.html *.css *.js
|
|
7
|
+
recursive-include qtwist_core *.py *.pt *.json py.typed
|
|
8
|
+
recursive-include tests *.py
|
|
9
|
+
|
|
10
|
+
prune build
|
|
11
|
+
prune dist
|
|
12
|
+
prune .venv
|
|
13
|
+
prune research
|
|
14
|
+
|
|
15
|
+
global-exclude *.pyc __pycache__
|
qtwist-0.1.0b0/PKG-INFO
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qtwist
|
|
3
|
+
Version: 0.1.0b0
|
|
4
|
+
Summary: Q-TWIST: certified-methodology digital twin for noisy quantum processors - engines, Python SDK, and web console.
|
|
5
|
+
Author: Q-TWIST
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Project-URL: Homepage, https://qtwist.example
|
|
8
|
+
Keywords: quantum,simulation,certified,digital-twin,noise
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: numpy>=2.0
|
|
13
|
+
Requires-Dist: scipy>=1.11
|
|
14
|
+
Requires-Dist: threadpoolctl>=3.0
|
|
15
|
+
Requires-Dist: qiskit>=1.0
|
|
16
|
+
Requires-Dist: quimb>=1.8
|
|
17
|
+
Requires-Dist: fastapi>=0.110
|
|
18
|
+
Requires-Dist: uvicorn[standard]>=0.27
|
|
19
|
+
Requires-Dist: pydantic>=2.0
|
|
20
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
21
|
+
Requires-Dist: razorpay>=2.0
|
|
22
|
+
Requires-Dist: httpx>=0.27
|
|
23
|
+
Requires-Dist: websockets>=12.0
|
|
24
|
+
Provides-Extra: torch
|
|
25
|
+
Requires-Dist: torch>=2.0; extra == "torch"
|
|
26
|
+
Provides-Extra: qpu
|
|
27
|
+
Requires-Dist: qiskit-aer>=0.14; extra == "qpu"
|
|
28
|
+
Requires-Dist: qiskit-ibm-runtime>=0.40; extra == "qpu"
|
|
29
|
+
Provides-Extra: jupyter
|
|
30
|
+
Requires-Dist: jupyter-server>=2.0; extra == "jupyter"
|
|
31
|
+
Requires-Dist: notebook>=7.0; extra == "jupyter"
|
|
32
|
+
Provides-Extra: full
|
|
33
|
+
Requires-Dist: torch>=2.0; extra == "full"
|
|
34
|
+
Requires-Dist: razorpay>=2.0; extra == "full"
|
|
35
|
+
Requires-Dist: qiskit-aer>=0.14; extra == "full"
|
|
36
|
+
Requires-Dist: qiskit-ibm-runtime>=0.40; extra == "full"
|
|
37
|
+
Requires-Dist: jupyter-server>=2.0; extra == "full"
|
|
38
|
+
Requires-Dist: notebook>=7.0; extra == "full"
|
|
39
|
+
Provides-Extra: test
|
|
40
|
+
Requires-Dist: pytest>=8.0; extra == "test"
|
|
41
|
+
Requires-Dist: httpx>=0.27; extra == "test"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# Q-TWIST (Beta) — The Honest Oracle
|
|
45
|
+
|
|
46
|
+
Q-TWIST is a physics-constrained quantum-circuit inference engine that tells
|
|
47
|
+
you **what it can simulate, to what error, and whether your circuit is worth
|
|
48
|
+
running on real hardware** — and refuses, honestly, when it cannot. No silent
|
|
49
|
+
wrong numbers. No "certified digital twin" marketing. Rigorous L1 error bounds,
|
|
50
|
+
and an explicit refusal with a fix when a circuit is out of envelope.
|
|
51
|
+
|
|
52
|
+
> **Status / version.** PyPI `0.1.0b0` is the current **beta** preview. A prior
|
|
53
|
+
> stable `5.0.0` is deprecated; install the beta with
|
|
54
|
+
> `pip install qtwist==0.1.0b0` (or `pip install --pre qtwist`).
|
|
55
|
+
|
|
56
|
+
It ships in three tiers:
|
|
57
|
+
|
|
58
|
+
* **FREE** — a local **`AerSimulator`-style drop-in** that runs on your laptop
|
|
59
|
+
CPU. Drop it into any Qiskit expectation-value workflow. No token, no bill.
|
|
60
|
+
* **PRO** — a **metered cloud GPU worker** unlocked by an API key / premium
|
|
61
|
+
token. Costs are previewed *before* every run (a metered credit wallet).
|
|
62
|
+
* **ENTERPRISE** — a **warm GPU worker pool** (low-latency 1024-qubit runs) plus
|
|
63
|
+
custom deployment and SLAs.
|
|
64
|
+
|
|
65
|
+
Everything today is classical simulation + an honest readiness verdict. The
|
|
66
|
+
"certified" label is only ever applied when a live QPU ground truth is behind it;
|
|
67
|
+
otherwise results are marked `UNCERTIFIED`.
|
|
68
|
+
|
|
69
|
+
## Install
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
python -m pip install qtwist==0.1.0b0
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Optional full-stack extras (Qiskit Aer input, the adaptive-MPS engine, and the
|
|
76
|
+
in-browser notebook): `python -m pip install -e ".[full]"`.
|
|
77
|
+
|
|
78
|
+
## Quickstart — free local drop-in
|
|
79
|
+
|
|
80
|
+
You only need standard Qiskit. `QtwistSimulator` mirrors `AerSimulator`'s
|
|
81
|
+
`run()` / `result()` surface for the expectation-value workflow:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from qiskit import QuantumCircuit
|
|
85
|
+
from qtwist.aer_compat import QtwistSimulator
|
|
86
|
+
|
|
87
|
+
# 20-qubit transverse-field Ising model, 3 layers
|
|
88
|
+
qc = QuantumCircuit(20)
|
|
89
|
+
for _ in range(3):
|
|
90
|
+
for i in range(19):
|
|
91
|
+
qc.rzz(0.5, i, i + 1)
|
|
92
|
+
for i in range(20):
|
|
93
|
+
qc.rx(0.3, i)
|
|
94
|
+
|
|
95
|
+
sim = QtwistSimulator(instance="local") # free, laptop CPU
|
|
96
|
+
res = sim.run(qc, observable="Z0Z1", epsilon_target=0.05).result()
|
|
97
|
+
|
|
98
|
+
print(f"<Z0 Z1> = {res.value():+.6f} +/- {res.error:.4f}")
|
|
99
|
+
print(res.explain()) # QPU-Readiness Oracle verdict
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## The QPU-Readiness Oracle
|
|
103
|
+
|
|
104
|
+
Every result carries a `qpu_readiness` verdict — the one thing you want to
|
|
105
|
+
know before spending real QPU queue time:
|
|
106
|
+
|
|
107
|
+
| Verdict | Meaning | What to do |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `READY_FOR_QPU` | Within Q-TWIST's validated envelope; value trustworthy within the reported L1 bound | Run it on hardware to validate the physics |
|
|
110
|
+
| `NEEDS_FIXES` | Rejected only for a fixable issue (long-range gate, multi-controlled gate, wrong topology) | Apply the listed suggestions, re-run |
|
|
111
|
+
| `INTRACTABLE` | Beyond classical simulation / QPU-advantage territory | Run on hardware directly if you must; Q-TWIST can't pre-validate |
|
|
112
|
+
|
|
113
|
+
## Quickstart — premium cloud tier (metered)
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from qtwist.aer_compat import QtwistSimulator
|
|
117
|
+
from qtwist.pricing import Wallet
|
|
118
|
+
|
|
119
|
+
wallet = Wallet(token="PRO_TOKEN") # $50 base = 100 credits
|
|
120
|
+
sim = QtwistSimulator(instance="cloud:PRO_TOKEN", wallet=wallet, topology="1D_chain")
|
|
121
|
+
|
|
122
|
+
print(sim.estimate(qc)) # pre-flight cost, never bills
|
|
123
|
+
# [PRO / cloud] engine=ENGINE_D n=20 depth=39 -- est. 0.97 credits (~$0.49) ...
|
|
124
|
+
|
|
125
|
+
res = sim.run(qc, observable="Z0Z1").result() # charged only after confirm
|
|
126
|
+
print(res.explain())
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Tiers:
|
|
130
|
+
| Tier | Runs on | Billing | Capability Classifier | QPU-Readiness Oracle |
|
|
131
|
+
|---|---|---|---|---|
|
|
132
|
+
| FREE | laptop CPU | free | instant | yes (local) |
|
|
133
|
+
| PRO | cloud GPU worker | metered credit wallet (~1 credit ≈ 1 GPU-min, $50/100) | instant | yes (cloud) |
|
|
134
|
+
| ENTERPRISE | warm GPU worker pool / custom | $500 base, quote for scale | instant | yes (cloud) |
|
|
135
|
+
|
|
136
|
+
## Web console & 1024-qubit GPU tier
|
|
137
|
+
|
|
138
|
+
For paid 1024-qubit (Engine-D MPS) execution, Q-TWIST runs as a small web
|
|
139
|
+
console plus a **warm GPU worker pool**:
|
|
140
|
+
|
|
141
|
+
* The console (cheap, always-on, CPU) serves the UI, auth, billing, and the
|
|
142
|
+
interactive playground. **Free** callers run in-process on CPU; **paid**
|
|
143
|
+
(Pro/Enterprise) callers are delegated to the GPU worker pool.
|
|
144
|
+
* `SimDispatcher` (`qtwist/web/dispatch.py`) routes free → local CPU and paid →
|
|
145
|
+
an `HttpWorker` that calls the worker's internal `/api/worker/predict`.
|
|
146
|
+
* Each worker is the same app image with `QTWIST_GPU=1` (cupy MPS path), kept
|
|
147
|
+
warm by `scripts/gpu_pool.py` (Local for dev, JarvisLabs SDK for prod).
|
|
148
|
+
|
|
149
|
+
Launch locally:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
qtwist serve # or: uvicorn qtwist.web.app:app --port 8000
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Or deploy the full stack with Docker Compose (console + GPU worker + redis):
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
QTWIST_WORKER_TOKEN=$(openssl rand -hex 24) docker compose up --build
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
See `DEPLOY.md` for the Render / Docker / JarvisLabs GPU-pool walkthrough.
|
|
162
|
+
|
|
163
|
+
## What "1024 qubits" really means (honesty note)
|
|
164
|
+
|
|
165
|
+
Q-TWIST can run **1024-qubit** circuits, but only inside the **Engine-D (adaptive
|
|
166
|
+
MPS) envelope**: a **local** observable (≤ 30 qubits), a **1D chain**,
|
|
167
|
+
**nearest-neighbour** gates, and **area-law** entanglement. Inside that envelope
|
|
168
|
+
it is exact and fast (e.g. GHZ-1024 `<Z0Z1> = +1.0000`). It is **not universal**:
|
|
169
|
+
long-range gates, global observables > 30 qubits, QFT, dynamic circuits, and
|
|
170
|
+
multi-controlled gates are **rejected** with a reason and a fix — never faked.
|
|
171
|
+
|
|
172
|
+
## Topology support
|
|
173
|
+
|
|
174
|
+
`QTWISTBackend(topology=...)` and `predict(..., topology=...)` accept:
|
|
175
|
+
|
|
176
|
+
* `"1D_chain"` — Engine D (adaptive MPS) envelope, up to 1024 qubits
|
|
177
|
+
* `"2D_heavy_hex"` — shallow circuits via Engine C; deep heavy-hex is rejected with routing guidance
|
|
178
|
+
* `"all_to_all"` — fully connected, any engine that fits
|
|
179
|
+
* a Qiskit `CouplingMap` — edges are read from the map (1D chains are detected automatically)
|
|
180
|
+
|
|
181
|
+
## Verification
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
python -m pytest tests/ # dispatch + engine honesty tests
|
|
185
|
+
python research/demo_1024.py # 1024-qubit capability demo (GHZ exact)
|
|
186
|
+
```
|
qtwist-0.1.0b0/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Q-TWIST (Beta) — The Honest Oracle
|
|
2
|
+
|
|
3
|
+
Q-TWIST is a physics-constrained quantum-circuit inference engine that tells
|
|
4
|
+
you **what it can simulate, to what error, and whether your circuit is worth
|
|
5
|
+
running on real hardware** — and refuses, honestly, when it cannot. No silent
|
|
6
|
+
wrong numbers. No "certified digital twin" marketing. Rigorous L1 error bounds,
|
|
7
|
+
and an explicit refusal with a fix when a circuit is out of envelope.
|
|
8
|
+
|
|
9
|
+
> **Status / version.** PyPI `0.1.0b0` is the current **beta** preview. A prior
|
|
10
|
+
> stable `5.0.0` is deprecated; install the beta with
|
|
11
|
+
> `pip install qtwist==0.1.0b0` (or `pip install --pre qtwist`).
|
|
12
|
+
|
|
13
|
+
It ships in three tiers:
|
|
14
|
+
|
|
15
|
+
* **FREE** — a local **`AerSimulator`-style drop-in** that runs on your laptop
|
|
16
|
+
CPU. Drop it into any Qiskit expectation-value workflow. No token, no bill.
|
|
17
|
+
* **PRO** — a **metered cloud GPU worker** unlocked by an API key / premium
|
|
18
|
+
token. Costs are previewed *before* every run (a metered credit wallet).
|
|
19
|
+
* **ENTERPRISE** — a **warm GPU worker pool** (low-latency 1024-qubit runs) plus
|
|
20
|
+
custom deployment and SLAs.
|
|
21
|
+
|
|
22
|
+
Everything today is classical simulation + an honest readiness verdict. The
|
|
23
|
+
"certified" label is only ever applied when a live QPU ground truth is behind it;
|
|
24
|
+
otherwise results are marked `UNCERTIFIED`.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
python -m pip install qtwist==0.1.0b0
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Optional full-stack extras (Qiskit Aer input, the adaptive-MPS engine, and the
|
|
33
|
+
in-browser notebook): `python -m pip install -e ".[full]"`.
|
|
34
|
+
|
|
35
|
+
## Quickstart — free local drop-in
|
|
36
|
+
|
|
37
|
+
You only need standard Qiskit. `QtwistSimulator` mirrors `AerSimulator`'s
|
|
38
|
+
`run()` / `result()` surface for the expectation-value workflow:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from qiskit import QuantumCircuit
|
|
42
|
+
from qtwist.aer_compat import QtwistSimulator
|
|
43
|
+
|
|
44
|
+
# 20-qubit transverse-field Ising model, 3 layers
|
|
45
|
+
qc = QuantumCircuit(20)
|
|
46
|
+
for _ in range(3):
|
|
47
|
+
for i in range(19):
|
|
48
|
+
qc.rzz(0.5, i, i + 1)
|
|
49
|
+
for i in range(20):
|
|
50
|
+
qc.rx(0.3, i)
|
|
51
|
+
|
|
52
|
+
sim = QtwistSimulator(instance="local") # free, laptop CPU
|
|
53
|
+
res = sim.run(qc, observable="Z0Z1", epsilon_target=0.05).result()
|
|
54
|
+
|
|
55
|
+
print(f"<Z0 Z1> = {res.value():+.6f} +/- {res.error:.4f}")
|
|
56
|
+
print(res.explain()) # QPU-Readiness Oracle verdict
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## The QPU-Readiness Oracle
|
|
60
|
+
|
|
61
|
+
Every result carries a `qpu_readiness` verdict — the one thing you want to
|
|
62
|
+
know before spending real QPU queue time:
|
|
63
|
+
|
|
64
|
+
| Verdict | Meaning | What to do |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `READY_FOR_QPU` | Within Q-TWIST's validated envelope; value trustworthy within the reported L1 bound | Run it on hardware to validate the physics |
|
|
67
|
+
| `NEEDS_FIXES` | Rejected only for a fixable issue (long-range gate, multi-controlled gate, wrong topology) | Apply the listed suggestions, re-run |
|
|
68
|
+
| `INTRACTABLE` | Beyond classical simulation / QPU-advantage territory | Run on hardware directly if you must; Q-TWIST can't pre-validate |
|
|
69
|
+
|
|
70
|
+
## Quickstart — premium cloud tier (metered)
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from qtwist.aer_compat import QtwistSimulator
|
|
74
|
+
from qtwist.pricing import Wallet
|
|
75
|
+
|
|
76
|
+
wallet = Wallet(token="PRO_TOKEN") # $50 base = 100 credits
|
|
77
|
+
sim = QtwistSimulator(instance="cloud:PRO_TOKEN", wallet=wallet, topology="1D_chain")
|
|
78
|
+
|
|
79
|
+
print(sim.estimate(qc)) # pre-flight cost, never bills
|
|
80
|
+
# [PRO / cloud] engine=ENGINE_D n=20 depth=39 -- est. 0.97 credits (~$0.49) ...
|
|
81
|
+
|
|
82
|
+
res = sim.run(qc, observable="Z0Z1").result() # charged only after confirm
|
|
83
|
+
print(res.explain())
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Tiers:
|
|
87
|
+
| Tier | Runs on | Billing | Capability Classifier | QPU-Readiness Oracle |
|
|
88
|
+
|---|---|---|---|---|
|
|
89
|
+
| FREE | laptop CPU | free | instant | yes (local) |
|
|
90
|
+
| PRO | cloud GPU worker | metered credit wallet (~1 credit ≈ 1 GPU-min, $50/100) | instant | yes (cloud) |
|
|
91
|
+
| ENTERPRISE | warm GPU worker pool / custom | $500 base, quote for scale | instant | yes (cloud) |
|
|
92
|
+
|
|
93
|
+
## Web console & 1024-qubit GPU tier
|
|
94
|
+
|
|
95
|
+
For paid 1024-qubit (Engine-D MPS) execution, Q-TWIST runs as a small web
|
|
96
|
+
console plus a **warm GPU worker pool**:
|
|
97
|
+
|
|
98
|
+
* The console (cheap, always-on, CPU) serves the UI, auth, billing, and the
|
|
99
|
+
interactive playground. **Free** callers run in-process on CPU; **paid**
|
|
100
|
+
(Pro/Enterprise) callers are delegated to the GPU worker pool.
|
|
101
|
+
* `SimDispatcher` (`qtwist/web/dispatch.py`) routes free → local CPU and paid →
|
|
102
|
+
an `HttpWorker` that calls the worker's internal `/api/worker/predict`.
|
|
103
|
+
* Each worker is the same app image with `QTWIST_GPU=1` (cupy MPS path), kept
|
|
104
|
+
warm by `scripts/gpu_pool.py` (Local for dev, JarvisLabs SDK for prod).
|
|
105
|
+
|
|
106
|
+
Launch locally:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
qtwist serve # or: uvicorn qtwist.web.app:app --port 8000
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Or deploy the full stack with Docker Compose (console + GPU worker + redis):
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
QTWIST_WORKER_TOKEN=$(openssl rand -hex 24) docker compose up --build
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
See `DEPLOY.md` for the Render / Docker / JarvisLabs GPU-pool walkthrough.
|
|
119
|
+
|
|
120
|
+
## What "1024 qubits" really means (honesty note)
|
|
121
|
+
|
|
122
|
+
Q-TWIST can run **1024-qubit** circuits, but only inside the **Engine-D (adaptive
|
|
123
|
+
MPS) envelope**: a **local** observable (≤ 30 qubits), a **1D chain**,
|
|
124
|
+
**nearest-neighbour** gates, and **area-law** entanglement. Inside that envelope
|
|
125
|
+
it is exact and fast (e.g. GHZ-1024 `<Z0Z1> = +1.0000`). It is **not universal**:
|
|
126
|
+
long-range gates, global observables > 30 qubits, QFT, dynamic circuits, and
|
|
127
|
+
multi-controlled gates are **rejected** with a reason and a fix — never faked.
|
|
128
|
+
|
|
129
|
+
## Topology support
|
|
130
|
+
|
|
131
|
+
`QTWISTBackend(topology=...)` and `predict(..., topology=...)` accept:
|
|
132
|
+
|
|
133
|
+
* `"1D_chain"` — Engine D (adaptive MPS) envelope, up to 1024 qubits
|
|
134
|
+
* `"2D_heavy_hex"` — shallow circuits via Engine C; deep heavy-hex is rejected with routing guidance
|
|
135
|
+
* `"all_to_all"` — fully connected, any engine that fits
|
|
136
|
+
* a Qiskit `CouplingMap` — edges are read from the map (1D chains are detected automatically)
|
|
137
|
+
|
|
138
|
+
## Verification
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
python -m pytest tests/ # dispatch + engine honesty tests
|
|
142
|
+
python research/demo_1024.py # 1024-qubit capability demo (GHZ exact)
|
|
143
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "qtwist"
|
|
7
|
+
version = "0.1.0b0"
|
|
8
|
+
description = "Q-TWIST: certified-methodology digital twin for noisy quantum processors - engines, Python SDK, and web console."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "Proprietary" }
|
|
12
|
+
authors = [{ name = "Q-TWIST" }]
|
|
13
|
+
keywords = ["quantum", "simulation", "certified", "digital-twin", "noise"]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"numpy>=2.0",
|
|
16
|
+
"scipy>=1.11",
|
|
17
|
+
"threadpoolctl>=3.0",
|
|
18
|
+
"qiskit>=1.0",
|
|
19
|
+
"quimb>=1.8",
|
|
20
|
+
"fastapi>=0.110",
|
|
21
|
+
"uvicorn[standard]>=0.27",
|
|
22
|
+
"pydantic>=2.0",
|
|
23
|
+
"python-multipart>=0.0.9",
|
|
24
|
+
"razorpay>=2.0",
|
|
25
|
+
"httpx>=0.27",
|
|
26
|
+
"websockets>=12.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
torch = ["torch>=2.0"]
|
|
31
|
+
# Heavy packages needed ONLY for the live-QPU / synthetic-twin noise path.
|
|
32
|
+
# The web console and default engine predictions do NOT require these, so they
|
|
33
|
+
# are opt-in to keep installs (and PaaS builds) light.
|
|
34
|
+
qpu = ["qiskit-aer>=0.14", "qiskit-ibm-runtime>=0.40"]
|
|
35
|
+
# In-browser Jupyter workspace (real notebook + terminal) embedded in the console.
|
|
36
|
+
jupyter = ["jupyter-server>=2.0", "notebook>=7.0"]
|
|
37
|
+
full = ["torch>=2.0", "razorpay>=2.0", "qiskit-aer>=0.14", "qiskit-ibm-runtime>=0.40", "jupyter-server>=2.0", "notebook>=7.0"]
|
|
38
|
+
test = ["pytest>=8.0", "httpx>=0.27"]
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
testpaths = ["tests"]
|
|
42
|
+
filterwarnings = [
|
|
43
|
+
"ignore::DeprecationWarning",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
qtwist = "qtwist.cli:main"
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://qtwist.example"
|
|
51
|
+
|
|
52
|
+
[tool.setuptools.packages.find]
|
|
53
|
+
include = ["qtwist*", "qtwist_core*"]
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.package-data]
|
|
56
|
+
qtwist_core = ["certification/models/*.pt", "certification/models/*.json", "py.typed"]
|
|
57
|
+
qtwist = ["web/static/*.html", "web/static/*.css", "web/static/*.js"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Q-TWIST (beta) — Python SDK Package
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0b0"
|
|
4
|
+
|
|
5
|
+
# Expose the engine packages (physics / router / core / certification) as
|
|
6
|
+
# top-level importable modules via the qtwist_core path shim.
|
|
7
|
+
import qtwist_core # noqa: F401
|
|
8
|
+
|
|
9
|
+
from qtwist.api import QTWISTBackend, PredictionResult, RejectionResult
|
|
10
|
+
from qtwist.aer_compat import QtwistSimulator, QtwistJob, QtwistResult
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"QtwistSimulator", "QtwistJob", "QtwistResult",
|
|
14
|
+
"QTWISTBackend", "PredictionResult", "RejectionResult",
|
|
15
|
+
]
|