QCOS Integration
SynapseX integrates with QCOS (Quantum Circuit Optimization Service) to provide quantum-enhanced AI capabilities. This guide covers how to leverage quantum computing features within SynapseX.
Overviewβ
SynapseX uses QCOS for:
- Quantum Reranking - QAOA-based response selection
- Quantum Embeddings - Enhanced vector representations
- Hybrid Workflows - Combined classical + quantum processing
- Direct QCOS Access - Execute quantum circuits from SynapseX
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SYNAPSEX + QCOS INTEGRATION β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β SYNAPSEX β β
β β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β β Chat β β Training β β Embeddingsβ β β
β β β API β β System β β API β β β
β β βββββββ¬βββββββ βββββββ¬βββββββ βββββββ¬βββββββ β β
β β β β β β β
β β βββββββββββββββββ΄ββββββββββββββββ β β
β β β β β
β βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β QCOS API β β
β β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β β QAOA β β Quantum β β Circuit β β β
β β β Reranking β β Embeddings β β Execution β β β
β β βββββββ¬βββββββ βββββββ¬βββββββ βββββββ¬βββββββ β β
β β β β β β β
β β βββββββββββββββββ΄ββββββββββββββββ β β
β β β β β
β βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββΌβββββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β IBM β β AWS β β LUMI β β
β β Quantum β β Braket β β HPC β β
β ββββββββββββ ββββββββββββ βββββ βββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Quantum Rerankingβ
How It Worksβ
- SynapseX generates K response candidates
- Each candidate is scored on quality metrics
- QCOS runs QAOA to optimize selection
- Best response is returned
Enable Quantum Rerankingβ
from openai import OpenAI
client = OpenAI(
api_key="sk-synapsex-xxx",
base_url="https://api.synapsex.ai/v1"
)
response = client.chat.completions.create(
model="synapsex-chat",
messages=[{"role": "user", "content": "Explain the SchrΓΆdinger equation"}],
extra_body={
"use_rerank": "quantum_cpu", # Uses QCOS
"rerank_k": 4
}
)
# Access quantum metadata
meta = response.meta
print(f"Quality score: {meta.quality_score}")
print(f"QCOS circuit depth: {meta.qcos_depth}")
print(f"QAOA layers: {meta.qaoa_p}")
Reranking Tiersβ
| Tier | QCOS Backend | Latency |
|---|---|---|
quantum_cpu | QCOS Simulator | +50ms |
quantum_gpu | QCOS LUMI GPU | +100ms |
quantum_real | IBM Quantum (Enterprise) | +500ms |
Direct QCOS Accessβ
Execute quantum circuits directly from SynapseX:
Run Circuitβ
import requests
response = requests.post(
"https://api.synapsex.ai/v1/softqcos/circuits",
headers={"Authorization": "Bearer sk-synapsex-xxx"},
json={
"circuit": {
"qasm": """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0],q[1];
measure q -> c;
""",
"format": "qasm2"
},
"backend": "simulator",
"shots": 1000
}
)
result = response.json()
print(f"Counts: {result['counts']}")
# {'00': 512, '11': 488}
Available Backendsβ
| Backend | Description | Availability |
|---|---|---|
simulator | QCOS CPU simulator | All plans |
lumi_gpu | LUMI GPU simulator | Hybrid+ |
ibm_brisbane | IBM Quantum (127 qubits) | Enterprise |
ionq_aria | IonQ Aria (25 qubits) | Enterprise |
Quantum-Enhanced Embeddingsβ
Generate embeddings with quantum features:
response = requests.post(
"https://api.synapsex.ai/v1/embeddings",
headers={"Authorization": "Bearer sk-synapsex-xxx"},
json={
"input": ["Quantum machine learning applications"],
"model": "synapsex-embed",
"quantum_enhance": True # Enable quantum features
}
)
embedding = response.json()['data'][0]['embedding']
print(f"Dimension: {len(embedding)}")
# Quantum features increase dimensionality and expressiveness
Quantum Embedding Benefitsβ
- Higher Expressiveness - Captures non-linear relationships
- Better Similarity - Improved semantic matching
- Noise Robustness - More stable representations
Hybrid Workflowsβ
Combine LLM generation with quantum optimization:
Example: Quantum-Optimized Answer Selectionβ
import requests
# Step 1: Generate multiple answers with SynapseX
answers = []
for temp in [0.5, 0.7, 0.9, 1.1]:
response = requests.post(
"https://api.synapsex.ai/v1/chat/completions",
headers={"Authorization": "Bearer sk-synapsex-xxx"},
json={
"model": "synapsex-chat",
"messages": [{"role": "user", "content": "What is photosynthesis?"}],
"temperature": temp,
"use_rerank": "off" # Disable automatic reranking
}
)
answers.append(response.json()['choices'][0]['message']['content'])
# Step 2: Score answers (custom scoring logic)
scores = score_answers(answers) # Your scoring function
# Step 3: Use QCOS QAOA for optimal selection
qubo = formulate_qubo(scores)
response = requests.post(
"https://api.synapsex.ai/v1/softqcos/qaoa",
headers={"Authorization": "Bearer sk-synapsex-xxx"},
json={
"qubo": qubo,
"p_layers": 3,
"optimizer": "COBYLA",
"shots": 1000
}
)
best_index = response.json()['best_solution']
best_answer = answers[best_index]
print(f"Best answer: {best_answer}")
Example: Quantum Feature Extractionβ
# Use quantum circuits to extract features for classification
response = requests.post(
"https://api.synapsex.ai/v1/softqcos/feature-map",
headers={"Authorization": "Bearer sk-synapsex-xxx"},
json={
"data": [[0.5, 0.3], [0.2, 0.8], [0.9, 0.1]],
"feature_map": "ZZFeatureMap",
"reps": 2
}
)
quantum_features = response.json()['features']
# Use quantum features in downstream ML tasks
QCOS API Referenceβ
Endpointsβ
| Endpoint | Description |
|---|---|
/v1/softqcos/circuits | Execute quantum circuits |
/v1/softqcos/qaoa | Run QAOA optimization |
/v1/softqcos/vqe | Run VQE algorithm |
/v1/softqcos/feature-map | Quantum feature extraction |
/v1/softqcos/backends | List available backends |
Run QAOAβ
POST /v1/softqcos/qaoa
{
"qubo": {
"(0,0)": -1.0,
"(1,1)": -2.0,
"(0,1)": 0.5
},
"p_layers": 3,
"optimizer": "COBYLA",
"shots": 1000,
"backend": "simulator"
}
Response:
{
"best_solution": [1, 0, 1, 0],
"best_energy": -3.5,
"probabilities": {
"1010": 0.45,
"0101": 0.32,
"1100": 0.15
},
"optimization_result": {
"iterations": 150,
"final_cost": -3.48
}
}
Run VQEβ
POST /v1/softqcos/vqe
{
"hamiltonian": "0.5*Z0 + 0.3*Z1 + 0.2*Z0*Z1",
"ansatz": "RealAmplitudes",
"optimizer": "COBYLA",
"backend": "simulator"
}
Configurationβ
Enable QCOS in Tenant Settingsβ
response = requests.patch(
"https://api.synapsex.ai/v1/tenants/my_tenant/settings",
headers={"Authorization": "Bearer sk-admin-xxx"},
json={
"qcos_enabled": True,
"qcos_tier": "hybrid", # Access level
"default_qcos_backend": "simulator"
}
)
QCOS Tiersβ
| Tier | Backends | Circuit Depth | Monthly Quota |
|---|---|---|---|
basic | Simulator only | 100 gates | 1000 circuits |
hybrid | Simulator + LUMI GPU | 500 gates | 10000 circuits |
enterprise | All including IBM/IonQ | Unlimited | Unlimited |
Pricingβ
QCOS usage within SynapseX:
| Feature | Included | Extra Cost |
|---|---|---|
| Classic reranking | All plans | Free |
| Quantum CPU reranking | Pro+ | Free |
| Quantum GPU reranking | Hybrid+ | $0.001/request |
| Direct circuit execution | Hybrid+ | See QCOS Pricing |
| Real quantum hardware | Enterprise | Contact sales |
Best Practicesβ
When to Use Quantumβ
β Good use cases:
- Response quality is critical (medical, legal)
- Optimization problems (routing, scheduling)
- Feature extraction for ML
- Research and experimentation
β Not recommended:
- Low-latency requirements (under 50ms)
- Simple queries with obvious answers
- High-volume, cost-sensitive applications
Performance Tipsβ
- Batch requests - Group multiple quantum calls
- Use simulators first - Validate circuits before real hardware
- Cache results - QAOA solutions for similar problems
- Right-size circuits - Smaller circuits = lower latency
Next Stepsβ
- βοΈ QCOS Documentation - Full QCOS reference
- π Quantum Reranking - Detailed reranking guide
- π° QCOS Pricing - Quantum hardware costs