Commit 0b8bceb
Rewrite default
* Rewrite default `UnitarySynthesis` to cache decomposers
This is a complete rewrite of the default `UnitarySynthesis` plugin to
vastly improve the efficiency of 2q decomposition.
This is good for approximately a 2x runtime improvement in the
`UnitarySynthesis` pass, since before this commit, we were
reconstructing each relevant 2q decomposer each time we had a new matrix
to decompose. However, constructing a 2q KAK decomposer is about as
expensive as using a constructed KAK decomposer on a single matrix.
This commit caches the available decomposers for each encountered pair
of qubits, and allows the cache to be persisted between calls to
`run_unitary_synthesis`.
Before the move of the default unitary synthesis plugin to Rust, we
effectively had decomposer caching for the "loose constraint" (basis
gates + coupling map) hardware description, since we just chose a single
decomposer on initialisation and used it throughout. The `Target` form
in Python space cached at the `qargs` level, which meant that multiple
unitaries on the same qargs pair would use the same set of decomposers,
but each qargs pair would be calculated separately on first access,
still (generally) leading to multiple constructions of the same
decomposer. Both of these types of caching were lost in the move to
Rust, but the effects were largely masked by the total runtime still
being drastically better than the Python-space versions.
This new form reinstates all the previous caching, and additionally
caches at the level of individual decomposer construction as well (by
caching the arguments used to construct a decomposer), so that (mostly)
homogeneous `Target`s will re-use the same decomposer whenever it is
valid on more than one 2q link.
* Give synthesis/state structs explicit names
There's lots of types of "synthesis" in Qiskit...
* Correct copyright years
* Avoid magic numbers in `ApproximationDegree::is_approximate`
Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
---------
Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>UnitarySynthesis to cache decomposers (Qiskit#15492)1 parent 826b4f1 commit 0b8bceb
16 files changed
Lines changed: 1938 additions & 1689 deletions
File tree
- crates
- cext/src/transpiler
- passes
- circuit/src
- synthesis/src
- discrete_basis
- transpiler/src
- passes
- unitary_synthesis
- target
- releasenotes/notes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | 13 | | |
16 | 14 | | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | | - | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
88 | 96 | | |
89 | | - | |
90 | | - | |
| 97 | + | |
| 98 | + | |
91 | 99 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
167 | 173 | | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
172 | 178 | | |
173 | 179 | | |
| 180 | + | |
174 | 181 | | |
175 | 182 | | |
176 | 183 | | |
| |||
399 | 406 | | |
400 | 407 | | |
401 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
402 | 414 | | |
403 | 415 | | |
404 | 416 | | |
| |||
407 | 419 | | |
408 | 420 | | |
409 | 421 | | |
| 422 | + | |
410 | 423 | | |
411 | 424 | | |
412 | 425 | | |
| |||
500 | 513 | | |
501 | 514 | | |
502 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
503 | 521 | | |
504 | 522 | | |
505 | | - | |
| 523 | + | |
506 | 524 | | |
507 | 525 | | |
508 | 526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8634 | 8634 | | |
8635 | 8635 | | |
8636 | 8636 | | |
| 8637 | + | |
| 8638 | + | |
| 8639 | + | |
| 8640 | + | |
| 8641 | + | |
| 8642 | + | |
| 8643 | + | |
| 8644 | + | |
| 8645 | + | |
| 8646 | + | |
| 8647 | + | |
| 8648 | + | |
8637 | 8649 | | |
8638 | 8650 | | |
8639 | 8651 | | |
8640 | 8652 | | |
8641 | 8653 | | |
| 8654 | + | |
| 8655 | + | |
| 8656 | + | |
| 8657 | + | |
| 8658 | + | |
| 8659 | + | |
| 8660 | + | |
| 8661 | + | |
| 8662 | + | |
| 8663 | + | |
| 8664 | + | |
| 8665 | + | |
8642 | 8666 | | |
8643 | 8667 | | |
8644 | 8668 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
431 | 442 | | |
432 | 443 | | |
433 | 444 | | |
| |||
824 | 835 | | |
825 | 836 | | |
826 | 837 | | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
827 | 842 | | |
828 | 843 | | |
829 | 844 | | |
| |||
833 | 848 | | |
834 | 849 | | |
835 | 850 | | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
836 | 864 | | |
837 | 865 | | |
838 | 866 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
608 | | - | |
| 608 | + | |
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
623 | 641 | | |
624 | 642 | | |
625 | 643 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1279 | 1279 | | |
1280 | 1280 | | |
1281 | 1281 | | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1282 | 1289 | | |
1283 | 1290 | | |
1284 | 1291 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
0 commit comments