Skip to main content

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

  1. SynapseX generates K response candidates
  2. Each candidate is scored on quality metrics
  3. QCOS runs QAOA to optimize selection
  4. 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

TierQCOS BackendLatency
quantum_cpuQCOS Simulator+50ms
quantum_gpuQCOS LUMI GPU+100ms
quantum_realIBM 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

BackendDescriptionAvailability
simulatorQCOS CPU simulatorAll plans
lumi_gpuLUMI GPU simulatorHybrid+
ibm_brisbaneIBM Quantum (127 qubits)Enterprise
ionq_ariaIonQ 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

EndpointDescription
/v1/softqcos/circuitsExecute quantum circuits
/v1/softqcos/qaoaRun QAOA optimization
/v1/softqcos/vqeRun VQE algorithm
/v1/softqcos/feature-mapQuantum feature extraction
/v1/softqcos/backendsList 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

TierBackendsCircuit DepthMonthly Quota
basicSimulator only100 gates1000 circuits
hybridSimulator + LUMI GPU500 gates10000 circuits
enterpriseAll including IBM/IonQUnlimitedUnlimited

Pricing

QCOS usage within SynapseX:

FeatureIncludedExtra Cost
Classic rerankingAll plansFree
Quantum CPU rerankingPro+Free
Quantum GPU rerankingHybrid+$0.001/request
Direct circuit executionHybrid+See QCOS Pricing
Real quantum hardwareEnterpriseContact 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

  1. Batch requests - Group multiple quantum calls
  2. Use simulators first - Validate circuits before real hardware
  3. Cache results - QAOA solutions for similar problems
  4. Right-size circuits - Smaller circuits = lower latency

Next Steps