• Chinese Journal of Quantum Electronics
  • Vol. 41, Issue 1, 151 (2024)
YANG Donghan, LI Zhiqiang*, WU Xi, PAN Wenjie, and YANG Hui
Author Affiliations
  • College of Information Engineering, Yangzhou University, Yangzhou 225100, China
  • show less
    DOI: 10.3969/j.issn.1007-5461.2024.01.015 Cite this Article
    Donghan YANG, Zhiqiang LI, Xi WU, Wenjie PAN, Hui YANG. Optimization of Oracle circuits based on minimum weight and template matching[J]. Chinese Journal of Quantum Electronics, 2024, 41(1): 151 Copy Citation Text show less
    Deutsch circuit
    Fig. 1. Deutsch circuit
    Grover circuit
    Fig. 2. Grover circuit
    Oracle circuit f(0,2,6,7)=1
    Fig. 3. Oracle circuit f(0,2,6,7)=1
    Oracle circuit f(4,6)=1
    Fig. 4. Oracle circuit f(4,6)=1
    Derivation process of R3
    Fig. 5. Derivation process of R3
    Examples of R1-R3. (a) R1; (b) R2; (c) R3
    Fig. 6. Examples of R1-R3. (a) R1; (b) R2; (c) R3
    (a) Initial circuit of f(3,4,7,9,11,12,13,14)=1; (b) Gate matching of algorithm 2; (c) Circuit conversion of algorithm 1;(d) Final circuit
    Fig. 7. (a) Initial circuit of f(3,4,7,9,11,12,13,14)=1; (b) Gate matching of algorithm 2; (c) Circuit conversion of algorithm 1;(d) Final circuit
    Derivation process of template 1
    Fig. 8. Derivation process of template 1
    Derivation process of template 2
    Fig. 9. Derivation process of template 2
    Matching process of template. (a) T2 matching; (b) T1 matching; (c) T2 matching; (d) Final circuit
    Fig. 10. Matching process of template. (a) T2 matching; (b) T1 matching; (c) T2 matching; (d) Final circuit

    算法4 Oracle整体优化算法

    输入:MCT门集合gates

    输出:优化后的线路gates

    1. do{

    2.  g1←Optimize(gates)  //阶段1优化

    3.  g2←T1_Match (g1)   //阶段2模板T1优化

    4.  gates←T2_Match (g2) //阶段2模板T2优化

    5. }while(gates != g1)

    6. return gates

    Table 0. [in Chinese]

    算法3 基于最小权匹配的线路替换算法Optimize

    输入: MCT门集合gates

    输出: 等效变换后的门集合gates1

    1. gates1←new hash()  // 初始化输出的门集合

    2. for key in gates{   // key表示MCT门的控制线位置信息

    3.  ngates[key].length // 具有相同控制线的MCT门集合, 有n个元素

    4.  Match(gates[key])   // 算法2重排序, 实现最小权匹配

    5.  for i←0 to n/2 do{   // 共有n/2个门对

    6.   gates1.add(Merge(key, gates[key][i*2], gates[key][i*2+1]))}} // 算法1两两替换

    7.  if n % 2 = 1{     // n为奇数, 最后一个门直接存储

    8.  gates1.add(gates[key][n-1]) }

    9. if gates1 = gates{  // 不再替换生成新的线路

    10.  return gates1 } // 返回结果线路

    11. Optimize (gates1)  // 在新的线路中递归算法3

    Table 0. [in Chinese]

    算法2 门集合的最小权匹配算法 Match

    输入: 相同控制线位置的门集合gates, 门集合构成图G

    输出: 配对后的门集合retGates

    1. retGates←Ø // 初始化输出门集合

    2. while gates = Ø{

    3. for each G(i) G do{ // 提取边权为i 的子图, 即MCT门互补控制点数目为i

    4. gates'←Blossom(G(i )) // 利用开花算法找到互补控制点为i的最大匹配

    5. retGates.add(gates' )  // 添加到结果

    6. gatesgatesgates' }} // 去除已匹配的点

    7. return retGates

    Table 0. [in Chinese]

    算法1 线路转换算法Merge

    输入:key , value1, value2

    输出:等效线路gates

    1. gates←ϕ           // 定义输出线路gates

    2. countvalue1value2     //确定控制点不同的位置(位运算)

    3. while (count){

    4.  lastIndexcount & (-count)  //获取最低位的1(位运算)

    5.  key←Set the log(lastIndex)-th 1 of the key to 0 // 得到新的控制线位置

    6.  gates[key].add(((value1 >> 1) & ~(lastIndex - 1)) + ((lastIndex - 1) & value1))

    7.  countcount & (count-1) }  //最低位的1清0, 迭代次数减1

    8. return gates

    Table 0. [in Chinese]
    f(x)OriginalRCViewer+Phase1Phase2Impr/%
    GCQCGCQCGCQCGCQCGCQC
    1{0, 1, 3, 4, 5, 9, 12, 15}8232810854253337.569.4
    2{0, 1, 7, 10, 11, 12, 14, 15}8232810664553837.564.2
    3{0, 2, 3, 6, 9, 10, 11, 14}823279353632557.173.1
    4{1, 2, 5, 7, 8, 11, 12, 15}823279142641642.982.4
    5{1, 3, 8, 11, 12, 13, 14, 15}823267856533950.050.0
    6{2, 3, 4, 5, 10, 11, 12, 14}82324524384280.046.2
    7{2, 5, 6, 7, 8, 10, 12, 13}8232823254343450.085.3
    8{3, 4, 7, 9, 11, 12, 13, 14}82321114354944063.672.0
    9{4, 5, 6, 7, 9, 11, 12, 14}82324523112650.088.5
    10{4, 7, 8, 9, 10, 11, 12, 15}823267841931550.080.8
    Avg6.9103.33.727.446.473.5
    Table 1. Deutsch optimized experimental results with n = 4
    nOriginalRCViewer+Phase1Phase2Impr/%ET/s
    GCQCGCQCGCQCGCQCGCQC
    4823278643943242.962.8<0.1
    5169761339610151711546.271.00.1
    6324000291555224711534248.378.00.3
    764161926048404814283099350.079.51.4
    81286515212212204106361959237951.680.59.2
    9256261376245314132269578123632849.879.987.2
    1051210470404961474484751093402656015346.659.2741.3
    Avg138.928277.471.910048.948.364.5
    Table 2. Optimized experimental results of DJ’s Oracle circuit with n bit
    nOriginalRCViewer+Phase1Phase2Impr/%ET/s
    GCQCGCQCGCQCGCQCGCQC
    43882362362340.05.6<0.1
    553014114411241080.05.3<0.1
    6811227343833073080.010.20.1
    717435117939179211583111.811.50.4
    8311580936230635223329198419.414.01.2
    9585999487630783612667520023.017.68.3
    1013426644323515937219155071671279828.919.7123.9
    Avg55.43711.741.63037.625.018.2
    Table 3. Optimized experimental results of Grover’s Oracle circuitwith n bit
    Donghan YANG, Zhiqiang LI, Xi WU, Wenjie PAN, Hui YANG. Optimization of Oracle circuits based on minimum weight and template matching[J]. Chinese Journal of Quantum Electronics, 2024, 41(1): 151
    Download Citation