Skip to main content

Network Quick Start

Execute distributed quantum workloads in 5 minutes.


Prerequisites


Step 1: Install the SDK

pip install qcos-sdk[network]

Step 2: Configure API Key

export QCOS_API_KEY="qcos_live_your_key_here"

Step 3: List Available Backends

from qcos.network import QuantumNetwork

network = QuantumNetwork()

# List all available backends
backends = network.list_backends()

for backend in backends:
print(f"{backend.id}: {backend.status} (queue: {backend.queue_depth})")

Expected Output:

ionq_simulator: online (queue: 0)
ionq_aria: online (queue: 5)
ibm_brisbane: online (queue: 12)
ibm_sherbrooke: maintenance (queue: 0)
rigetti_aspen: online (queue: 3)

Step 4: Execute on Single Backend

from qcos.network import QuantumNetwork

network = QuantumNetwork()

# Simple Bell state 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;
"""

result = network.execute(
qasm=qasm,
backends=["ionq_simulator"],
shots=1024
)

print(f"Backend: {result.backend}")
print(f"Counts: {result.counts}")

Step 5: Execute with Load Balancing

from qcos.network import QuantumNetwork

network = QuantumNetwork()

result = network.execute(
qasm=qasm,
backends=["ionq_simulator", "ibm_brisbane", "rigetti_aspen"],
strategy="fastest", # Use backend with shortest queue
shots=1024
)

print(f"Selected backend: {result.backend}")
print(f"Queue wait time: {result.queue_time_s}s")
print(f"Counts: {result.counts}")

Step 6: Execute on Multiple Backends

from qcos.network import QuantumNetwork

network = QuantumNetwork()

# Execute on all specified backends
result = network.execute(
qasm=qasm,
backends=["ionq_simulator", "ibm_brisbane"],
strategy="all",
shots=1024
)

# Access individual results
for backend_result in result.results:
print(f"\n{backend_result.backend}:")
print(f" Counts: {backend_result.counts}")
print(f" Fidelity estimate: {backend_result.fidelity_estimate:.2%}")

Step 7: Aggregate Results

from qcos.network import QuantumNetwork

network = QuantumNetwork()

result = network.execute(
qasm=qasm,
backends=["ionq_simulator", "ibm_brisbane", "rigetti_aspen"],
strategy="all",
shots=1024,
aggregate=True,
aggregation_method="weighted_average"
)

print(f"Aggregated counts: {result.aggregated_counts}")
print(f"Aggregation confidence: {result.aggregation_confidence:.2%}")
print(f"Backends used: {[r.backend for r in result.results]}")

Step 8: Configure Failover

from qcos.network import QuantumNetwork

network = QuantumNetwork()

result = network.execute(
qasm=qasm,
backends=["ionq_aria", "ionq_simulator"], # Hardware primary, simulator backup
strategy="ordered", # Try in order
failover=True,
failover_timeout_s=60,
shots=1024
)

print(f"Executed on: {result.backend}")
if result.failover_occurred:
print(f"Failover reason: {result.failover_reason}")

Step 9: Monitor Network Status

from qcos.network import QuantumNetwork

network = QuantumNetwork()

# Get network-wide status
status = network.status()

print(f"Network status: {status.overall_status}")
print(f"Total capacity: {status.total_capacity} qubits")
print(f"Active jobs: {status.active_jobs}")

for backend in status.backends:
print(f"\n{backend.id}:")
print(f" Status: {backend.status}")
print(f" Queue depth: {backend.queue_depth}")
print(f" Avg wait time: {backend.avg_wait_time_s}s")

Complete Example

#!/usr/bin/env python3
"""Network Complete Example"""

from qcos.network import QuantumNetwork

def main():
network = QuantumNetwork()

# Define circuit
qasm = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c[3];
h q[0];
cx q[0],q[1];
cx q[1],q[2];
measure q -> c;
"""

# Execute with full configuration
result = network.execute(
qasm=qasm,
backends=["ionq_simulator", "ibm_brisbane"],
strategy="all",
shots=2048,
aggregate=True,
aggregation_method="weighted_average",
failover=True,
evidence=True
)

# Print results
print("=" * 60)
print("QCOS Network Execution Report")
print("=" * 60)

print("\nIndividual Backend Results:")
for r in result.results:
print(f"\n {r.backend}:")
print(f" Status: {r.status}")
print(f" Counts: {r.counts}")
print(f" Fidelity: {r.fidelity_estimate:.2%}")

print(f"\nAggregated Results:")
print(f" Counts: {result.aggregated_counts}")
print(f" Confidence: {result.aggregation_confidence:.2%}")

print(f"\nExecution Metadata:")
print(f" Total time: {result.total_time_s:.2f}s")
print(f" Evidence bundle: {result.evidence_bundle_id}")
print("=" * 60)

if __name__ == "__main__":
main()

REST API Direct Usage

Execute on Multiple Backends

curl -X POST https://api.softquantus.com/api/v2/network/execute \
-H "Authorization: Bearer $QCOS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"qasm": "OPENQASM 2.0; ...",
"backends": ["ionq_simulator", "ibm_brisbane"],
"strategy": "all",
"shots": 1024,
"aggregate": true
}'

Get Network Status

curl https://api.softquantus.com/api/v2/network/status \
-H "Authorization: Bearer $QCOS_API_KEY"

Next Steps


© 2024-2026 SoftQuantus Innovative OÜ