LLM-Driven Algorithm Design for Quantum Circuit Synthesis based on Binary Decision Diagrams
Organizations: Department of Industrial and Systems Engineering, KAIST, Daejeon, 34141, Republic of Korea · Radical Numerics, California, USA · Omelet, Inc., Daejeon, 34051, Republic of Korea
Abstract
Quantum circuits are central to implementing quantum algorithms on quantum devices, where quantum gates must be reversible. Many quantum algorithms rely on Boolean functions, which must therefore be implemented reversibly within quantum circuits. Reversible circuit synthesis provides a way to translate such Boolean functions into reversible circuits. Binary decision diagrams (BDDs) offer a scalable approach to this task, but the resulting BDDs and circuits depend heavily on variable ordering. Existing ordering heuristics commonly minimize BDD size because it is closely tied to the circuit size. However, BDD size is an imperfect proxy for the quantum cost of the synthesized circuit (QCC). We propose QuantumEvo, an evolutionary framework that uses an LLM as a heuristic generator for QCC-aware BDD variable ordering. Instead of predicting orderings directly, QuantumEvo searches over ordering heuristics initialized from multiple heuristic families. Candidate heuristics directly manipulate variable orderings using standard BDD operations and are selected by downstream QCC. The discovered heuristic, HGA-QE, modifies the sifting step inside a genetic algorithm so that the procedure is better aligned with QCC. Across the benchmark set, HGA-QE achieves a 70.9% tie-or-win rate against the per-function best baseline and is strictly best on 13.5% of the functions. The results demonstrate broadly competitive QCC performance, with HGA-QE showing a clearer relative advantage in strict wins on the two benchmark suites drawn from sources different from the data used for heuristic discovery.
Figures & tables
| QCC | BDD | ||||
| Method | Mean Gap ( ) | W/T/L | Mean Gap ( ) | W/T/L | Total Time (s) |
| GA with sifting | 2.096% | - | 0.211% | - | 23.24 |
| GA with MiniSift | 0.532% | 34/53/13 | 0.350% | 4/94/2 | 21.95 |
| GA with MiniSift + local refinement | 0.527% | 34/53/13 | 0.354% | 4/94/2 | 22.01 |
| Suite | Method | Best | Strict | Mean Best QCC | Mean Avg QCC | Mean Worst QCC |
| RevLib (96) | HGA-QE | 70 | 6 | 1416.04 | 1434.31 | 1450.76 |
| SA | 68 | 5 | 1416.25 | 1437.27 | 1463.44 | |
| BDD2Seq | 65 | 13 | 1456.03 | – | – | |
| GA | 58 | 1 | 1445.28 | 1457.55 | 1468.35 | |
| SIFT | 42 | 0 | 1767.24 | – | – | |
| SYMM SIFT | 41 | 0 | 1757.90 | – | – |
| Circuit | I | O | QuantumEvo | GA | SA | ||||||
| Best | Avg | Avg Time | Best | Avg | Avg Time | Best | Avg | Avg Time | |||
| apex5_104 R | 117 | 88 | 9184 | 9812.40 | 0.97 | 9551 | 10041.40 | 1.24 | 9397 | 9809.00 | 1.97 |
| apex6_orig L | 135 | 99 | 3736 | 3787.20 | 0.65 | 4159 | 4368.40 | 0.64 | 4392 | 4551.40 | 1.08 |
| apex7_orig L | 49 | 37 | 1431 | 1440.60 | 0.28 | 1441 | 1443.40 | 0.58 | 1703 | 1759.20 | 0.44 |
| b9_orig L | 41 | 21 | 713 | 719.40 | 0.17 | 715 | 719.00 | 0.27 | 804 | 804.00 | 0.19 |
| c432 I | 36 | 7 | 10494 | 11053.20 | 245.19 | 11141 | 11170.60 | 6.20 | 11101 | 11148.60 | 1.46 |
| Initialization | Fitness | Guidance | Best/Total (%) | Strictly Best/Total (%) | Mean Best QCC | Mean Avg QCC | Mean Worst QCC |
| Sifting, GA, SA | QCC | LLM | 70.9 | 13.5 | 1923.83 | 1979.76 | 2033.46 |
| Non-LLM | 66.9 | 5.4 | 2075.15 | 2220.27 | 2432.07 | ||
| GA | QCC | LLM | 63.5 | 3.4 | 2061.84 | 2172.50 | 2264.26 |
| SA | QCC | LLM | 66.2 | 0.7 | 1949.11 | 2004.30 | 2084.68 |
| Sifting | QCC | LLM | 55.4 | 4.1 | 2203.34 | 2435.04 | 2670.19 |
| Sifting, GA, SA | BDD size | LLM | 61.5 | 5.4 | 1944.65 | 2003.03 | 2099.68 |
Appendix figures & tables26 assets
Supplementary material from the paper’s appendix.
Appendix
| Hyperparameter | Value | Hyperparameter | Value |
| Max. function evaluations | 200 | Per-iteration timeout | 40 s |
| Population size | 10 | Evaluation seeds per instance | 3 |
| Initial population size | 30 | Search instances | 100 |
| Mutation rate | 0.5 | Validation instances | 50 |
| Family | Search dimension | Available choices or range |
| Top level | Heuristic family | Sifting / SA / GA. The initial population is divided evenly across the three families. |
| Sifting | Search direction | Bidirectional / top-down only / bottom-up only. |
| Search range | Full variable range / sliding window with width / random subset containing of the variables in each pass. | |
| Simulated annealing | Neighborhood operators | Seed exchange–jump mixture / exchange only / jump only / adjacent swap only / all four move types. |
| Move probabilities | Exchange probability ; upward-jump share . | |
| Cooling schedule | Multiplicative cooling factor ; secondary temperature-scaling parameter . |
| Benchmark | Family Type | |||||||
| LLM choice | Best/Total (%) | Strictly Best/Total (%) | Mean Best QCC | Mean Avg QCC | Mean Worst QCC | GA | SA | Sifting |
| gpt-oss-120b | 70.9 | 13.5 | 1923.83 | 1979.76 | 2033.46 | 1 | 9 | 0 |
| gpt-5.4-mini | 66.9 | 6.1 | 2080.71 | 2147.33 | 2211.11 | 2 | 3 | 5 |
| Analysis | Initialization | Fitness | Guidance | Rate |
| Search set | Multi-seed | QCC | gpt-oss-120b | 5/10 |
| Validation set | Multi-seed | QCC | gpt-oss-120b | 9/10 |
| gpt-5.4-mini | 2/10 | |||
| Non-LLM | 1/10 | |||
| GA only | QCC | gpt-oss-120b | 8/10 | |
| SA only | QCC | gpt-oss-120b | Identical heuristic |
| Budget fraction | Budget (s) | Failure rate |
| 1.0 | 40.0 | 8.3% |
| 0.9 | 36.0 | 9.0% |
| 0.8 | 32.0 | 9.8% |
| 0.7 | 28.0 | 11.6% |
| 0.6 | 24.0 | 14.1% |
| 0.5 | 20.0 | 17.7% |
| Pseudocode | CUDD function | Source file | Type | Notes |
| Sift | cuddSifting | cuddReorder.c | W | — |
| SwapAdjacent | cuddSwapInPlace | cuddReorder.c | W | — |
| PMX | PMX | cuddGenetic.c | W | — |
| RouletteSelect | roulette | cuddGenetic.c | A | Spin range unified to popsize for both parent selections |
| PartialSift | build_dd | cuddGenetic.c | A | Replaces full cuddSifting with MiniSift over marked starting levels |
| RestoreOrder | restoreOrder | cuddAnneal.c | A | Reimplemented locally; based on annealing restore logic (cf. ddShuffle in cuddReorder.c ) |
| Statistic | Sifting | MiniSift | Change (%) | Wilcoxon |
| Unique fraction | 0.553 | 0.615 | ||
| Hamming fraction | 0.507 | 0.537 | ||
| Child-node line preservation cases | 999 | 983 | 0.0100 | |
| Toffoli gates | 3847 | 3797 | ||
| Total controls | 10591 | 10479 | ||
| Total QCC | 22550 | 22274 |
| Suite | Baseline | Mean QCC | (raw) | (Holm) |
| RevLib (96) | SA | -0.21 | 0.571 | 0.571 |
| BDD2Seq | -39.99 | 0.008 | 0.025 | |
| GA | -29.24 | 0.069 | 0.139 | |
| SIFT | -351.20 | |||
| SYMM_SIFT | -341.85 | |||
| GROUP_SIFT | -272.52 |
| Method | Stage | Success | Best | Strict | Mean Best | Mean Avg | Mean Worst | Geo-mean Runtime (s) |
| HGA-QE | Net. Size | 49/52 | 47/49 | 5/49 | 217.39 | 222.12 | 227.86 | 0.066 |
| # LUT | 49/52 | 30/48 | 3/48 | 83.46 | 87.45 | 91.73 | 3.036 | |
| SA | Net. Size | 52/52 | 36/49 | 1/49 | 215.47 | 222.06 | 235.41 | 0.092 |
| # LUT | 52/52 | 35/48 | 6/48 | 85.04 | 90.52 | 98.50 | 3.041 | |
| GA | Net. Size | 52/52 | 42/49 | 1/49 | 274.24 | 1575.83 | 2564.90 | 0.080 |
| # LUT | 50/52 | 30/48 | 4/48 | 83.38 | 87.24 | 90.35 | 3.060 |
| LLM Calls | Input Tokens | Output Tokens | Wall-clock | Hardware |
| 291.6 | 3.11M | 1.04M | 108.5 min | 1 NVIDIA RTX PRO 6000 |
| Function | I | O | QuantumEvo | GA | SA | ||||||
| Best | Avg Std | Time | Best | Avg Std | Time | Best | Avg Std | Time | |||
| 4gt10_22 | 4 | 1 | 17 | 17.00 0 | 0.04 | 17 | 17.00 0 | 0.06 | 17 | 17.00 0 | 0.05 |
| 4gt11_23 | 4 | 1 | 5 | 5.00 0 | 0.06 | 5 | 5.00 0 | 0.06 | 5 | 5.00 0 | 0.05 |
| 4gt12_24 | 4 | 1 | 17 | 17.00 0 | 0.06 | 17 | 17.00 0 | 0.06 | 17 | 17.00 0 | 0.06 |
| 4gt13_25 | 4 | 1 | 10 | 10.00 0 | 0.06 | 10 | 10.00 0 | 0.06 | 10 | 10.00 0 | 0.05 |
| 4gt4_20 | 4 | 1 | 19 | 19.00 0 | 0.06 | 19 | 19.00 0 | 0.06 | 19 | 19.00 0 | 0.06 |
| Function | I | O | QuantumEvo | GA | SA | ||||||
| Best | Avg Std | Time | Best | Avg Std | Time | Best | Avg Std | Time | |||
| ex3_152 | 5 | 1 | 38 | 40.00 4 | 0.06 | 38 | 44.00 4.90 | 0.06 | 38 | 45.00 4 | 0.06 |
| ex5p_154 | 8 | 63 | 1843 | 1843.00 0 | 0.11 | 1843 | 1843.00 0 | 0.11 | 1843 | 1843.00 0 | 0.14 |
| example2_156 | 10 | 6 | 1266 | 1276.80 8.82 | 0.08 | 1269 | 1287.00 11.22 | 0.09 | 1266 | 1278.80 9.62 | 0.11 |
| f2_158 | 4 | 4 | 108 | 111.00 2.45 | 0.05 | 108 | 108.00 0 | 0.05 | 113 | 113.00 0 | 0.05 |
| f51m_159 | 14 | 8 | 2422 | 2429.20 4.21 | 0.14 | 2427 | 2429.40 2.94 | 0.20 | 2422 | 2430.60 4.32 | 0.25 |
| Function | I | O | QuantumEvo | GA | SA | ||||||
| Best | Avg Std | Time | Best | Avg Std | Time | Best | Avg Std | Time | |||
| apex6_orig L | 135 | 99 | 3736 | 3787.20 36.31 | 0.65 | 4159 | 4368.40 169.77 | 0.64 | 4392 | 4551.40 148.45 | 1.08 |
| apex7_orig L | 49 | 37 | 1431 | 1440.60 7.45 | 0.28 | 1441 | 1443.40 2.94 | 0.58 | 1703 | 1759.20 46.63 | 0.44 |
| b1_orig L | 3 | 4 | 22 | 23.00 2 | 0.06 | 22 | 22.00 0 | 0.05 | 22 | 22.00 0 | 0.06 |
| b9_orig L | 41 | 21 | 713 | 719.40 6.59 | 0.17 | 715 | 719.00 3.58 | 0.27 | 804 | 804.00 0 | 0.19 |
| c17 I | 5 | 2 | 37 | 37.00 0 | 0.06 | 37 | 37.00 0 | 0.06 | 37 | 37.00 0 | 0.06 |
| Function | QuantumEvo | BDD2Seq(B*) | BDD2Seq(E*) | SIFT | SYMM_SIFT | GROUP_SIFT | ||||||
| Best | Time | Best | Time | Best | Time | Best | Time | Best | Time | Best | Time | |
| 4gt10_22 | 17 | 0.04 | 17 | 1.49 | 17 | 2.13 | 17 | 0.02 | 23 | 0.01 | 23 | 0.02 |
| 4gt11_23 | 5 | 0.06 | 5 | 0.05 | 5 | 0.01 | 5 | 0.01 | 5 | 0.01 | 5 | 0.03 |
| 4gt12_24 | 17 | 0.06 | 17 | 0.04 | 17 | 0.01 | 17 | 0.01 | 16 | 0.01 | 16 | 0.03 |
| 4gt13_25 | 10 | 0.06 | 10 | 0.05 | 10 | 0.01 | 10 | 0.01 | 10 | 0.01 | 10 | 0.03 |
| 4gt4_20 | 19 | 0.06 | 19 | 0.04 | 25 | 0.01 | 19 | 0.03 | 23 | 0.01 | 23 | 0.03 |
| Function | QuantumEvo | BDD2Seq(B*) | BDD2Seq(E*) | SIFT | SYMM_SIFT | GROUP_SIFT | ||||||
| Best | Time | Best | Time | Best | Time | Best | Time | Best | Time | Best | Time | |
| ex3_152 | 38 | 0.06 | 38 | 0.08 | 38 | 0.02 | 61 | 0.03 | 61 | 0.03 | 43 | 0.03 |
| ex5p_154 | 1843 | 0.11 | 1837 | 0.17 | 1871 | 0.06 | 1843 | 0.04 | 1843 | 0.05 | 1843 | 0.05 |
| example2_156 | 1266 | 0.08 | 1218 | 0.18 | 1415 | 0.03 | 1436 | 0.03 | 1436 | 0.03 | 1366 | 0.02 |
| f2_158 | 108 | 0.05 | 108 | 0.05 | 113 | 0.01 | 113 | 0.03 | 113 | 0.03 | 113 | 0.02 |
| f51m_159 | 2422 | 0.14 | 2427 | 0.46 | 2517 | 0.14 | 5392 | 0.05 | 5392 | 0.05 | 4603 | 0.05 |
| Function | QuantumEvo | BDD2Seq(B*) | BDD2Seq(E*) | SIFT | SYMM_SIFT | GROUP_SIFT | ||||||
| Best | Time | Best | Time | Best | Time | Best | Time | Best | Time | Best | Time | |
| apex6_orig L | 3736 | 0.65 | 3895 | 16.72 | 4021 | 0.16 | 4822 | 0.05 | 4810 | 0.03 | 4269 | 0.03 |
| apex7_orig L | 1431 | 0.28 | 1455 | 2.40 | 1456 | 0.07 | 2653 | 0.04 | 2653 | 0.04 | 2377 | 0.04 |
| b1_orig L | 22 | 0.06 | 22 | 0.04 | 22 | 0.01 | 22 | 0.03 | 22 | 0.03 | 22 | 0.03 |
| b9_orig L | 713 | 0.17 | 737 | 1.71 | 737 | 0.05 | 804 | 0.03 | 810 | 0.03 | 836 | 0.03 |
| c17 I | 37 | 0.06 | 37 | 0.06 | 49 | 0.01 | 49 | 0.03 | 49 | 0.03 | 37 | 0.03 |
Quantum Circuit Compilation
Quantum circuit compilation translates quantum algorithms into hardware-compatible circuits while reducing resource costs and preserving their behavior.
See all 21 papers