QAOA性能比较技术报告 (Qibo vs Qiskit)¶
测试环境配置¶
- 硬件: Windows 10 Pro, x64
- 量子比特数: 4-15
- QAOA层数: 1-5
- 优化器: COBYLA
- 采样数: 8192 shots
数据加载与预处理¶
In [2]:
Copied!
!jupyter kernelspec list
!jupyter kernelspec list
Available kernels: python3 E:\quantum computing\venv\share\jupyter\kernels\python3 qenv C:\Users\Administrator\AppData\Roaming\jupyter\kernels\qenv sjenv C:\Users\Administrator\AppData\Roaming\jupyter\kernels\sjenv venv C:\Users\Administrator\AppData\Roaming\jupyter\kernels\venv
In [1]:
Copied!
import pandas as pd
import matplotlib.pyplot as plt
# 加载数据
qibo_df = pd.read_csv('qaoa_qibo_benchmark_results.csv')
qiskit_df = pd.read_csv('qaoa_benchmark_results.csv')
# 添加模拟器标签
qibo_df['simulator'] = 'Qibo'
qiskit_df['simulator'] = 'Qiskit'
# 合并数据
combined_df = pd.concat([qibo_df, qiskit_df])
import pandas as pd
import matplotlib.pyplot as plt
# 加载数据
qibo_df = pd.read_csv('qaoa_qibo_benchmark_results.csv')
qiskit_df = pd.read_csv('qaoa_benchmark_results.csv')
# 添加模拟器标签
qibo_df['simulator'] = 'Qibo'
qiskit_df['simulator'] = 'Qiskit'
# 合并数据
combined_df = pd.concat([qibo_df, qiskit_df])
关键性能指标对比¶
1. 运行时间对比 (秒)¶
In [2]:
Copied!
plt.figure(figsize=(10, 6))
for simulator in ['Qibo', 'Qiskit']:
df = combined_df[combined_df['simulator'] == simulator]
plt.plot(df['num_qubits'], df['runtime_sec'], 'o-', label=simulator)
plt.title('Runtime Comparison (Qibo vs Qiskit)')
plt.xlabel('Number of Qubits')
plt.ylabel('Runtime (seconds)')
plt.legend()
plt.grid()
plt.show()
plt.figure(figsize=(10, 6))
for simulator in ['Qibo', 'Qiskit']:
df = combined_df[combined_df['simulator'] == simulator]
plt.plot(df['num_qubits'], df['runtime_sec'], 'o-', label=simulator)
plt.title('Runtime Comparison (Qibo vs Qiskit)')
plt.xlabel('Number of Qubits')
plt.ylabel('Runtime (seconds)')
plt.legend()
plt.grid()
plt.show()
2. 内存使用对比 (MB)¶
In [3]:
Copied!
plt.figure(figsize=(10, 6))
for simulator in ['Qibo', 'Qiskit']:
df = combined_df[combined_df['simulator'] == simulator]
plt.plot(df['num_qubits'], df['memory_usage_mb'], 's-', label=simulator)
plt.title('Memory Usage Comparison (Qibo vs Qiskit)')
plt.xlabel('Number of Qubits')
plt.ylabel('Memory Usage (MB)')
plt.legend()
plt.grid()
plt.show()
plt.figure(figsize=(10, 6))
for simulator in ['Qibo', 'Qiskit']:
df = combined_df[combined_df['simulator'] == simulator]
plt.plot(df['num_qubits'], df['memory_usage_mb'], 's-', label=simulator)
plt.title('Memory Usage Comparison (Qibo vs Qiskit)')
plt.xlabel('Number of Qubits')
plt.ylabel('Memory Usage (MB)')
plt.legend()
plt.grid()
plt.show()
3. 最优解概率对比¶
In [4]:
Copied!
plt.figure(figsize=(10, 6))
for simulator in ['Qibo', 'Qiskit']:
df = combined_df[combined_df['simulator'] == simulator]
plt.plot(df['num_qubits'], df['best_probability'], 'd-', label=simulator)
plt.title('Optimal Solution Probability Comparison')
plt.xlabel('Number of Qubits')
plt.ylabel('Probability')
plt.legend()
plt.grid()
plt.show()
plt.figure(figsize=(10, 6))
for simulator in ['Qibo', 'Qiskit']:
df = combined_df[combined_df['simulator'] == simulator]
plt.plot(df['num_qubits'], df['best_probability'], 'd-', label=simulator)
plt.title('Optimal Solution Probability Comparison')
plt.xlabel('Number of Qubits')
plt.ylabel('Probability')
plt.legend()
plt.grid()
plt.show()
性能差异分析¶
- Qibo优势:
- 专为量子计算优化的后端
- 更高效的电路编译和优化
- 原生支持参数化量子门
- Qiskit特点:
- 更成熟稳定的模拟器
- 更好的大规模电路处理能力
- 内存管理更高效
结论与建议¶
- 对于≤12 qubits的QAOA电路,推荐使用Qibo以获得更快运行速度
- 对于大规模电路(≥15 qubits),Qiskit表现更稳定
- 两种模拟器都能正确解决MAX-CUT问题,选择取决于具体规模和要求
完整数据表格¶
In [9]:
Copied!
# 原代码替换为:
display(
qibo_df
.groupby(['num_qubits', 'qaoa_layers'])
.agg({
'runtime_sec': 'mean',
'memory_usage_mb': 'mean',
'best_probability': 'mean'
})
)
# 原代码替换为:
display(
qibo_df
.groupby(['num_qubits', 'qaoa_layers'])
.agg({
'runtime_sec': 'mean',
'memory_usage_mb': 'mean',
'best_probability': 'mean'
})
)
| runtime_sec | memory_usage_mb | best_probability | ||
|---|---|---|---|---|
| num_qubits | qaoa_layers | |||
| 4 | 1 | 0.53 | 21.25 | 0.264526 |
| 2 | 0.11 | 0.23 | 0.270874 | |
| 3 | 0.23 | 0.31 | 0.487305 | |
| 4 | 0.25 | 0.22 | 0.470703 | |
| 5 | 0.33 | 0.42 | 0.482300 | |
| 5 | 1 | 0.08 | 0.04 | 0.092285 |
| 2 | 0.15 | 0.10 | 0.093384 | |
| 3 | 0.22 | 0.04 | 0.095459 | |
| 4 | 0.32 | 0.12 | 0.100220 | |
| 5 | 0.44 | 0.34 | 0.104736 | |
| 6 | 1 | 0.08 | 0.03 | 0.139648 |
| 2 | 0.15 | 0.00 | 0.167847 | |
| 3 | 0.26 | 0.09 | 0.274292 | |
| 4 | 0.39 | 0.07 | 0.351196 | |
| 5 | 0.43 | 0.43 | 0.473389 | |
| 7 | 1 | 0.10 | 0.13 | 0.045898 |
| 2 | 0.17 | 0.00 | 0.065308 | |
| 3 | 0.28 | 0.00 | 0.070312 | |
| 4 | 0.40 | 0.43 | 0.073853 | |
| 5 | 0.59 | 0.87 | 0.066040 | |
| 8 | 1 | 0.13 | 0.00 | 0.078003 |
| 2 | 0.18 | 0.06 | 0.103882 | |
| 3 | 0.41 | 0.19 | 0.211426 | |
| 4 | 0.60 | 0.41 | 0.439575 | |
| 5 | 0.75 | 1.04 | 0.240112 | |
| 9 | 1 | 0.15 | 0.02 | 0.027100 |
| 2 | 0.27 | 0.03 | 0.045044 | |
| 3 | 0.47 | 0.00 | 0.045044 | |
| 4 | 0.70 | 0.48 | 0.033813 | |
| 5 | 1.14 | 1.16 | 0.057251 | |
| 10 | 1 | 0.25 | 0.12 | 0.039917 |
| 2 | 0.39 | 0.00 | 0.050171 | |
| 3 | 0.58 | 0.27 | 0.160645 | |
| 4 | 1.09 | 1.03 | 0.202148 | |
| 5 | 1.20 | 1.19 | 0.133057 | |
| 11 | 1 | 0.24 | 0.33 | 0.014526 |
| 2 | 0.54 | 0.00 | 0.023804 | |
| 3 | 0.98 | 0.11 | 0.027710 | |
| 4 | 1.62 | 1.04 | 0.030884 | |
| 5 | 2.41 | 2.25 | 0.033691 | |
| 12 | 1 | 0.45 | 0.98 | 0.020996 |
| 2 | 0.76 | 0.26 | 0.027954 | |
| 3 | 1.58 | 0.06 | 0.089478 | |
| 4 | 2.20 | 1.08 | 0.180908 | |
| 5 | 3.17 | 2.14 | 0.164307 | |
| 13 | 1 | 0.79 | 2.08 | 0.007324 |
| 2 | 1.40 | -0.47 | 0.008545 | |
| 3 | 2.72 | 1.26 | 0.017822 | |
| 4 | 3.76 | 1.82 | 0.021484 | |
| 5 | 5.46 | 3.28 | 0.033447 | |
| 14 | 1 | 1.20 | 2.63 | 0.010498 |
| 2 | 2.76 | 0.06 | 0.034912 | |
| 3 | 4.25 | 1.50 | 0.012451 | |
| 4 | 7.17 | -7.80 | 0.018188 | |
| 5 | 11.13 | 2.08 | 0.047852 | |
| 15 | 1 | 2.36 | 0.68 | 0.004272 |
| 2 | 4.44 | 2.33 | 0.010498 | |
| 3 | 9.34 | 7.44 | 0.017700 | |
| 4 | 14.25 | -3.36 | 0.009888 | |
| 5 | 23.22 | 11.94 | 0.012207 |
In [12]:
Copied!
# 原代码替换为:
display(
qiskit_df
.groupby(['num_qubits', 'qaoa_layers'])
.agg({
'runtime_sec': 'mean',
'memory_usage_mb': 'mean',
'best_probability': 'mean'
})
)
# 原代码替换为:
display(
qiskit_df
.groupby(['num_qubits', 'qaoa_layers'])
.agg({
'runtime_sec': 'mean',
'memory_usage_mb': 'mean',
'best_probability': 'mean'
})
)
| runtime_sec | memory_usage_mb | best_probability | ||
|---|---|---|---|---|
| num_qubits | qaoa_layers | |||
| 4 | 1 | 4.37 | 7.80 | 0.262939 |
| 2 | 7.94 | 0.59 | 0.492676 | |
| 3 | 10.41 | 0.98 | 0.484619 | |
| 4 | 11.11 | 1.16 | 0.484863 | |
| 5 | 11.40 | 0.31 | 0.432007 | |
| 5 | 1 | 3.81 | 0.00 | 0.094238 |
| 2 | 6.34 | 0.00 | 0.098877 | |
| 3 | 7.65 | -0.05 | 0.105713 | |
| 4 | 11.57 | 0.00 | 0.103394 | |
| 5 | 13.98 | 0.04 | 0.099976 | |
| 6 | 1 | 5.48 | 0.01 | 0.143311 |
| 2 | 6.65 | 0.00 | 0.265991 | |
| 3 | 10.77 | 0.00 | 0.199097 | |
| 4 | 12.74 | 0.00 | 0.445190 | |
| 5 | 13.40 | -0.02 | 0.216675 | |
| 7 | 1 | 4.88 | 0.00 | 0.047729 |
| 2 | 6.49 | 0.00 | 0.058716 | |
| 3 | 8.62 | -0.01 | 0.071167 | |
| 4 | 9.32 | 0.08 | 0.067505 | |
| 5 | 13.06 | 0.01 | 0.070190 | |
| 8 | 1 | 5.10 | 0.03 | 0.080444 |
| 2 | 5.77 | 0.00 | 0.122559 | |
| 3 | 7.70 | 0.00 | 0.084229 | |
| 4 | 11.19 | 0.00 | 0.130859 | |
| 5 | 11.61 | 0.01 | 0.270630 | |
| 9 | 1 | 4.35 | 0.00 | 0.026855 |
| 2 | 7.09 | 0.57 | 0.046875 | |
| 3 | 8.20 | 0.00 | 0.030884 | |
| 4 | 13.46 | -0.01 | 0.049438 | |
| 5 | 14.12 | -0.01 | 0.035522 | |
| 10 | 1 | 4.31 | 0.02 | 0.039917 |
| 2 | 5.98 | 0.56 | 0.051636 | |
| 3 | 10.73 | 0.02 | 0.165527 | |
| 4 | 9.42 | 0.05 | 0.162354 | |
| 5 | 13.16 | 0.00 | 0.141602 | |
| 11 | 1 | 4.55 | 0.00 | 0.015259 |
| 2 | 6.06 | 0.02 | 0.012573 | |
| 3 | 7.63 | 0.00 | 0.014526 | |
| 4 | 11.50 | 0.00 | 0.028564 | |
| 5 | 13.14 | 0.00 | 0.038208 | |
| 12 | 1 | 5.52 | 0.00 | 0.021973 |
| 2 | 7.11 | 0.00 | 0.053955 | |
| 3 | 9.56 | 0.00 | 0.080688 | |
| 4 | 12.53 | 0.00 | 0.047363 | |
| 5 | 16.59 | 0.10 | 0.081665 | |
| 13 | 1 | 4.93 | -0.07 | 0.008789 |
| 2 | 8.04 | 0.00 | 0.020020 | |
| 3 | 8.81 | 0.00 | 0.021362 | |
| 4 | 15.58 | 0.00 | 0.023315 | |
| 5 | 13.46 | 0.14 | 0.015625 | |
| 14 | 1 | 5.03 | 0.00 | 0.011719 |
| 2 | 7.21 | 0.00 | 0.031128 | |
| 3 | 8.05 | 0.55 | 0.022339 | |
| 4 | 13.07 | 0.01 | 0.049072 | |
| 5 | 15.13 | 0.00 | 0.018677 | |
| 15 | 1 | 5.24 | 0.06 | 0.005005 |
| 2 | 5.60 | 0.20 | 0.006104 | |
| 3 | 8.52 | -0.05 | 0.008179 | |
| 4 | 11.11 | 0.63 | 0.013916 | |
| 5 | 12.69 | -0.34 | 0.008911 |