quantum-compiler / quartz

The Quartz Quantum Compiler
Apache License 2.0
76 stars 19 forks source link

[Simulator] A better heuristic for permuting gates before the simple DP #133

Closed xumingkuan closed 11 months ago

xumingkuan commented 11 months ago

Changes specific to the simulator: I use the following heuristic to permute the gates before the simple DP:

Benchmark: qft, 33 qubits, 28 local qubits: Before:

2 stages.
Kernel info: 11 kernels (8 fusion, 3 shared-memory), cost = 271.5, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
0 seconds.

After (repeat=10):

2 stages.
Kernel info: 10 kernels (7 fusion, 3 shared-memory), cost = 271.3, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
3 seconds.

(each invocation:)

Kernel info: 10 kernels (7 fusion, 3 shared-memory), cost = 271.3, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 14 kernels (9 fusion, 5 shared-memory), cost = 294.6, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 13 kernels (10 fusion, 3 shared-memory), cost = 282, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 14 kernels (10 fusion, 4 shared-memory), cost = 290, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 11 kernels (8 fusion, 3 shared-memory), cost = 273.7, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 13 kernels (9 fusion, 4 shared-memory), cost = 287.6, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 13 kernels (9 fusion, 4 shared-memory), cost = 285.4, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 10 kernels (6 fusion, 4 shared-memory), cost = 277.9, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 10 kernels (7 fusion, 3 shared-memory), cost = 271.3, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
Kernel info: 5 kernels (5 fusion, 0 shared-memory), cost = 31.6, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.6, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
Kernel info: 5 kernels (5 fusion, 0 shared-memory), cost = 31.6, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4

After (repeat=100):

2 stages.
Kernel info: 11 kernels (8 fusion, 3 shared-memory), cost = 265.7, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
29 seconds.

Recall the complicated DP:

2 stages.
Kernel info: 13 kernels (10 fusion, 3 shared-memory), cost = 268.5, local qubits 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Kernel info: 4 kernels (4 fusion, 0 shared-memory), cost = 25.4, local qubits 5 6 7 8 9 10 11 12 13 28 29 30 31 32 19 20 21 22 23 24 25 26 27 0 1 2 3 4
6 seconds.