quantumflow-sdk 0.2.1__py3-none-any.whl → 0.4.0__py3-none-any.whl
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.
- api/main.py +34 -3
- api/models.py +41 -0
- api/routes/algorithm_routes.py +1029 -0
- api/routes/chat_routes.py +565 -0
- api/routes/pipeline_routes.py +578 -0
- db/models.py +357 -0
- quantumflow/algorithms/machine_learning/__init__.py +14 -2
- quantumflow/algorithms/machine_learning/vqe.py +355 -3
- quantumflow/core/__init__.py +10 -1
- quantumflow/core/quantum_compressor.py +379 -1
- quantumflow/integrations/domain_agents.py +617 -0
- quantumflow/pipeline/__init__.py +29 -0
- quantumflow/pipeline/anomaly_detector.py +521 -0
- quantumflow/pipeline/base_pipeline.py +602 -0
- quantumflow/pipeline/checkpoint_manager.py +587 -0
- quantumflow/pipeline/finance/__init__.py +5 -0
- quantumflow/pipeline/finance/portfolio_optimization.py +595 -0
- quantumflow/pipeline/healthcare/__init__.py +5 -0
- quantumflow/pipeline/healthcare/protein_folding.py +994 -0
- quantumflow/pipeline/temporal_memory.py +577 -0
- {quantumflow_sdk-0.2.1.dist-info → quantumflow_sdk-0.4.0.dist-info}/METADATA +3 -3
- {quantumflow_sdk-0.2.1.dist-info → quantumflow_sdk-0.4.0.dist-info}/RECORD +25 -12
- {quantumflow_sdk-0.2.1.dist-info → quantumflow_sdk-0.4.0.dist-info}/WHEEL +0 -0
- {quantumflow_sdk-0.2.1.dist-info → quantumflow_sdk-0.4.0.dist-info}/entry_points.txt +0 -0
- {quantumflow_sdk-0.2.1.dist-info → quantumflow_sdk-0.4.0.dist-info}/top_level.txt +0 -0
api/main.py
CHANGED
|
@@ -35,6 +35,10 @@ from api.models import (
|
|
|
35
35
|
from api.auth import get_current_user, get_optional_user, get_db_session
|
|
36
36
|
from api.routes.auth_routes import router as auth_router
|
|
37
37
|
from api.routes.teleport_routes import router as teleport_router
|
|
38
|
+
from api.routes.algorithm_routes import router as algorithm_router
|
|
39
|
+
from api.routes.chat_routes import router as chat_router
|
|
40
|
+
# Pipeline routes disabled - internal research only (not public API)
|
|
41
|
+
# from api.routes.pipeline_routes import router as pipeline_router
|
|
38
42
|
|
|
39
43
|
# Import billing routes (optional - only if Stripe is configured)
|
|
40
44
|
try:
|
|
@@ -97,7 +101,7 @@ async def lifespan(app: FastAPI):
|
|
|
97
101
|
app = FastAPI(
|
|
98
102
|
title="QuantumFlow API",
|
|
99
103
|
description="Quantum-optimized AI agent workflow platform",
|
|
100
|
-
version="0.
|
|
104
|
+
version="0.3.0",
|
|
101
105
|
lifespan=lifespan,
|
|
102
106
|
)
|
|
103
107
|
|
|
@@ -116,6 +120,16 @@ app.include_router(auth_router)
|
|
|
116
120
|
# Include teleportation & secure messaging routes
|
|
117
121
|
app.include_router(teleport_router)
|
|
118
122
|
|
|
123
|
+
# Include algorithm routes (QNN, Grover, QAOA, VQE, QSVM, QKD, QRNG, QFT)
|
|
124
|
+
app.include_router(algorithm_router)
|
|
125
|
+
|
|
126
|
+
# Include QChat messaging routes (P2P encrypted messaging)
|
|
127
|
+
app.include_router(chat_router)
|
|
128
|
+
|
|
129
|
+
# Pipeline routes disabled - internal research only
|
|
130
|
+
# To enable: uncomment import and line below
|
|
131
|
+
# app.include_router(pipeline_router)
|
|
132
|
+
|
|
119
133
|
# Include billing routes if available
|
|
120
134
|
if BILLING_ENABLED and billing_router:
|
|
121
135
|
app.include_router(billing_router)
|
|
@@ -128,7 +142,7 @@ async def health_check():
|
|
|
128
142
|
"""Check API health status."""
|
|
129
143
|
return HealthResponse(
|
|
130
144
|
status="healthy",
|
|
131
|
-
version="0.
|
|
145
|
+
version="0.3.0",
|
|
132
146
|
quantum_ready=_compressor is not None,
|
|
133
147
|
)
|
|
134
148
|
|
|
@@ -156,14 +170,29 @@ async def compress_tokens(
|
|
|
156
170
|
Compress tokens using quantum amplitude encoding.
|
|
157
171
|
|
|
158
172
|
Achieves 53% token reduction via quantum superposition.
|
|
173
|
+
|
|
174
|
+
Options:
|
|
175
|
+
- `use_gray_code`: Enable Gray-code measurement protocol (arXiv:2601.00247)
|
|
176
|
+
which reduces measurement settings from O(N) to 2n+1.
|
|
159
177
|
"""
|
|
160
178
|
if not _compressor:
|
|
161
179
|
raise HTTPException(status_code=503, detail="Quantum compressor not initialized")
|
|
162
180
|
|
|
163
181
|
start_time = time.perf_counter()
|
|
182
|
+
measurement_settings = None
|
|
183
|
+
gray_code_enabled = request.use_gray_code
|
|
164
184
|
|
|
165
185
|
try:
|
|
166
|
-
if request.execute:
|
|
186
|
+
if request.use_gray_code and request.execute:
|
|
187
|
+
# Use Gray-code measurement protocol
|
|
188
|
+
result, gray_result = _compressor.compress_with_gray_code(
|
|
189
|
+
tokens=request.tokens,
|
|
190
|
+
compression_level=request.compression_level,
|
|
191
|
+
shots=request.shots,
|
|
192
|
+
)
|
|
193
|
+
fidelity = result.execution_result.fidelity if result.execution_result else None
|
|
194
|
+
measurement_settings = gray_result.n_measurement_settings
|
|
195
|
+
elif request.execute:
|
|
167
196
|
result = _compressor.compress_and_execute(
|
|
168
197
|
tokens=request.tokens,
|
|
169
198
|
compression_level=request.compression_level,
|
|
@@ -206,6 +235,8 @@ async def compress_tokens(
|
|
|
206
235
|
fidelity=fidelity,
|
|
207
236
|
execution_time_ms=execution_time,
|
|
208
237
|
backend_used=request.backend,
|
|
238
|
+
measurement_settings=measurement_settings,
|
|
239
|
+
gray_code_enabled=gray_code_enabled,
|
|
209
240
|
)
|
|
210
241
|
|
|
211
242
|
except Exception as e:
|
api/models.py
CHANGED
|
@@ -16,6 +16,10 @@ class CompressRequest(BaseModel):
|
|
|
16
16
|
backend: str = Field(default="auto", description="Backend: auto, simulator, ibm")
|
|
17
17
|
execute: bool = Field(default=False, description="Execute on quantum backend")
|
|
18
18
|
shots: int = Field(default=1024, ge=1, le=10000)
|
|
19
|
+
use_gray_code: bool = Field(
|
|
20
|
+
default=False,
|
|
21
|
+
description="Use Gray-code measurement protocol (arXiv:2601.00247) for efficient readout"
|
|
22
|
+
)
|
|
19
23
|
|
|
20
24
|
|
|
21
25
|
class CompressResponse(BaseModel):
|
|
@@ -29,6 +33,43 @@ class CompressResponse(BaseModel):
|
|
|
29
33
|
fidelity: Optional[float] = None
|
|
30
34
|
execution_time_ms: Optional[float] = None
|
|
31
35
|
backend_used: str
|
|
36
|
+
# Gray-code specific fields
|
|
37
|
+
measurement_settings: Optional[int] = Field(
|
|
38
|
+
default=None,
|
|
39
|
+
description="Number of measurement settings used (2n+1 for Gray-code)"
|
|
40
|
+
)
|
|
41
|
+
gray_code_enabled: bool = Field(default=False)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# === SES VQE Models (arXiv:2601.00247) ===
|
|
45
|
+
|
|
46
|
+
class SESVQERequest(BaseModel):
|
|
47
|
+
"""Request for Single Excitation Subspace VQE."""
|
|
48
|
+
|
|
49
|
+
n_sites: int = Field(..., ge=2, le=1024, description="Number of lattice sites")
|
|
50
|
+
on_site_energies: list[float] = Field(..., description="Energy at each site [h_11, h_22, ...]")
|
|
51
|
+
hopping_terms: list[tuple[int, int, float]] = Field(
|
|
52
|
+
...,
|
|
53
|
+
description="Hopping amplitudes [(i, j, t_ij), ...] between sites"
|
|
54
|
+
)
|
|
55
|
+
max_iterations: int = Field(default=100, ge=10, le=1000)
|
|
56
|
+
backend: str = Field(default="auto")
|
|
57
|
+
shots: int = Field(default=1024, ge=100, le=10000)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class SESVQEResponse(BaseModel):
|
|
61
|
+
"""Response from SES VQE computation."""
|
|
62
|
+
|
|
63
|
+
ground_energy: float
|
|
64
|
+
n_sites: int
|
|
65
|
+
n_qubits_used: int = Field(description="Logarithmic encoding: log₂(n_sites)")
|
|
66
|
+
qubit_reduction_percent: float
|
|
67
|
+
iterations: int
|
|
68
|
+
volumetric_cost: int
|
|
69
|
+
original_volumetric_cost: int
|
|
70
|
+
speedup: float
|
|
71
|
+
execution_time_ms: float
|
|
72
|
+
ansatz_type: str = "ses_binary"
|
|
32
73
|
|
|
33
74
|
|
|
34
75
|
# === Gradient Models ===
|