š§ Hardware Benchmarking
Neutral, reproducible benchmarking for quantum hardware vendors.
Why QCOS for Hardware Vendors?ā
| Challenge | QCOS Solution |
|---|---|
| Biased benchmarks | Neutral third-party infrastructure |
| Comparison difficulty | Standardized circuit library |
| Reproducibility | Deterministic simulation baseline |
| Public credibility | Verifiable results + audit trail |
Benchmark Suitesā
QCOS provides standardized benchmark suites for comparing quantum hardware:
| Suite | Circuits | Purpose |
|---|---|---|
| QV | Quantum Volume | Overall system quality |
| RB | Randomized Benchmarking | Gate fidelity |
| XEB | Cross-Entropy Benchmarking | System performance |
| CLOPS | Circuit Layer Operations/Second | Throughput |
| Application | VQE, QAOA, QML | Real-world performance |
Use Case: Quantum Volume Measurementā
from qcos import QCOSClient
from qcos.benchmarks import QuantumVolumeBenchmark
import numpy as np
client = QCOSClient()
def run_quantum_volume_circuit(depth: int, seed: int = None) -> str:
"""
Generate random SU(4) quantum volume circuit.
"""
np.random.seed(seed)
n_qubits = depth
qasm = f"""
OPENQASM 2.0;
include "qelib1.inc";
qreg q[{n_qubits}];
creg c[{n_qubits}];
"""
for layer in range(depth):
# Random permutation of qubits
perm = np.random.permutation(n_qubits)
# Apply random SU(4) to pairs
for i in range(0, n_qubits - 1, 2):
q1, q2 = perm[i], perm[i + 1]
# Random single-qubit gates
for q in [q1, q2]:
theta = np.random.uniform(0, 2 * np.pi)
phi = np.random.uniform(0, 2 * np.pi)
lam = np.random.uniform(0, 2 * np.pi)
qasm += f"u3({theta},{phi},{lam}) q[{q}];\n"
# CNOT
qasm += f"cx q[{q1}], q[{q2}];\n"
# More random single-qubit gates
for q in [q1, q2]:
theta = np.random.uniform(0, 2 * np.pi)
phi = np.random.uniform(0, 2 * np.pi)
lam = np.random.uniform(0, 2 * np.pi)
qasm += f"u3({theta},{phi},{lam}) q[{q}];\n"
qasm += "\nmeasure q -> c;\n"
return qasm
def measure_quantum_volume(max_depth: int = 10, trials: int = 100, shots: int = 1000):
"""
Measure quantum volume by finding largest successful depth.
"""
results = {}
for depth in range(2, max_depth + 1):
successes = 0
for trial in range(trials):
# Generate circuit
circuit = run_quantum_volume_circuit(depth, seed=trial)
# Execute on QCOS (simulated ideal)
ideal_result = client.execute(qasm=circuit, shots=shots)
# Calculate heavy output probability
all_states = ideal_result.counts
median_prob = np.median(list(all_states.values())) / shots
heavy_output_count = sum(
count for state, count in all_states.items()
if count / shots > median_prob
)
heavy_output_prob = heavy_output_count / shots
# Success if heavy output > 2/3
if heavy_output_prob > 2/3:
successes += 1
success_rate = successes / trials
results[depth] = {
'success_rate': success_rate,
'passed': success_rate >= 0.97 # 97% confidence
}
print(f"Depth {depth}: {success_rate:.1%} success rate - {'PASS' if results[depth]['passed'] else 'FAIL'}")
if not results[depth]['passed']:
break
# Quantum volume = 2^(largest passing depth)
passing_depths = [d for d, r in results.items() if r['passed']]
qv = 2 ** max(passing_depths) if passing_depths else 1
return {
'quantum_volume': qv,
'largest_depth': max(passing_depths) if passing_depths else 0,
'detailed_results': results
}
# Run benchmark
result = measure_quantum_volume(max_depth=8, trials=50)
print(f"\n{'='*50}")
print(f"QUANTUM VOLUME: {result['quantum_volume']}")
print(f"Largest successful depth: {result['largest_depth']}")
Use Case: Randomized Benchmarkingā
from qcos import QCOSClient
import numpy as np
from scipy.optimize import curve_fit
client = QCOSClient()
# Clifford gates in OpenQASM
CLIFFORD_GATES = [
"id", "x", "y", "z", "h", "s", "sdg",
"sx", "sxdg"
]
def generate_rb_circuit(n_cliffords: int, seed: int = None) -> str:
"""
Generate randomized benchmarking circuit.
"""
np.random.seed(seed)
qasm = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[1];
creg c[1];
"""
# Apply random Cliffords
gates_applied = []
for _ in range(n_cliffords):
gate = np.random.choice(CLIFFORD_GATES)
qasm += f"{gate} q[0];\n"
gates_applied.append(gate)
# Compute and apply inverse (simplified - real RB computes exact inverse)
# For demonstration, we just apply reverse gates
for gate in reversed(gates_applied):
if gate == "s":
qasm += "sdg q[0];\n"
elif gate == "sdg":
qasm += "s q[0];\n"
elif gate == "sx":
qasm += "sxdg q[0];\n"
elif gate == "sxdg":
qasm += "sx q[0];\n"
else:
qasm += f"{gate} q[0];\n"
qasm += "measure q -> c;\n"
return qasm
def run_randomized_benchmarking(max_cliffords: int = 100, samples_per_length: int = 20):
"""
Run RB and extract error per Clifford.
"""
lengths = [1, 2, 4, 8, 16, 32, 64, max_cliffords]
survival_probs = []
for length in lengths:
survivals = []
for sample in range(samples_per_length):
circuit = generate_rb_circuit(length, seed=sample)
result = client.execute(qasm=circuit, shots=1000)
# Survival = probability of measuring |0>
survival = result.counts.get('0', 0) / 1000
survivals.append(survival)
avg_survival = np.mean(survivals)
survival_probs.append(avg_survival)
print(f"Length {length:3d}: survival = {avg_survival:.4f}")
# Fit exponential decay
def rb_decay(m, A, p, B):
return A * p**m + B
try:
popt, _ = curve_fit(
rb_decay,
lengths,
survival_probs,
p0=[0.5, 0.99, 0.5],
bounds=([0, 0, 0], [1, 1, 1])
)
A, p, B = popt
# Error per Clifford
epc = (1 - p) * (1 - 1/2) # For single qubit
return {
'error_per_clifford': epc,
'depolarizing_parameter': p,
'fit_params': {'A': A, 'p': p, 'B': B},
'data': {'lengths': lengths, 'survivals': survival_probs}
}
except:
return {
'error_per_clifford': None,
'data': {'lengths': lengths, 'survivals': survival_probs}
}
# Run RB
rb_result = run_randomized_benchmarking()
print(f"\nError per Clifford: {rb_result['error_per_clifford']:.6f}")
Use Case: Cross-Entropy Benchmarking (XEB)ā
from qcos import QCOSClient
import numpy as np
from collections import Counter
client = QCOSClient()
def generate_xeb_circuit(n_qubits: int, depth: int, seed: int = None) -> str:
"""
Generate XEB circuit with random single-qubit gates and fixed two-qubit pattern.
"""
np.random.seed(seed)
qasm = f"""
OPENQASM 2.0;
include "qelib1.inc";
qreg q[{n_qubits}];
creg c[{n_qubits}];
"""
for layer in range(depth):
# Random single-qubit gates (sqrt(X), sqrt(Y), sqrt(W))
for qubit in range(n_qubits):
gate_type = np.random.choice(['sx', 'sy', 'sw'])
if gate_type == 'sx':
qasm += f"sx q[{qubit}];\n"
elif gate_type == 'sy':
# sqrt(Y) ā ry(Ļ/2)
qasm += f"ry({np.pi/2}) q[{qubit}];\n"
else:
# sqrt(W) = combination
qasm += f"h q[{qubit}];\n"
qasm += f"s q[{qubit}];\n"
# Two-qubit gates (alternating pattern)
start = layer % 2
for i in range(start, n_qubits - 1, 2):
# iSWAP or fSim gate (approximated with CZ)
qasm += f"cz q[{i}], q[{i+1}];\n"
qasm += "\nmeasure q -> c;\n"
return qasm
def compute_xeb_fidelity(n_qubits: int, depth: int, n_circuits: int = 20, shots: int = 10000):
"""
Compute XEB fidelity for given circuit parameters.
"""
fidelities = []
for circuit_idx in range(n_circuits):
circuit = generate_xeb_circuit(n_qubits, depth, seed=circuit_idx)
# Get experimental results
exp_result = client.execute(qasm=circuit, shots=shots)
exp_counts = exp_result.counts
# For ideal simulation, all probabilities are computed theoretically
# Here we use high-shot simulation as proxy for ideal probabilities
ideal_result = client.execute(qasm=circuit, shots=100000)
ideal_probs = {k: v/100000 for k, v in ideal_result.counts.items()}
# Compute linear XEB fidelity
# F_XEB = 2^n * <p_ideal> - 1
# where <p_ideal> is average ideal probability of observed bitstrings
total_prob_sum = 0
for bitstring, count in exp_counts.items():
ideal_prob = ideal_probs.get(bitstring, 0)
total_prob_sum += ideal_prob * count
avg_ideal_prob = total_prob_sum / shots
xeb_fidelity = (2**n_qubits) * avg_ideal_prob - 1
fidelities.append(xeb_fidelity)
return {
'mean_fidelity': np.mean(fidelities),
'std_fidelity': np.std(fidelities),
'n_qubits': n_qubits,
'depth': depth,
'all_fidelities': fidelities
}
# Run XEB for different depths
print("XEB Fidelity vs Circuit Depth")
print("="*50)
for depth in [4, 8, 12, 16, 20]:
result = compute_xeb_fidelity(n_qubits=4, depth=depth, n_circuits=10)
print(f"Depth {depth:2d}: F_XEB = {result['mean_fidelity']:.4f} ± {result['std_fidelity']:.4f}")
Hardware Comparison Dashboardā
Generate comparative reports:
from qcos import QCOSClient
from qcos.benchmarks import BenchmarkSuite
import json
client = QCOSClient()
# Define hardware configurations to compare
hardware_configs = [
{
'name': 'IQM Spark',
'qubits': 5,
'topology': 'star',
'gate_set': ['rx', 'ry', 'cz']
},
{
'name': 'Pasqal Fresnel',
'qubits': 100,
'topology': 'grid',
'gate_set': ['rx', 'ry', 'rz', 'cphase']
},
{
'name': 'AQT Pine',
'qubits': 24,
'topology': 'all-to-all',
'gate_set': ['rx', 'ry', 'rxx']
}
]
def run_comparison_suite():
"""
Run standardized benchmarks for hardware comparison.
"""
results = []
for config in hardware_configs:
print(f"\nBenchmarking: {config['name']}")
print("-" * 40)
hw_results = {
'hardware': config['name'],
'qubits': config['qubits'],
'benchmarks': {}
}
# Quantum Volume (limited by qubit count)
max_qv_depth = min(config['qubits'], 6)
# ... run QV benchmark
# CLOPS (Circuit Layer Operations Per Second)
clops = measure_clops(config['qubits'], shots=100)
hw_results['benchmarks']['clops'] = clops
# Application benchmark: VQE
if config['qubits'] >= 4:
vqe_time = benchmark_vqe(4)
hw_results['benchmarks']['vqe_4q_time'] = vqe_time
results.append(hw_results)
return results
def generate_comparison_report(results: list) -> str:
"""
Generate markdown comparison report.
"""
report = """# Quantum Hardware Comparison Report
Generated by QCOS Benchmark Suite
## Summary
| Hardware | Qubits | QV | CLOPS | VQE (4q) |
|----------|--------|-----|-------|----------|
"""
for r in results:
b = r['benchmarks']
report += f"| {r['hardware']} | {r['qubits']} | "
report += f"{b.get('qv', 'N/A')} | "
report += f"{b.get('clops', 'N/A'):.0f} | "
report += f"{b.get('vqe_4q_time', 'N/A'):.2f}s |\n"
report += """
## Methodology
All benchmarks run on QCOS infrastructure using cuStateVec simulator.
Results represent ideal hardware performance without noise.
## Reproducibility
All circuits and raw data available at: [benchmark-data.json](./benchmark-data.json)
"""
return report
# Run and generate report
results = run_comparison_suite()
report = generate_comparison_report(results)
with open('comparison_report.md', 'w') as f:
f.write(report)
with open('benchmark-data.json', 'w') as f:
json.dump(results, f, indent=2)
print("\nā Report generated: comparison_report.md")
Letter of Intent (LOI) Supportā
For hardware vendors seeking credible third-party benchmarks:
- Neutral Infrastructure: QCOS provides unbiased simulation platform
- Standardized Protocols: Industry-standard benchmark suites
- Verifiable Results: Audit trail and reproducibility packages
- Public Reports: Optionally publish results on our platform
Sample LOI Statementā
"Performance benchmarks were conducted using QCOS, a neutral third-party quantum simulation platform. All results are reproducible using the provided circuit definitions and configuration parameters."
Contactā
For hardware benchmarking partnerships:
We offer:
- Custom benchmark development
- White-label reports
- Integration support
- Joint press releases