quantumflow-sdk 0.3.0__tar.gz → 0.4.0__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.
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/PKG-INFO +3 -3
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/pyproject.toml +6 -2
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/api/main.py +28 -1
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/api/models.py +41 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/api/routes/algorithm_routes.py +134 -0
- quantumflow_sdk-0.4.0/src/api/routes/chat_routes.py +565 -0
- quantumflow_sdk-0.4.0/src/api/routes/pipeline_routes.py +578 -0
- quantumflow_sdk-0.4.0/src/db/models.py +554 -0
- quantumflow_sdk-0.4.0/src/quantumflow/algorithms/machine_learning/__init__.py +19 -0
- quantumflow_sdk-0.4.0/src/quantumflow/algorithms/machine_learning/vqe.py +581 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/core/__init__.py +10 -1
- quantumflow_sdk-0.4.0/src/quantumflow/core/quantum_compressor.py +687 -0
- quantumflow_sdk-0.4.0/src/quantumflow/integrations/domain_agents.py +617 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/__init__.py +29 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/anomaly_detector.py +521 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/base_pipeline.py +602 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/checkpoint_manager.py +587 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/finance/__init__.py +5 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/finance/portfolio_optimization.py +595 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/healthcare/__init__.py +5 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/healthcare/protein_folding.py +994 -0
- quantumflow_sdk-0.4.0/src/quantumflow/pipeline/temporal_memory.py +577 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow_sdk.egg-info/PKG-INFO +3 -3
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow_sdk.egg-info/SOURCES.txt +12 -0
- quantumflow_sdk-0.3.0/src/db/models.py +0 -197
- quantumflow_sdk-0.3.0/src/quantumflow/algorithms/machine_learning/__init__.py +0 -7
- quantumflow_sdk-0.3.0/src/quantumflow/algorithms/machine_learning/vqe.py +0 -229
- quantumflow_sdk-0.3.0/src/quantumflow/core/quantum_compressor.py +0 -309
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/README.md +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/setup.cfg +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/api/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/api/auth.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/api/routes/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/api/routes/auth_routes.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/api/routes/teleport_routes.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/db/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/db/crud.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/db/database.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/compression/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/compression/amplitude_amplification.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/compression/qft_compression.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/compression/token_compression.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/cryptography/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/cryptography/qkd.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/cryptography/qrng.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/machine_learning/qnn.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/machine_learning/qsvm.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/optimization/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/optimization/grover.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/optimization/qaoa.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/optimization/quantum_annealing.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/utility/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/utility/circuit_optimizer.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/algorithms/utility/error_correction.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/api/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/api/routes/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/api/routes/billing_routes.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/api/routes/workflow_routes.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/backends/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/backends/base_backend.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/backends/braket_backend.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/backends/ibm_backend.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/backends/simulator_backend.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/billing/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/billing/models.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/billing/stripe_service.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/core/entanglement.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/core/memory.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/core/quantum_backprop.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/core/teleportation.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/core/workflow.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/integrations/__init__.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/integrations/autogen_tools.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/integrations/crewai_agents.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/integrations/crewai_tools.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/integrations/langchain_memory.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/integrations/langchain_tools.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/integrations/mcp_server.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow/integrations/openai_functions.py +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow_sdk.egg-info/dependency_links.txt +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow_sdk.egg-info/entry_points.txt +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow_sdk.egg-info/requires.txt +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/src/quantumflow_sdk.egg-info/top_level.txt +0 -0
- {quantumflow_sdk-0.3.0 → quantumflow_sdk-0.4.0}/tests/test_quantum_compressor.py +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantumflow-sdk
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Quantum-optimized AI agent workflow platform with 53% token compression
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Quantum-optimized AI agent workflow platform with 53% token compression, Gray-code measurement, and SES VQE
|
|
5
5
|
Author-email: BlockQuantAI <hello@blockquant.ai>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://qflowai.dev
|
|
8
8
|
Project-URL: Documentation, https://qflowai.dev/docs
|
|
9
9
|
Project-URL: Repository, https://github.com/blockquantai/quantumflow
|
|
10
10
|
Project-URL: Issues, https://github.com/blockquantai/quantumflow/issues
|
|
11
|
-
Keywords: quantum,quantum-computing,ai,machine-learning,token-compression,qkd,teleportation,langchain,crewai
|
|
11
|
+
Keywords: quantum,quantum-computing,ai,machine-learning,token-compression,qkd,teleportation,langchain,crewai,vqe,gray-code,ses-ansatz,tight-binding
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
14
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quantumflow-sdk"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Quantum-optimized AI agent workflow platform with 53% token compression"
|
|
7
|
+
version = "0.4.0"
|
|
8
|
+
description = "Quantum-optimized AI agent workflow platform with 53% token compression, Gray-code measurement, and SES VQE"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
authors = [
|
|
@@ -21,6 +21,10 @@ keywords = [
|
|
|
21
21
|
"teleportation",
|
|
22
22
|
"langchain",
|
|
23
23
|
"crewai",
|
|
24
|
+
"vqe",
|
|
25
|
+
"gray-code",
|
|
26
|
+
"ses-ansatz",
|
|
27
|
+
"tight-binding",
|
|
24
28
|
]
|
|
25
29
|
classifiers = [
|
|
26
30
|
"Development Status :: 4 - Beta",
|
|
@@ -36,6 +36,9 @@ 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
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
|
|
39
42
|
|
|
40
43
|
# Import billing routes (optional - only if Stripe is configured)
|
|
41
44
|
try:
|
|
@@ -120,6 +123,13 @@ app.include_router(teleport_router)
|
|
|
120
123
|
# Include algorithm routes (QNN, Grover, QAOA, VQE, QSVM, QKD, QRNG, QFT)
|
|
121
124
|
app.include_router(algorithm_router)
|
|
122
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
|
+
|
|
123
133
|
# Include billing routes if available
|
|
124
134
|
if BILLING_ENABLED and billing_router:
|
|
125
135
|
app.include_router(billing_router)
|
|
@@ -160,14 +170,29 @@ async def compress_tokens(
|
|
|
160
170
|
Compress tokens using quantum amplitude encoding.
|
|
161
171
|
|
|
162
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.
|
|
163
177
|
"""
|
|
164
178
|
if not _compressor:
|
|
165
179
|
raise HTTPException(status_code=503, detail="Quantum compressor not initialized")
|
|
166
180
|
|
|
167
181
|
start_time = time.perf_counter()
|
|
182
|
+
measurement_settings = None
|
|
183
|
+
gray_code_enabled = request.use_gray_code
|
|
168
184
|
|
|
169
185
|
try:
|
|
170
|
-
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:
|
|
171
196
|
result = _compressor.compress_and_execute(
|
|
172
197
|
tokens=request.tokens,
|
|
173
198
|
compression_level=request.compression_level,
|
|
@@ -210,6 +235,8 @@ async def compress_tokens(
|
|
|
210
235
|
fidelity=fidelity,
|
|
211
236
|
execution_time_ms=execution_time,
|
|
212
237
|
backend_used=request.backend,
|
|
238
|
+
measurement_settings=measurement_settings,
|
|
239
|
+
gray_code_enabled=gray_code_enabled,
|
|
213
240
|
)
|
|
214
241
|
|
|
215
242
|
except Exception as e:
|
|
@@ -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 ===
|
|
@@ -506,6 +506,128 @@ async def vqe_compute(
|
|
|
506
506
|
raise HTTPException(status_code=400, detail=str(e))
|
|
507
507
|
|
|
508
508
|
|
|
509
|
+
# ============================================================
|
|
510
|
+
# SES VQE - Single Excitation Subspace (arXiv:2601.00247)
|
|
511
|
+
# ============================================================
|
|
512
|
+
|
|
513
|
+
class SESVQERequest(BaseModel):
|
|
514
|
+
"""Request for Single Excitation Subspace VQE.
|
|
515
|
+
|
|
516
|
+
Uses logarithmic qubit encoding from arXiv:2601.00247:
|
|
517
|
+
- N lattice sites encoded in log₂(N) qubits
|
|
518
|
+
- Exponential reduction in quantum resources
|
|
519
|
+
- Ideal for tight-binding Hamiltonians
|
|
520
|
+
"""
|
|
521
|
+
n_sites: int = Field(..., ge=2, le=1024, description="Number of lattice sites")
|
|
522
|
+
on_site_energies: List[float] = Field(
|
|
523
|
+
...,
|
|
524
|
+
description="Diagonal energies [h_11, h_22, ...] for each site"
|
|
525
|
+
)
|
|
526
|
+
hopping_terms: List[List] = Field(
|
|
527
|
+
...,
|
|
528
|
+
description="Hopping terms [[i, j, t_ij], ...] between sites"
|
|
529
|
+
)
|
|
530
|
+
max_iterations: int = Field(default=100, ge=10, le=1000)
|
|
531
|
+
backend: str = Field(default="simulator")
|
|
532
|
+
shots: int = Field(default=1024, ge=100, le=10000)
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
class SESVQEResponse(BaseModel):
|
|
536
|
+
"""Response from SES VQE computation."""
|
|
537
|
+
ground_energy: float
|
|
538
|
+
n_sites: int
|
|
539
|
+
n_qubits_used: int = Field(description="Logarithmic encoding: ⌈log₂(n_sites)⌉")
|
|
540
|
+
qubit_reduction_percent: float
|
|
541
|
+
iterations: int
|
|
542
|
+
energy_history: List[float]
|
|
543
|
+
volumetric_cost: int
|
|
544
|
+
original_volumetric_cost: int
|
|
545
|
+
speedup: float
|
|
546
|
+
execution_time_ms: float
|
|
547
|
+
ansatz_type: str = "ses_binary"
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
@router.post("/ses/solve", response_model=SESVQEResponse)
|
|
551
|
+
async def ses_vqe_solve(
|
|
552
|
+
request: SESVQERequest,
|
|
553
|
+
user: User = Depends(get_current_user), # Requires API key
|
|
554
|
+
):
|
|
555
|
+
"""
|
|
556
|
+
Run VQE with Single Excitation Subspace (SES) ansatz.
|
|
557
|
+
|
|
558
|
+
Based on arXiv:2601.00247 - achieves exponential reduction in
|
|
559
|
+
quantum resources for tight-binding Hamiltonians:
|
|
560
|
+
|
|
561
|
+
- **Qubit reduction**: N sites → log₂(N) qubits
|
|
562
|
+
- **Volumetric speedup**: O(N²) → O((log N)³)
|
|
563
|
+
|
|
564
|
+
Use cases:
|
|
565
|
+
- Tight-binding band structure calculations
|
|
566
|
+
- Solid-state physics simulations
|
|
567
|
+
- Material property prediction
|
|
568
|
+
|
|
569
|
+
Example (8-site chain):
|
|
570
|
+
```json
|
|
571
|
+
{
|
|
572
|
+
"n_sites": 8,
|
|
573
|
+
"on_site_energies": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
|
|
574
|
+
"hopping_terms": [[0,1,-1.0], [1,2,-1.0], [2,3,-1.0], ...]
|
|
575
|
+
}
|
|
576
|
+
```
|
|
577
|
+
Uses only 3 qubits instead of 8!
|
|
578
|
+
"""
|
|
579
|
+
import math
|
|
580
|
+
from quantumflow.algorithms.machine_learning.vqe import run_ses_vqe, calculate_volumetric_cost
|
|
581
|
+
|
|
582
|
+
start_time = time.perf_counter()
|
|
583
|
+
|
|
584
|
+
try:
|
|
585
|
+
# Validate input
|
|
586
|
+
if len(request.on_site_energies) != request.n_sites:
|
|
587
|
+
raise ValueError(
|
|
588
|
+
f"on_site_energies length ({len(request.on_site_energies)}) "
|
|
589
|
+
f"must match n_sites ({request.n_sites})"
|
|
590
|
+
)
|
|
591
|
+
|
|
592
|
+
# Convert hopping terms to tuples
|
|
593
|
+
hopping_tuples = [
|
|
594
|
+
(int(h[0]), int(h[1]), complex(h[2]) if len(h) > 2 else complex(-1.0))
|
|
595
|
+
for h in request.hopping_terms
|
|
596
|
+
]
|
|
597
|
+
|
|
598
|
+
# Run SES VQE
|
|
599
|
+
result = run_ses_vqe(
|
|
600
|
+
n_sites=request.n_sites,
|
|
601
|
+
on_site_energies=request.on_site_energies,
|
|
602
|
+
hopping_terms=hopping_tuples,
|
|
603
|
+
max_iterations=request.max_iterations,
|
|
604
|
+
backend=request.backend,
|
|
605
|
+
)
|
|
606
|
+
|
|
607
|
+
execution_time = (time.perf_counter() - start_time) * 1000
|
|
608
|
+
|
|
609
|
+
# Calculate efficiency metrics
|
|
610
|
+
n_qubits = math.ceil(math.log2(request.n_sites))
|
|
611
|
+
costs = calculate_volumetric_cost(request.n_sites, "ses_binary")
|
|
612
|
+
|
|
613
|
+
return SESVQEResponse(
|
|
614
|
+
ground_energy=result.ground_energy,
|
|
615
|
+
n_sites=request.n_sites,
|
|
616
|
+
n_qubits_used=n_qubits,
|
|
617
|
+
qubit_reduction_percent=(1 - n_qubits / request.n_sites) * 100,
|
|
618
|
+
iterations=result.n_iterations,
|
|
619
|
+
energy_history=result.energy_history,
|
|
620
|
+
volumetric_cost=costs["volumetric_cost"],
|
|
621
|
+
original_volumetric_cost=costs["original_volumetric_cost"],
|
|
622
|
+
speedup=costs["speedup"],
|
|
623
|
+
execution_time_ms=execution_time,
|
|
624
|
+
ansatz_type="ses_binary",
|
|
625
|
+
)
|
|
626
|
+
|
|
627
|
+
except Exception as e:
|
|
628
|
+
raise HTTPException(status_code=400, detail=str(e))
|
|
629
|
+
|
|
630
|
+
|
|
509
631
|
# ============================================================
|
|
510
632
|
# Algorithm Info Endpoint
|
|
511
633
|
# ============================================================
|
|
@@ -863,6 +985,18 @@ async def list_algorithms():
|
|
|
863
985
|
"endpoints": ["/v1/algorithms/vqe/compute"],
|
|
864
986
|
"use_cases": ["Molecular simulation", "Ground state energy", "Quantum chemistry"],
|
|
865
987
|
},
|
|
988
|
+
{
|
|
989
|
+
"id": "ses",
|
|
990
|
+
"name": "SES VQE",
|
|
991
|
+
"description": "Single Excitation Subspace VQE with logarithmic qubit encoding (arXiv:2601.00247)",
|
|
992
|
+
"endpoints": ["/v1/algorithms/ses/solve"],
|
|
993
|
+
"use_cases": ["Tight-binding Hamiltonians", "Band structure", "Solid-state physics"],
|
|
994
|
+
"features": {
|
|
995
|
+
"qubit_reduction": "N sites → log₂(N) qubits",
|
|
996
|
+
"speedup": "O(N²) → O((log N)³)",
|
|
997
|
+
"ansatz": "Binary-encoded SES with Gray-code measurement"
|
|
998
|
+
}
|
|
999
|
+
},
|
|
866
1000
|
{
|
|
867
1001
|
"id": "qsvm",
|
|
868
1002
|
"name": "Quantum SVM",
|