CN117313883A - Quantum circuit processing method and device and electronic equipment - Google Patents

Quantum circuit processing method and device and electronic equipment Download PDF

Info

Publication number
CN117313883A
CN117313883A CN202311268026.XA CN202311268026A CN117313883A CN 117313883 A CN117313883 A CN 117313883A CN 202311268026 A CN202311268026 A CN 202311268026A CN 117313883 A CN117313883 A CN 117313883A
Authority
CN
China
Prior art keywords
qubit
quantum circuit
list
instruction
qubits
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311268026.XA
Other languages
Chinese (zh)
Other versions
CN117313883B (en
Inventor
方堃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202311268026.XA priority Critical patent/CN117313883B/en
Publication of CN117313883A publication Critical patent/CN117313883A/en
Application granted granted Critical
Publication of CN117313883B publication Critical patent/CN117313883B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/20Models of quantum computing, e.g. quantum circuits or universal quantum computers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/40Physical realisations or architectures of quantum processors or components for manipulating qubits, e.g. qubit coupling or qubit control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/80Quantum programming, e.g. interfaces, languages or software-development kits for creating or handling programs capable of running on quantum computers; Platforms for simulating or accessing quantum computers, e.g. cloud-based quantum computing

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Mathematical Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Data Mining & Analysis (AREA)
  • Condensed Matter Physics & Semiconductors (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computational Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Superconductor Devices And Manufacturing Methods Thereof (AREA)

Abstract

The disclosure provides a quantum circuit processing method, a quantum circuit processing device and electronic equipment, relates to the technical field of quantum computing, and particularly relates to the technical field of quantum circuits. The specific implementation scheme is as follows: acquiring a first instruction list of a first quantum circuit comprising N quantum bits, wherein the first quantum circuit is a quantum circuit with a star structure or a sub-circuit of the quantum circuit with the star structure, and in the star structure, a double-quantum bit gate acts between each first quantum bit and a target quantum bit according to the sequence of the quantum bits from small to large; based on the first instruction list, performing equivalent compiling on the first quantum circuit to obtain a second instruction list of the second quantum circuit; equivalent compilation includes: adding a first reset operation instruction after the first measurement operation instruction in the first instruction list; each target operating instruction in the first instruction list is remapped to the qubit of the qubit i, and the target operating instruction acts on the qubit i+1.

Description

量子电路处理方法、装置及电子设备Quantum circuit processing methods, devices and electronic equipment

技术领域Technical field

本公开涉及量子计算技术领域,尤其涉及量子电路技术领域,具体涉及一种量子电路处理方法、装置及电子设备。The present disclosure relates to the field of quantum computing technology, in particular to the field of quantum circuit technology, and specifically to a quantum circuit processing method, device and electronic equipment.

背景技术Background technique

量子计算利用量子世界中特有的运行规律,提供了一条全新的并且非常有前景的信息处理方式。在诸多特定问题上,量子算法可以带来超越经典算法的优势。例如,利用秀尔(Shor)算法,可以对大整数进行高效的分解,利用格罗弗(Grover)算法,可以更快的进行数据搜索。随着量子理论的发展,不断有新的量子算法被提出,如何高效的对这些算法进行模拟或者在真正的量子硬件上运行始终是一个重要的问题。Quantum computing uses the unique operating laws of the quantum world to provide a new and very promising way of processing information. Quantum algorithms can bring advantages over classical algorithms on many specific problems. For example, the Shor algorithm can be used to efficiently decompose large integers, and the Grover algorithm can be used to search for data faster. With the development of quantum theory, new quantum algorithms are constantly being proposed. How to efficiently simulate these algorithms or run them on real quantum hardware is always an important issue.

量子算法的经典模拟或者真机运行主要受限于量子比特的数量。在经典模拟上,由于描述量子态的列向量的长度随对应比特数呈指数增长(例如一个n比特的量子态的列向量长度为2n),经典计算机很难模拟大规模的量子算法。受计算机内存和处理器能力的限制,现有的量子电路模拟方式最多能支持模拟几十个量子比特的算法。Classical simulation or real machine operation of quantum algorithms is mainly limited by the number of qubits. In classical simulations, since the length of the column vector describing the quantum state grows exponentially with the number of corresponding bits (for example, the column vector length of an n-bit quantum state is 2 n ), it is difficult for classical computers to simulate large-scale quantum algorithms. Limited by computer memory and processor capabilities, existing quantum circuit simulation methods can support algorithms that simulate dozens of qubits at most.

目前,通常是采用启发式算法对量子电路进行等效编译,以得到与量子电路等效的动态量子电路。At present, heuristic algorithms are usually used to perform equivalent compilation of quantum circuits to obtain dynamic quantum circuits that are equivalent to quantum circuits.

发明内容Contents of the invention

本公开提供了一种量子电路处理方法、装置及电子设备。The present disclosure provides a quantum circuit processing method, device and electronic equipment.

根据本公开的第一方面,提供了一种量子电路处理方法,包括:According to a first aspect of the present disclosure, a quantum circuit processing method is provided, including:

获取包括N个量子比特的第一量子电路的第一指令列表,所述第一量子电路为:星型结构的量子电路或星型结构的量子电路的子电路,所述星型结构的量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特有序排列,所述星型结构中,按照量子位从小到大的顺序分别在每个第一量子比特与目标量子比特之间作用双量子比特门,所述目标量子比特为所述N个量子比特之间任一量子比特,所述第一量子比特为所述N个量子比特中除所述目标量子比特的其他量子比特,所述子电路为从星型结构的量子电路的指令列表中删除部分操作指令所获得的量子电路,N为大于2的整数;Obtaining a first instruction list of a first quantum circuit including N qubits, the first quantum circuit being: a star-structured quantum circuit or a sub-circuit of a star-structured quantum circuit, the star-structured quantum circuit The N qubits in the qubit are arranged in order from the qubit of qubit 0 to the qubit of qubit N-1. In the star structure, each first qubit and the qubit are arranged in order from small to large. A two-qubit gate acts between target qubits, the target qubit is any qubit among the N qubits, and the first qubit is any of the N qubits except the target qubit. Other qubits, the sub-circuit is a quantum circuit obtained by deleting some operation instructions from the instruction list of a star-structured quantum circuit, and N is an integer greater than 2;

基于所述第一指令列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表;Based on the first instruction list, perform equivalent compilation on the first quantum circuit to obtain a second instruction list of the second quantum circuit equivalent to the first quantum circuit;

其中,所述第二量子电路的量子比特数量小于所述第一量子电路的量子比特数量,所述等效编译包括:在所述第一指令列表中第一测量操作指令之后添加第一重置操作指令;并将所述第一指令列表中每个目标操作指令重新映射到量子位i的量子比特上,所述第一测量操作指令和所述第一重置操作指令均作用在量子位i上,所述目标操作指令作用在量子位i+1上,i的取值范围为[0,N-3]。Wherein, the number of qubits of the second quantum circuit is less than the number of qubits of the first quantum circuit, and the equivalent compilation includes: adding a first reset after the first measurement operation instruction in the first instruction list Operation instructions; and remap each target operation instruction in the first instruction list to the qubit of qubit i, and the first measurement operation instruction and the first reset operation instruction both act on qubit i On, the target operation instruction acts on qubit i+1, and the value range of i is [0, N-3].

根据本公开的第二方面,提供了一种量子电路处理装置,包括:According to a second aspect of the present disclosure, a quantum circuit processing device is provided, including:

获取模块,用于获取包括N个量子比特的第一量子电路的第一指令列表,所述第一量子电路为:星型结构的量子电路或星型结构的量子电路的子电路,所述星型结构的量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特有序排列,所述星型结构中,按照量子位从小到大的顺序分别在每个第一量子比特与目标量子比特之间作用双量子比特门,所述目标量子比特为所述N个量子比特之间任一量子比特,所述第一量子比特为所述N个量子比特中除所述目标量子比特的其他量子比特,所述子电路为从星型结构的量子电路的指令列表中删除部分操作指令所获得的量子电路,N为大于2的整数;An acquisition module, configured to acquire a first instruction list of a first quantum circuit including N qubits, where the first quantum circuit is: a star-structured quantum circuit or a sub-circuit of a star-structured quantum circuit, where the star The N qubits in the quantum circuit of the star-shaped structure are arranged in an orderly manner from the qubits of qubit 0 to the qubits of qubit N-1. In the star-shaped structure, each qubit is arranged in order from small to large. A two-qubit gate operates between the first qubit and the target qubit. The target qubit is any qubit among the N qubits. The first qubit is any one of the N qubits. For other qubits of the target qubit, the sub-circuit is a quantum circuit obtained by deleting some operation instructions from the instruction list of the star-structured quantum circuit, and N is an integer greater than 2;

等效编译模块,用于基于所述第一指令列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表;An equivalent compilation module, configured to perform equivalent compilation on the first quantum circuit based on the first instruction list to obtain a second instruction list of the second quantum circuit equivalent to the first quantum circuit;

其中,所述第二量子电路的量子比特数量小于所述第一量子电路的量子比特数量,所述等效编译包括:在所述第一指令列表中第一测量操作指令之后添加第一重置操作指令;并将所述第一指令列表中每个目标操作指令重新映射到量子位i的量子比特上,所述第一测量操作指令和所述第一重置操作指令均作用在量子位i上,所述目标操作指令作用在量子位i+1上,i的取值范围为[0,N-3]。Wherein, the number of qubits of the second quantum circuit is less than the number of qubits of the first quantum circuit, and the equivalent compilation includes: adding a first reset after the first measurement operation instruction in the first instruction list Operation instructions; and remap each target operation instruction in the first instruction list to the qubit of qubit i, and the first measurement operation instruction and the first reset operation instruction both act on qubit i On, the target operation instruction acts on qubit i+1, and the value range of i is [0, N-3].

根据本公开的第三方面,提供了一种电子设备,包括:According to a third aspect of the present disclosure, an electronic device is provided, including:

至少一个处理器;以及at least one processor; and

与至少一个处理器通信连接的存储器;其中,A memory communicatively connected to at least one processor; wherein,

存储器存储有可被至少一个处理器执行的指令,该指令被至少一个处理器执行,以使至少一个处理器能够执行第一方面中的任一项方法。The memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor, so that at least one processor can perform any method in the first aspect.

根据本公开的第四方面,提供了一种存储有计算机指令的非瞬时计算机可读存储介质,该计算机指令用于使计算机执行第一方面中的任一项方法。According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform any one of the methods of the first aspect.

根据本公开的第五方面,提供了一种计算机程序产品,包括计算机程序,该计算机程序在被处理器执行时实现第一方面中的任一项方法。According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program that implements any method in the first aspect when executed by a processor.

根据本公开的技术解决了相关技术中星型结构的量子电路以及星型结构的量子电路的子电路的经典模拟和真机运行比较难的问题,能够实现星型结构的量子电路,以及星型结构的量子电路的子电路的最优编译,使得编译出来的量子电路宽度可以达到最小,即能够将一个星型结构的量子电路或一个星型结构的量子电路的子电路编译成与其等价的所需量子比特数最少的动态量子电路,从而能够简化星型结构的量子电路,以及星型结构的量子电路的子电路的经典模拟和真机运行。The technology according to the present disclosure solves the problem in the related art that the classical simulation and real machine operation of the star-structured quantum circuit and the sub-circuit of the star-structured quantum circuit are difficult, and can realize the star-structured quantum circuit, as well as the star-shaped quantum circuit. The optimal compilation of the sub-circuits of the structured quantum circuit enables the width of the compiled quantum circuit to be minimized, that is, a star-structured quantum circuit or the sub-circuit of a star-structured quantum circuit can be compiled into its equivalent A dynamic quantum circuit with the minimum number of qubits required can simplify the classical simulation and real-machine operation of star-structured quantum circuits and sub-circuits of star-structured quantum circuits.

应当理解,本部分所描述的内容并非旨在标识本公开的实施例的关键或重要特征,也不用于限制本公开的范围。本公开的其它特征将通过以下的说明书而变得容易理解。It should be understood that what is described in this section is not intended to identify key or important features of the embodiments of the disclosure, nor is it intended to limit the scope of the disclosure. Other features of the present disclosure will become readily understood from the following description.

附图说明Description of the drawings

附图用于更好地理解本方案,不构成对本公开的限定。其中:The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. in:

图1是根据本公开第一实施例的量子电路处理方法的流程示意图;Figure 1 is a schematic flowchart of a quantum circuit processing method according to the first embodiment of the present disclosure;

图2是一示例的静态量子电路的结构示意图;Figure 2 is a schematic structural diagram of an example static quantum circuit;

图3是另一示例的静态量子电路的结构示意图;Figure 3 is a schematic structural diagram of another example of a static quantum circuit;

图4是图3所示量子电路编译得到的动态量子电路的结构示意图;Figure 4 is a schematic structural diagram of a dynamic quantum circuit obtained by compiling the quantum circuit shown in Figure 3;

图5是一示例的星型结构的量子电路的结构示意图;Figure 5 is a schematic structural diagram of an example of a star-structured quantum circuit;

图6是另一示例的星型结构的量子电路的结构示意图;Figure 6 is a schematic structural diagram of another example of a star-structured quantum circuit;

图7是一示例的星型结构的量子电路的子电路的结构示意图;Figure 7 is a schematic structural diagram of a sub-circuit of a star-structured quantum circuit;

图8是图6所示量子电路编译得到的动态量子电路的结构示意图;Figure 8 is a schematic structural diagram of a dynamic quantum circuit obtained by compiling the quantum circuit shown in Figure 6;

图9是根据本公开第二实施例的量子电路处理装置的结构示意图;Figure 9 is a schematic structural diagram of a quantum circuit processing device according to a second embodiment of the present disclosure;

图10是用来实施本公开的实施例的示例电子设备的示意性框图。Figure 10 is a schematic block diagram of an example electronic device used to implement embodiments of the present disclosure.

具体实施方式Detailed ways

以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本公开的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the present disclosure are included to facilitate understanding and should be considered to be exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the disclosure. Also, descriptions of well-known functions and constructions are omitted from the following description for clarity and conciseness.

第一实施例First embodiment

如图1所示,本公开提供一种量子电路处理方法,包括如下步骤:As shown in Figure 1, the present disclosure provides a quantum circuit processing method, which includes the following steps:

步骤S101:获取包括N个量子比特的第一量子电路的第一指令列表,所述第一量子电路为:星型结构的量子电路或星型结构的量子电路的子电路,所述星型结构的量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特有序排列,所述星型结构中,按照量子位从小到大的顺序分别在每个第一量子比特与目标量子比特之间作用双量子比特门,所述目标量子比特为所述N个量子比特之间任一量子比特,所述第一量子比特为所述N个量子比特中除所述目标量子比特的其他量子比特,所述子电路为从星型结构的量子电路的指令列表中删除部分操作指令所获得的量子电路,N为大于2的整数。Step S101: Obtain the first instruction list of the first quantum circuit including N qubits. The first quantum circuit is: a star-structured quantum circuit or a sub-circuit of a star-structured quantum circuit. The star-shaped structure The N qubits in the quantum circuit are arranged in order from the qubits of qubit 0 to the qubits of qubit N-1. In the star structure, each first qubit is placed in the order of qubits from small to large. A two-qubit gate acts between a qubit and a target qubit, the target qubit is any qubit among the N qubits, and the first qubit is any one of the N qubits. Other qubits of the target qubit, the sub-circuit is a quantum circuit obtained by deleting some operation instructions from the instruction list of the star-structured quantum circuit, and N is an integer greater than 2.

本实施例中,量子电路处理方法涉及量子计算技术领域,尤其涉及量子电路技术领域,其可以广泛应用于星型结构的量子电路,以及星型结构的量子电路的子电路的经典模拟和真机运行场景下。本公开实施例的量子电路处理方法,可以由本公开实施例的量子电路处理装置执行。本公开实施例的量子电路处理装置可以配置在任意电子设备中,以执行本公开实施例的量子电路处理方法。In this embodiment, the quantum circuit processing method relates to the field of quantum computing technology, especially to the field of quantum circuit technology. It can be widely used in the classical simulation and real machine of star-structured quantum circuits, as well as the sub-circuits of star-structured quantum circuits. operating scenario. The quantum circuit processing method of the embodiment of the present disclosure can be executed by the quantum circuit processing device of the embodiment of the present disclosure. The quantum circuit processing device according to the embodiment of the present disclosure can be configured in any electronic device to execute the quantum circuit processing method according to the embodiment of the present disclosure.

目前,较为主流的量子计算实现方式基于量子电路模型,即通过在量子比特上作用一系列的量子门完成量子态的演化,并在电路末端进行量子测量以获取计算结果。当前业界常用的量子电路是静态量子电路,即仅在电路末端包含测量操作的量子电路。Currently, the more mainstream implementation of quantum computing is based on the quantum circuit model, which uses a series of quantum gates on qubits to complete the evolution of the quantum state, and performs quantum measurements at the end of the circuit to obtain the calculation results. The currently commonly used quantum circuits in the industry are static quantum circuits, that is, quantum circuits that only contain measurement operations at the end of the circuit.

随着近期硬件方向的快速发展(主要是量子比特相干时间的显著提升,以及高保真度中间态测量与重置操作的实现),包含量子电路中间测量以及重置操作的动态量子电路越来越受到业界的重视。由于引入了电路的中间测量,动态量子电路可以在量子比特的相干时间内,将量子计算和实时的经典计算与通信有效的结合起来。这一特性使得通过量子电路模型可以实现的计算任务的多样性大大增加。例如,利用动态量子电路的中间测量,可以在电路运行中实现前反馈操作,即根据中间测量获得的结果决定接下来要作用什么量子门,亦或抛弃当前的计算结果,重新开始计算任务。这样的功能在量子纠错与容错量子计算中是非常重要的。因此可以预见的是,动态量子电路在未来将会成为各类量子算法以及量子应用的重要组成部分。With the recent rapid development of hardware (mainly the significant improvement of qubit coherence time and the realization of high-fidelity intermediate state measurement and reset operations), dynamic quantum circuits including quantum circuit intermediate measurements and reset operations are becoming more and more popular. Attracted by the industry. Due to the introduction of intermediate measurements in the circuit, dynamic quantum circuits can effectively combine quantum computing and real-time classical computing and communication within the coherence time of the qubit. This property greatly increases the diversity of computational tasks that can be achieved through quantum circuit models. For example, using intermediate measurements of dynamic quantum circuits, forward feedback operations can be implemented during circuit operation, that is, deciding which quantum gates to operate next based on the results obtained from intermediate measurements, or discarding the current calculation results and restarting the calculation task. Such functions are very important in quantum error correction and error-tolerant quantum computing. Therefore, it is foreseeable that dynamic quantum circuits will become an important part of various quantum algorithms and quantum applications in the future.

由于动态量子电路中的量子比特可以被重置并在后续计算过程中继续被使用,因此与静态量子电路相比,在运行相同的量子算法的情况下,动态量子电路可以有效地减少计算任务所需的量子比特数,且理论上计算能力不受任何影响。例如在静态电路中需要n量子比特的Berstein-Vazirani算法,在动态量子电路仅需2个量子比特即可实现。Because qubits in dynamic quantum circuits can be reset and continue to be used during subsequent calculations, dynamic quantum circuits can effectively reduce the computational tasks required to run the same quantum algorithm compared to static quantum circuits. The required number of qubits, and theoretically the computing power will not be affected in any way. For example, the Berstein-Vazirani algorithm that requires n qubits in a static circuit can be implemented with only 2 qubits in a dynamic quantum circuit.

受计算机内存和处理器能力的限制,现有的量子电路模拟方式最多能支持模拟几十个量子比特的算法。比如,笔记本能模拟20-30个左右的量子比特,大型超级计算机和集群可以最多模拟30-40个左右的量子比特。在真机运行上,由于当前量子芯片的可扩展性问题尚未解决,导致量子计算机能提供的量子比特数非常有限。因此,量子电路优化是量子计算领域中的一个基本问题。Limited by computer memory and processor capabilities, existing quantum circuit simulation methods can support algorithms that simulate dozens of qubits at most. For example, a laptop can simulate about 20-30 qubits, and large supercomputers and clusters can simulate up to about 30-40 qubits. In terms of real machine operation, due to the unresolved scalability problem of current quantum chips, the number of qubits that quantum computers can provide is very limited. Therefore, quantum circuit optimization is a fundamental problem in the field of quantum computing.

量子电路优化是通过一定的技术手段,可以将给定的量子电路进行等效编译为动态量子电路,以减少量子比特数,这样可以降低其经典模拟和真机运行的要求,加速量子算法的研究和量子计算在实际场景下的落地。Quantum circuit optimization uses certain technical means to equivalently compile a given quantum circuit into a dynamic quantum circuit to reduce the number of qubits. This can reduce the requirements for its classical simulation and real machine operation, and accelerate the research of quantum algorithms. and the implementation of quantum computing in practical scenarios.

本实施例中通过对星型结构的量子电路或星型结构的量子电路的子电路进行编译,可以在量子比特数上对原量子电路进行大量简化。一方面,可以进一步提升量子算法经典模拟的规模,加强经典计算机对量子算法的验证能力,另一方面,也可以降低量子算法在真机运行上的比特数要求,弥补当前量子芯片可扩展性问题的不足。对星型结构的量子电路,以及星型结构的量子电路的子电路在量子算法如Deutsch-Jozsa算法和Bernstein-Vazirani算法等的使用场景中非常重要。In this embodiment, by compiling the star-structured quantum circuit or the sub-circuits of the star-structured quantum circuit, the original quantum circuit can be greatly simplified in terms of the number of qubits. On the one hand, it can further increase the scale of classical simulations of quantum algorithms and strengthen the ability of classical computers to verify quantum algorithms. On the other hand, it can also reduce the number of bits required for quantum algorithms to run on real machines and make up for the scalability issues of current quantum chips. shortcomings. Star-structured quantum circuits and sub-circuits of star-structured quantum circuits are very important in the use scenarios of quantum algorithms such as the Deutsch-Jozsa algorithm and the Bernstein-Vazirani algorithm.

以下详细介绍量子电路模型。The quantum circuit model is described in detail below.

目前,量子计算实现方式可以基于量子电路模型,即通过在量子比特上作用一系列的量子门完成量子态的演化,并在电路末端进行量子测量以获取计算结果。量子电路图可以表示了量子电路模型计算的全部过程。At present, the implementation of quantum computing can be based on the quantum circuit model, that is, by applying a series of quantum gates on qubits to complete the evolution of the quantum state, and perform quantum measurements at the end of the circuit to obtain the calculation results. The quantum circuit diagram can represent the entire process of quantum circuit model calculation.

图2是一示例的量子电路的结构示意图,如图2所示,可以用一根水平线表示一个量子比特系统,从上至下依次对量子比特的量子位进行标号,其中,量子位的标号往往从零开始。Figure 2 is a schematic structural diagram of an example quantum circuit. As shown in Figure 2, a horizontal line can be used to represent a qubit system, and the qubits of the qubit are numbered from top to bottom. Among them, the qubits are often numbered. Start from scratch.

量子电路图中时间演化的方向从左到右,最左端为初始的量子态,其中,通常每个量子比特初始化为零态,之后对初始态依次作用不同的量子门操作以完成量子态的演化。同时可以对某些量子位进行量子测量,获得测量结果。The direction of time evolution in the quantum circuit diagram is from left to right, with the initial quantum state at the far left end. Usually each qubit is initialized to the zero state, and then different quantum gate operations are applied to the initial state in sequence to complete the evolution of the quantum state. At the same time, quantum measurements can be performed on certain qubits to obtain measurement results.

如果一个量子电路中不包含重置、中间量子测量等操作,且所有测量操作都位于量子电路的最末端,则此类量子电路称为静态量子电路,如图2所示的量子电路即为静态量子电路。If a quantum circuit does not include operations such as reset and intermediate quantum measurement, and all measurement operations are located at the end of the quantum circuit, then this type of quantum circuit is called a static quantum circuit. The quantum circuit shown in Figure 2 is static. Quantum circuits.

量子电路图中的操作通常可以按照作用顺序用一个有序的指令列表进行表示,指令列表中每个元素代表一个操作指令。The operations in a quantum circuit diagram can usually be represented by an ordered instruction list in the order of action, with each element in the instruction list representing an operation instruction.

每一个量子态制备(或初始化)操作表示为一个包含四个元素的指令[Reset,qubit,None,None]。例如,[Reset,2,None,None]表示将量子位2的量子比特初始化为零态。Each quantum state preparation (or initialization) operation is expressed as an instruction containing four elements [Reset, qubit, None, None]. For example, [Reset,2,None,None] means initializing the qubit of qubit 2 to the zero state.

每一个单比特量子门(如H,X,Y,Z,S,T,Rx,Ry,Rz等)表示为一个包含四个元素的操作指令[name,qubit,parameter,condition],其中name为量子门的名称,qubit为量子门作用的量子位,parameter为量子门的参数(如没有参数则默认为None),condition表示该量子门操作受哪一个量子位测量结果的控制(标准量子电路中该参数默认为None)。例如,[Rx,2,pi,None]表示对量子位2上的量子比特作用一个Rx旋转门,旋转角度为pi。Each single-bit quantum gate (such as H, The name of the quantum gate, qubit is the qubit that the quantum gate acts on, parameter is the parameter of the quantum gate (if there is no parameter, the default is None), condition indicates which qubit measurement result controls the quantum gate operation (in standard quantum circuits This parameter defaults to None). For example, [Rx, 2, pi, None] means applying an Rx rotating gate to the qubit on qubit 2, and the rotation angle is pi.

每一个双比特量子门(如控制非门CNOT,SWAP门)表示为一个包含四个元素的指令[name,qubit,parameter,condition]。其中,name为量子门的名称,qubit为控制位和受控位构成的列表,parameter为量子门的参数(如没有参数则默认为None),标准量子电路中condition参数默认为None。例如,[SWAP,[1,2],None,None]表示在量子位1和2之间作用SWAP门;[CNOT,[1,3],None,None]表示对量子位1和量子位3作用控制非门,其中量子位1为控制位,量子位3为受控位。Each two-bit quantum gate (such as the controlled NOT gate CNOT, SWAP gate) is represented by an instruction containing four elements [name, qubit, parameter, condition]. Among them, name is the name of the quantum gate, qubit is a list of control bits and controlled bits, parameter is the parameter of the quantum gate (if there is no parameter, it defaults to None), and the condition parameter in a standard quantum circuit defaults to None. For example, [SWAP, [1,2], None, None] means operating the SWAP gate between qubit 1 and 2; [CNOT, [1,3], None, None] means operating the SWAP gate between qubit 1 and qubit 3. The action controls the NOT gate, where qubit 1 is the control bit and qubit 3 is the controlled bit.

更为一般的,每一个多量子比特门(例如CCX门)表示为一个包含四个元素的指令[name,qubit,parameter,condition]。其中,name为量子门的名称,qubit为该多量子比特门作用的量子位构成的列表,parameter为量子门的参数(如没有参数则默认为None),condition表示该量子门操作受哪一个量子位测量结果的控制(如果没有参数则默认为None)。More generally, each multi-qubit gate (such as a CCX gate) is represented as an instruction containing four elements [name, qubit, parameter, condition]. Among them, name is the name of the quantum gate, qubit is a list of qubits acted on by the multi-qubit gate, parameter is the parameter of the quantum gate (if there is no parameter, the default is None), and condition indicates which quantum gate the quantum gate operation is affected by. Control of the bit measurement result (defaults to None if there are no parameters).

每一个计算基下的测量表示为一个包含四个元素的指令[measure,qubit,None,None]。例如,[measure,2,None,None]表示对量子位2进行计算基下的测量。Each measurement under the calculation basis is represented as an instruction containing four elements [measure, qubit, None, None]. For example, [measure, 2, None, None] represents the measurement of the computational basis for qubit 2.

按照如上的指令表示规则,图2中的静态量子电路可以表示为如下的有序指令列表:static_circuit=[[Reset,0,None,None],[Reset,1,None,None],[Reset,2,None,None],[H,0,None,None],[H,1,None,None],[H,2,None,None],[CNOT,[0,1],None,None],[SWAP,[1,2],None,None],[Rx,0,α,None],[Ry,1,β,None],[Rz,2,γ,None],[Measure,0,None,None],[Measure,1,None,None],[Measure,2,None,None]]。According to the above instruction representation rules, the static quantum circuit in Figure 2 can be represented as the following ordered instruction list: static_circuit=[[Reset,0,None,None],[Reset,1,None,None],[Reset, 2,None,None],[H,0,None,None],[H,1,None,None],[H,2,None,None],[CNOT,[0,1],None,None] ,[SWAP,[1,2],None,None],[Rx,0,α,None],[Ry,1,β,None],[Rz,2,γ,None],[Measure,0, None,None],[Measure,1,None,None],[Measure,2,None,None]].

在一些应用场景中,可以允许在量子电路的中间对某些量子比特进行测量,并在测量获得结果后将这些量子比特重置为|0>态,以供后续计算继续使用。而包含了电路中间测量以及重置操作的量子电路称为动态量子电路。In some application scenarios, it is possible to measure certain qubits in the middle of a quantum circuit, and after the measurement results are obtained, these qubits are reset to the |0> state for continued use in subsequent calculations. Quantum circuits that include intermediate measurement and reset operations in the circuit are called dynamic quantum circuits.

可以通过量子电路优化将静态量子电路编译为动态量子电路,例如可以将图3所示的静态量子电路等效编译为图4所示的动态量子电路,可以看到,该动态量子电路相对于原静态量子电路,其量子比特数减少了一个,但两个量子电路的运行效果等价。Static quantum circuits can be compiled into dynamic quantum circuits through quantum circuit optimization. For example, the static quantum circuit shown in Figure 3 can be equivalently compiled into the dynamic quantum circuit shown in Figure 4. It can be seen that this dynamic quantum circuit is better than the original quantum circuit. For static quantum circuits, the number of qubits is reduced by one, but the operating effects of the two quantum circuits are equivalent.

原静态量子电路的指令列表为:static_circuit=[[Reset,0,None,None],[Reset,1,None,None],[Reset,2,None,None],[H,0,None,None],[H,1,None,None],[H,2,None,None],[CNOT,[0,1],None,None],[CNOT,[1,2],None,None],[Measure,0,None,None],[Measure,1,None,None],[Measure,2,None,None]]。编译后的动态量子电路的指令列表为:dynamic_circuit=[[Reset,0,None,None],[Reset,1,None,None],[H,0,None,None],[H,1,None,None],[CNOT,[0,1],None,None],[Measure,0,None,None],[Reset,0,None,None],[H,0,None,None],[CNOT,[1,0],None,None],[Measure,0,None,None],[Measure,1,None,None]]。The instruction list of the original static quantum circuit is: static_circuit=[[Reset,0,None,None],[Reset,1,None,None],[Reset,2,None,None],[H,0,None,None ],[H,1,None,None],[H,2,None,None],[CNOT,[0,1],None,None],[CNOT,[1,2],None,None], [Measure,0,None,None],[Measure,1,None,None],[Measure,2,None,None]]. The instruction list of the compiled dynamic quantum circuit is: dynamic_circuit=[[Reset,0,None,None],[Reset,1,None,None],[H,0,None,None],[H,1,None ,None],[CNOT,[0,1],None,None],[Measure,0,None,None],[Reset,0,None,None],[H,0,None,None],[CNOT ,[1,0],None,None],[Measure,0,None,None],[Measure,1,None,None]].

本实施例的目的是将一个给定的静态量子电路编译成其等价的动态量子电路,并且使得编译后的量子电路所需的量子比特数最少。The purpose of this embodiment is to compile a given static quantum circuit into its equivalent dynamic quantum circuit, and to minimize the number of qubits required for the compiled quantum circuit.

在步骤S101中,第一量子电路可以为静态量子电路,第一量子电路为星型结构的量子电路或星型结构的量子电路的子电路。星型结构的量子电路是量子算法如Deutsch-Jozsa算法和Bernstein-Vazirani算法等中广泛使用的一种量子电路。In step S101, the first quantum circuit may be a static quantum circuit, and the first quantum circuit may be a star-structured quantum circuit or a sub-circuit of a star-structured quantum circuit. The star-structured quantum circuit is a type of quantum circuit widely used in quantum algorithms such as the Deutsch-Jozsa algorithm and the Bernstein-Vazirani algorithm.

星型结构的量子电路的连接性有一个统一公共的量子比特即目标量子比特,如量子位N-1的量子比特即最后一个量子比特,其余所有量子比特按照量子位从小到大的顺序,分别与该目标量子比特之间作用双量子比特门,其对应的拓扑结构为星状结构,称之为星型结构。其中,双量子比特门可以为CNOT门,也可以为SWAP门,或者其他双量子比特门。The connectivity of the star-structured quantum circuit has a unified common qubit, which is the target qubit. For example, the qubit of qubit N-1 is the last qubit, and all the other qubits are arranged in order from small to large qubits. A two-qubit gate acts on the target qubit, and its corresponding topological structure is a star-shaped structure, which is called a star structure. Among them, the double qubit gate can be a CNOT gate, a SWAP gate, or other double qubit gates.

图5是一示例的星型结构的量子电路的结构示意图,如图5所示,该星型结构的量子电路中包含4个量子比特,将最后一个量子比特作为目标量子比特,量子位0的量子比特、量子位1的量子比特以及量子位2的量子比特,依次与量子位3的量子比特之间作用双量子比特门。Figure 5 is a schematic structural diagram of an example of a star-structured quantum circuit. As shown in Figure 5, the star-structured quantum circuit contains 4 qubits. The last qubit is used as the target qubit, and qubit 0 is The qubits, the qubits of qubit 1 and the qubits of qubit 2, in turn interact with the qubit of qubit 3 through double qubit gates.

可以获取预先存储的第一量子电路的第一指令列表,也可以获取用户输入的第一量子电路的第一指令列表,还可以基于与第一量子电路等效的第三量子电路的指令列表,获取第一量子电路的第一指令列表,这里不进行具体限定。The pre-stored first instruction list of the first quantum circuit may be obtained, the first instruction list of the first quantum circuit input by the user may be obtained, or the instruction list of the third quantum circuit equivalent to the first quantum circuit may be obtained, Obtain the first instruction list of the first quantum circuit, which is not specifically limited here.

图5中的量子电路的指令列表为:static_circuit=[[Reset,0,None,None],[Reset,1,None,None],[Reset,2,None,None],[Reset,3,None,None],[CNOT,[0,3],None,None],[CNOT,[1,3],None,None],[CNOT,[2,3],None,None],[Measure,0,None,None],[Measure,1,None,None],[Measure,2,None,None],[Measure,3,None,None]。The instruction list of the quantum circuit in Figure 5 is: static_circuit=[[Reset,0,None,None],[Reset,1,None,None],[Reset,2,None,None],[Reset,3,None ,None],[CNOT,[0,3],None,None],[CNOT,[1,3],None,None],[CNOT,[2,3],None,None],[Measure,0 ,None,None],[Measure,1,None,None],[Measure,2,None,None],[Measure,3,None,None].

另外,在第一量子电路为星型结构的量子电路的子电路的情况下,第一量子电路的第一指令列表也可以基于星型结构的量子电路的指令列表确定,其是星型结构的量子电路的有序子集合,即从星型结构的量子电路的指令列表中删除部分操作指令,得到第一指令列表。In addition, when the first quantum circuit is a sub-circuit of a star-structured quantum circuit, the first instruction list of the first quantum circuit can also be determined based on the instruction list of the star-structured quantum circuit, which is a star-structured An ordered subset of the quantum circuit, that is, deleting some operation instructions from the instruction list of the star-structured quantum circuit to obtain the first instruction list.

步骤S102:基于所述第一指令列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表;其中,所述第二量子电路的量子比特数量小于所述第一量子电路的量子比特数量,所述等效编译包括:在所述第一指令列表中第一测量操作指令之后添加第一重置操作指令;并将所述第一指令列表中每个目标操作指令重新映射到量子位i的量子比特上,所述第一测量操作指令和所述第一重置操作指令均作用在量子位i上,所述目标操作指令作用在量子位i+1上,i的取值范围为[0,N-3]。Step S102: Based on the first instruction list, equivalently compile the first quantum circuit to obtain a second instruction list of the second quantum circuit that is equivalent to the first quantum circuit; wherein, the second The number of qubits of the quantum circuit is less than the number of qubits of the first quantum circuit, and the equivalent compilation includes: adding a first reset operation instruction after the first measurement operation instruction in the first instruction list; and Each target operation instruction in the first instruction list is remapped to a qubit of qubit i. The first measurement operation instruction and the first reset operation instruction both act on qubit i. The target operation The instruction acts on qubit i+1, and the value range of i is [0, N-3].

该步骤中,第二量子电路可以为动态量子电路。In this step, the second quantum circuit may be a dynamic quantum circuit.

在进行等效编译时,可以依次获取第一指令列表中的第一测量操作指令,并针对每个第一测量操作指令,基于第一测量操作指令所作用的量子位i,在第一测量操作指令之后添加该量子位i上的第一重置操作指令,并将第一指令列表中每个目标操作指令重新映射到量子位i的量子比特上。第一测量操作指令分别为作用在量子位0、量子位1…、量子位N-3上的测量操作指令。When performing equivalent compilation, the first measurement operation instructions in the first instruction list can be obtained in sequence, and for each first measurement operation instruction, based on the qubit i acted on by the first measurement operation instruction, in the first measurement operation After the instruction, add the first reset operation instruction on the qubit i, and remap each target operation instruction in the first instruction list to the qubit of the qubit i. The first measurement operation instructions are measurement operation instructions acting on qubit 0, qubit 1..., and qubit N-3 respectively.

若N为3,则第一测量操作指令为作用在量子位0上的测量操作指令。也即等效编译时,在量子位0上的测量操作指令之后添加量子位0上的重置操作指令,并将第一指令列表中作用在量子位1上的目标操作指令重新映射,将其映射到量子位0的量子比特上,从而得到与第一量子电路等效的第二量子电路的第二指令列表。If N is 3, the first measurement operation instruction is a measurement operation instruction acting on qubit 0. That is, during equivalent compilation, add the reset operation instruction on qubit 0 after the measurement operation instruction on qubit 0, and remap the target operation instruction acting on qubit 1 in the first instruction list to Map to the qubit of qubit 0, thereby obtaining the second instruction list of the second quantum circuit that is equivalent to the first quantum circuit.

若N为4,则第一测量操作指令分别为作用在量子位0和量子位1上的测量操作指令。也即等效编译时,先针对量子位0上的测量操作指令,在量子位0上的测量操作指令之后添加量子位0上的重置操作指令,并将第一指令列表中作用在量子位1上的目标操作指令重新映射,将其映射到量子位0的量子比特上。之后针对量子位1上的测量操作指令,在量子位1上的测量操作指令之后添加量子位1上的重置操作指令,并将第一指令列表中作用在量子位2上的目标操作指令重新映射,将其映射到量子位1的量子比特上,从而可以得到与第一量子电路等效的第二量子电路的第二指令列表。If N is 4, the first measurement operation instructions are measurement operation instructions acting on qubit 0 and qubit 1 respectively. That is to say, during equivalent compilation, first target the measurement operation instruction on qubit 0, add the reset operation instruction on qubit 0 after the measurement operation instruction on qubit 0, and apply the first instruction list to the qubit. The target operation instruction on qubit 1 is remapped to the qubit of qubit 0. Then, for the measurement operation instruction on qubit 1, add the reset operation instruction on qubit 1 after the measurement operation instruction on qubit 1, and reset the target operation instruction acting on qubit 2 in the first instruction list. Mapping, mapping it to the qubit of qubit 1, so that the second instruction list of the second quantum circuit equivalent to the first quantum circuit can be obtained.

这样,在将量子测量操作的操作指令等效编译后,可以在量子测量操作的操作指令之后添加重置操作的操作指令,通过重置操作指令,可以将分配给量子位i的寄存单元进行回收,以供量子位i+1的量子比特继续使用,以减少编译得到的第二量子电路的量子比特数。In this way, after equivalent compilation of the operation instructions of the quantum measurement operation, the operation instructions of the reset operation can be added after the operation instructions of the quantum measurement operation. Through the reset operation instructions, the register unit allocated to qubit i can be recycled , for the qubit of qubit i+1 to continue to be used to reduce the number of qubits of the compiled second quantum circuit.

在一可选实施方式中,可以基于第一指令列表直接进行第一量子电路的等效编译,即通过对第一指令列表的遍历,分别获取第一测量操作指令和目标操作指令,并执行第一量子电路的等效编译。在另一可选实施方式中,可以基于第一指令列表构建有向无环图,基于有向无环图来进行第一量子电路的等效编译。In an optional implementation, equivalent compilation of the first quantum circuit can be directly performed based on the first instruction list, that is, by traversing the first instruction list, the first measurement operation instruction and the target operation instruction are respectively obtained, and the first measurement operation instruction and the target operation instruction are executed. An equivalent compilation of a quantum circuit. In another optional implementation, a directed acyclic graph can be constructed based on the first instruction list, and equivalent compilation of the first quantum circuit can be performed based on the directed acyclic graph.

相关技术中,通常是采用启发式算法进行量子电路编译,无法保证电路编译的最优性,若通过电路编译的数学建模给出了最优编译方案,然而算法复杂度随量子比特数指数增长,对较大规模的电路编译效率非常低。而本实施例中,针对星型结构的量子电路的结构特殊性,可以将量子位i的量子比特测量之后进行重置,将所有作用在量子位i+1的量子比特上的操作指令重新映射到量子位i的量子比特上进行执行,该规则由基于电路结构的理论证明所得。In related technologies, heuristic algorithms are usually used for quantum circuit compilation, which cannot guarantee the optimality of circuit compilation. If the optimal compilation solution is given through mathematical modeling of circuit compilation, however, the complexity of the algorithm increases exponentially with the number of qubits. , the compilation efficiency for larger-scale circuits is very low. In this embodiment, due to the structural particularity of the star-structured quantum circuit, the qubit of qubit i can be reset after measurement, and all operating instructions acting on the qubit of qubit i+1 can be remapped. To execute on the qubit of qubit i, this rule is proved theoretically based on the circuit structure.

在时间复杂度上,本实施例由于无需构建复杂的数学模型,因此编译过程简单,且运行时间可以随N线性增长,编译非常高效。在编译效果上,编译出来的动态量子电路将会只需要2个量子比特。可以理论证明,本实施例中编译方案是最优的编译方案,也就是说不可能存在一种编译方案,使得编译出来的电路宽度比2更少。如此,本实施例提供了一种星型结构的量子电路以及星型结构的量子电路的子电路的最优编译方式,可直接应用于相应场景之中,无需复杂的计算和优化。In terms of time complexity, this embodiment does not require the construction of a complex mathematical model, so the compilation process is simple, and the running time can grow linearly with N, making the compilation very efficient. In terms of compilation effect, the compiled dynamic quantum circuit will only require 2 qubits. It can be theoretically proven that the compilation scheme in this embodiment is the optimal compilation scheme, which means that there is no compilation scheme that makes the compiled circuit width less than 2. In this way, this embodiment provides an optimal compilation method for a star-structured quantum circuit and the sub-circuits of a star-structured quantum circuit, which can be directly applied to corresponding scenarios without the need for complex calculations and optimizations.

并且,基于不同架构设计的量子计算机,其所能提供的量子比特数与各类操作的实现能力也不同。通过等效编译,可以使得量子电路在真实量子计算机上的运行方案更为灵活,可以根据实际的硬件条件,在动态量子电路和静态量子电路之间灵活地进行选择。例如,对于相干时间较短,但易于扩展量子比特数的超导量子计算机,更适合运行宽度较大、深度较小的静态量子电路;而对于相干时间较长,但扩展性相对较差的基于离子阱架构的量子计算机,则更适合运行宽度较小、深度较大的动态量子电路。Moreover, quantum computers designed based on different architectures also have different numbers of qubits and capabilities in realizing various operations. Through equivalent compilation, the operation scheme of quantum circuits on real quantum computers can be made more flexible, and one can flexibly choose between dynamic quantum circuits and static quantum circuits according to actual hardware conditions. For example, superconducting quantum computers with short coherence time but easy expansion of the number of qubits are more suitable for running static quantum circuits with larger width and smaller depth; while for superconducting quantum computers with long coherence time but relatively poor scalability, they are more suitable for running static quantum circuits with larger width and smaller depth. Quantum computers with ion trap architecture are more suitable for running dynamic quantum circuits with smaller width and larger depth.

可选的,所述第一量子电路中还包括至少一个单量子比特门,所述单量子比特门位于所述第一量子电路的任意位置。Optionally, the first quantum circuit also includes at least one single qubit gate, and the single qubit gate is located at any position of the first quantum circuit.

本实施例中的等效编译过程与单量子比特门的个数、种类、具体执行位置等信息无关,因此,本实施例中的第一量子电路在保证其是星型结构,或其是星型结构的量子电路的子电路的情况下,还可以包括单量子比特门。The equivalent compilation process in this embodiment has nothing to do with the number, type, specific execution position and other information of single qubit gates. Therefore, the first quantum circuit in this embodiment ensures that it is a star structure, or that it is a star structure. In the case of a sub-circuit of a quantum circuit with a type structure, a single qubit gate may also be included.

图6是另一示例的星型结构的量子电路的结构示意图,如图6所示,可以在图5所示的量子电路的任意位置添加单量子比特门,或者可以将CNOT门替换成其他双量子比特门。只要量子电路的双量子比特门满足星型结构,则该量子电路即为星型结构的量子电路。Figure 6 is a schematic structural diagram of another example of a star-structured quantum circuit. As shown in Figure 6, a single qubit gate can be added at any position of the quantum circuit shown in Figure 5, or the CNOT gate can be replaced with another double qubit gate. Qubit gate. As long as the two-qubit gate of a quantum circuit satisfies the star structure, the quantum circuit is a star-structured quantum circuit.

对于图6所示的星型结构的量子电路,其指令列表为static_circuit=[[Reset,0,None,None],[Reset,1,None,None],[Reset,2,None,None],[Reset,3,None,None],[H,0,None,None],[S,1,None,None],[T,2,None,None],[H,3,None,None],[CNOT,[0,3],None,None],[Z,1,None,None],[CNOT,[1,3],None,None],[CNOT,[2,3],None,None],[Rx,0,0.5,None],[Rz,1,0.1,None],[Measure,0,None,None],[Measure,1,None,None],[Measure,2,None,None],[Measure,3,None,None]]。For the star structure quantum circuit shown in Figure 6, the instruction list is static_circuit=[[Reset,0,None,None],[Reset,1,None,None],[Reset,2,None,None], [Reset,3,None,None],[H,0,None,None],[S,1,None,None],[T,2,None,None],[H,3,None,None], [CNOT,[0,3],None,None],[Z,1,None,None],[CNOT,[1,3],None,None],[CNOT,[2,3],None,None ],[Rx,0,0.5,None],[Rz,1,0.1,None],[Measure,0,None,None],[Measure,1,None,None],[Measure,2,None,None ],[Measure,3,None,None]].

图7是一示例的星型结构的量子电路的子电路的结构示意图,如图7所示,其是在图6的基础上删除部分双量子比特门的操作指令得到的量子电路。FIG. 7 is a schematic structural diagram of a sub-circuit of an example star-structured quantum circuit. As shown in FIG. 7 , it is a quantum circuit obtained by deleting some operating instructions of a two-qubit gate on the basis of FIG. 6 .

如此,可以扩大量子电路处理的原量子电路的适用范围。In this way, the applicable scope of original quantum circuits processed by quantum circuits can be expanded.

可选的,所述步骤S102具体包括:Optionally, step S102 specifically includes:

基于所述第一指令列表,确定第一有向无环图,所述第一有向无环图包括所述第一指令列表中操作指令对应的节点和第一有向边,所述第一有向边用于表征所述第一指令列表中不同操作指令间的时序关系;Based on the first instruction list, a first directed acyclic graph is determined, the first directed acyclic graph includes nodes corresponding to the operation instructions in the first instruction list and first directed edges, and the first directed acyclic graph Directed edges are used to characterize the timing relationship between different operation instructions in the first instruction list;

在所述第一有向无环图中添加第二有向边,得到第二有向无环图和所述第二有向边构成的有向边列表,所述第二有向边包括所述第一测量操作指令对应输出节点至第二重置操作指令对应输入节点的有向边,所述第二重置操作指令为作用在量子位i+1上的重置操作指令;Add a second directed edge to the first directed acyclic graph to obtain a directed edge list composed of the second directed acyclic graph and the second directed edge, where the second directed edge includes all The first measurement operation instruction corresponds to the directed edge from the output node to the second reset operation instruction corresponding to the input node, and the second reset operation instruction is a reset operation instruction acting on qubit i+1;

基于所述第二有向无环图和所述有向边列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表。Based on the second directed acyclic graph and the directed edge list, the first quantum circuit is equivalently compiled to obtain a second instruction list of the second quantum circuit equivalent to the first quantum circuit. .

在一可选实施方式中,可以对第一指令列表按照从左至右的指令排列顺序进行遍历,并通过查找所作用的量子位与当前遍历的操作指令所作用的量子位存在交集的最近邻操作指令来构建第一有向无环图。In an optional implementation, the first instruction list can be traversed in the order of instructions from left to right, and the nearest neighbor of the intersection between the qubit acted on and the qubit acted upon by the currently traversed operation instruction is searched. Operate instructions to construct the first directed acyclic graph.

在另一可选实施方式中,可选的,所述基于所述第一指令列表,确定第一有向无环图,包括:In another optional implementation, optionally, determining the first directed acyclic graph based on the first instruction list includes:

对所述第一指令列表按照操作指令的排列顺序进行遍历;Traverse the first instruction list in the order in which the operation instructions are arranged;

将当前遍历的操作指令作为节点,并在目标列表不为空列表的情况下,添加所述目标列表中位于末尾的操作指令对应节点至当前遍历的操作指令对应节点的第一有向边;所述目标列表为当前遍历的操作指令所作用的量子位对应的列表;Use the currently traversed operation instruction as a node, and if the target list is not an empty list, add the operation instruction corresponding node at the end of the target list to the first directed edge of the currently traversed operation instruction corresponding node; so The target list is a list corresponding to the qubits acted upon by the currently traversed operation instruction;

将当前遍历的操作指令添加至所述目标列表的末尾,并在所述第一指令列表遍历完成的情况下,得到所述第一有向无环图。The currently traversed operation instructions are added to the end of the target list, and when the traversal of the first instruction list is completed, the first directed acyclic graph is obtained.

也即通过构建N个量子比特一一对应的N个目标列表,来存储当前遍历的操作指令的前序操作指令。基于当前遍历的操作指令所作用的量子位,获取该量子位对应的目标列表,该目标列表中的操作指令所作用的量子位均与当前遍历的操作指令所作用的量子位存在交集。从中选取与其最近邻的操作指令,即目标列表中位于末尾的操作指令,来构建第一有向边。如此,可以简化第一有向无环图的构建过程,实现第一有向无环图的高效构建。That is, by constructing N target lists with one-to-one correspondence of N qubits, the preceding operation instructions of the currently traversed operation instructions are stored. Based on the qubit acted upon by the currently traversed operation instruction, a target list corresponding to the qubit is obtained. The qubits acted upon by the operation instructions in the target list all intersect with the qubits acted upon by the currently traversed operation instruction. Select its nearest neighbor operation instruction, that is, the operation instruction at the end of the target list, to construct the first directed edge. In this way, the construction process of the first directed acyclic graph can be simplified and the efficient construction of the first directed acyclic graph can be achieved.

进一步的,在所述第一有向无环图中添加第二有向边,得到第二有向无环图和所述第二有向边构成的有向边列表,所述第二有向边包括所述第一测量操作指令对应输出节点至第二重置操作指令对应输入节点的有向边,所述第二重置操作指令为作用在量子位i+1上的重置操作指令。比如,若N为3,则第二有向边为作用在量子位0上的测量操作指令对应输出节点至作用在量子位1上的重置操作指令对应输入节点的有向边。又比如,若N为4,则第二有向边包括:作用在量子位0上的测量操作指令对应输出节点至作用在量子位1上的重置操作指令对应输入节点的有向边,以及作用在量子位1上的测量操作指令对应输出节点至作用在量子位2上的重置操作指令对应输入节点的有向边。Further, a second directed edge is added to the first directed acyclic graph to obtain a directed edge list composed of the second directed acyclic graph and the second directed edge. The second directed edge is The edge includes a directed edge from an output node corresponding to the first measurement operation instruction to an input node corresponding to the second reset operation instruction. The second reset operation instruction is a reset operation instruction acting on qubit i+1. For example, if N is 3, the second directed edge is the directed edge from the output node corresponding to the measurement operation instruction acting on qubit 0 to the input node corresponding to the reset operation instruction acting on qubit 1. For another example, if N is 4, the second directed edge includes: the directed edge from the output node corresponding to the measurement operation instruction acting on qubit 0 to the input node corresponding to the reset operation instruction acting on qubit 1, and The directed edge from the measurement operation instruction acting on qubit 1 corresponds to the output node to the reset operation instruction acting on qubit 2 corresponds to the input node.

之后基于第二有向无环图和有向边列表,对第一量子电路进行等效编译,得到与第一量子电路等效的第二量子电路的第二指令列表。可选的,所述基于所述第二有向无环图和所述有向边列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表,包括:Then, based on the second directed acyclic graph and the directed edge list, the first quantum circuit is equivalently compiled to obtain a second instruction list of the second quantum circuit that is equivalent to the first quantum circuit. Optionally, the first quantum circuit is equivalently compiled based on the second directed acyclic graph and the directed edge list to obtain a second quantum circuit equivalent to the first quantum circuit. The second instruction list of the circuit includes:

获取所述第二有向无环图对应的操作指令的拓扑排序,得到第三指令列表;Obtain the topological sorting of the operation instructions corresponding to the second directed acyclic graph and obtain a third instruction list;

针对所述有向边列表中每个所述第二有向边,将所述第三指令列表中所述第二有向边的输入节点所作用的量子位对应的各目标操作指令重新映射到所述第二有向边的输出节点所作用的量子位上,以得到所述第二指令列表。For each second directed edge in the directed edge list, remap each target operation instruction corresponding to the qubit acted on by the input node of the second directed edge in the third instruction list to The output node of the second directed edge acts on the qubit to obtain the second instruction list.

第一量子电路的最优编译过程如下:The optimal compilation process of the first quantum circuit is as follows:

输入:第一量子电路的第一指令列表circuit_list,电路宽度N(N>2);Input: circuit_list, the first instruction list of the first quantum circuit, circuit width N (N>2);

输出:编译后的动态量子电路的第二指令列表。Output: The compiled second instruction list of the dynamic quantum circuit.

步骤1:初始化一个空的有向无环图digraph;Step 1: Initialize an empty directed acyclic graph digraph;

步骤2:初始化一个长度为N的目标列表causal_lists,其中每个元素为一个空列表;Step 2: Initialize a target list causal_lists of length N, where each element is an empty list;

步骤3:对circuit_list进行循环,设当前被循环的元素为instruction:Step 3: Loop circuit_list, assuming the currently looped element is instruction:

步骤3.1:取出instruction指令中qubit值,并进行循环,设被循环的元素为q,将instruction作为节点,添加至有向无环图digraph中;查找目标列表causal_lists[q]的最后一个元素,记录为preinstruction;如果preinstruction不为空元素,则向有向无环图digraph中添加第一有向边,从preinstruction指向instruction;将instruction添加至列表causal_lists[q]的最后;Step 3.1: Take out the qubit value in the instruction instruction and perform a loop. Let the element being looped be q. Use instruction as a node and add it to the directed acyclic graph digraph; find the last element of the target list causal_lists[q] and record it. is preinstruction; if preinstruction is not an empty element, add the first directed edge to the directed acyclic graph digraph, pointing from preinstruction to instruction; add instruction to the end of the list causal_lists[q];

步骤4:初始化一个空列表added_edges(即有向边列表);Step 4: Initialize an empty list added_edges (i.e. directed edge list);

步骤5:对变量i∈{0,···,N-3}进行循环:Step 5: Loop over the variables i∈{0,···,N-3}:

步骤5.1:向有向无环图digraph中添加第二有向边,从作用在量子位i上的测量操作指令指向作用在量子位i+1上的重置操作指令,同时将有向边添加至added_edges列表中;Step 5.1: Add a second directed edge to the directed acyclic graph digraph, from the measurement operation instruction acting on qubit i to the reset operation instruction acting on qubit i+1, and add a directed edge at the same time to the added_edges list;

步骤6:根据有向无环图digraph获得所有电路指令的拓扑排序,并记录于circuit_list中;Step 6: Obtain the topological sorting of all circuit instructions based on the directed acyclic graph digraph, and record it in circuit_list;

步骤7:对added_edges列表进行循环,设当前循环的变量为edge:Step 7: Loop through the added_edges list, assuming the variable of the current loop is edge:

步骤7.1:令preinstruction和postinstruction分别表示有向边edge的输出节点和输入节点;Step 7.1: Let preinstruction and postinstruction represent the output node and input node of the directed edge respectively;

步骤7.2:记preinstruction和postinstruction两个操作指令作用的量子位分别为prequbit和postqubit;循环遍历circuit_list列表,将所有作用在量子位postqubit的目标操作指令更新至作用在量子位prequbit上;Step 7.2: Note that the qubits acted upon by the two operation instructions preinstruction and postinstruction are prequbit and postqubit respectively; loop through the circuit_list list and update all target operation instructions acting on the qubit postqubit to those acting on the qubit prequbit;

步骤8:返回circuit_list作为输出。Step 8: Return circuit_list as output.

如此,可以借助于有向无环图实现对星型结构的量子电路,以及星型结构的量子电路的子电路的等效编译,其实现过程非常简单。In this way, equivalent compilation of star-structured quantum circuits and sub-circuits of star-structured quantum circuits can be achieved with the help of directed acyclic graphs, and the implementation process is very simple.

对于图6中的量子电路,通过本实施例中的方案编译后得到的动态量子电路为图8所示,其对应电路指令列表为:dynamic_circuit=[[Reset,0,None,None],[Reset,1,None,None],[H,0,None,None],[H,1,None,None],[CNOT,[0,1],None,None],[Rx,0,0.5,None],[Measure,0,None,None],[Reset,0,None,None],[S,0,None,None],[Z,0,None,None],[CNOT,[0,1],None,None],[Rz,0,0.1,None],[Measure,0,None,None],[Reset,0,None,None],[T,0,None,None],[CNOT,[0,1],None,None],[Measure,0,None,None],[Measure,1,None,None]]。其动态量子电路的量子比特数为2,为最优的编译方案。For the quantum circuit in Figure 6, the dynamic quantum circuit obtained after compiling the solution in this embodiment is shown in Figure 8, and its corresponding circuit instruction list is: dynamic_circuit=[[Reset,0,None,None],[Reset ,1,None,None],[H,0,None,None],[H,1,None,None],[CNOT,[0,1],None,None],[Rx,0,0.5,None ],[Measure,0,None,None],[Reset,0,None,None],[S,0,None,None],[Z,0,None,None],[CNOT,[0,1] ,None,None],[Rz,0,0.1,None],[Measure,0,None,None],[Reset,0,None,None],[T,0,None,None],[CNOT,[ 0,1],None,None],[Measure,0,None,None],[Measure,1,None,None]]. The number of qubits in its dynamic quantum circuit is 2, which is the optimal compilation solution.

可选的,在所述第一量子电路为星型结构的量子电路的情况下,所述步骤S101具体包括:Optionally, in the case where the first quantum circuit is a star-structured quantum circuit, step S101 specifically includes:

将所述第一量子电路中每个量子比特的重置操作指令添加至电路列表;Add a reset operation instruction for each qubit in the first quantum circuit to the circuit list;

确定所述目标量子比特的第一量子位,并按照量子位从小到大的顺序,将所述第一量子电路中除所述第一量子位之外的其他量子位的量子比特与所述目标量子比特之间的每个双量子比特门的操作指令添加至电路列表;Determine the first qubit of the target qubit, and compare the qubits of other qubits in the first quantum circuit except the first qubit with the target in order of qubits from small to large. The operating instructions for each two-qubit gate between qubits are added to the circuit list;

将所述第一量子电路中每个量子比特的量子测量操作指令添加至电路列表,得到所述第一指令列表。Add the quantum measurement operation instructions of each qubit in the first quantum circuit to the circuit list to obtain the first instruction list.

一个包含N个量子比特的星型结构的量子电路的电路指令列表的具体获取过程如下。其中,目标量子比特可以为量子位N-1的量子比特,即量子电路中最后一个量子比特。The specific process of obtaining the circuit instruction list of a quantum circuit with a star structure containing N qubits is as follows. Among them, the target qubit can be the qubit of qubit N-1, which is the last qubit in the quantum circuit.

输入:量子电路宽度N;Input: quantum circuit width N;

输出:星型结构的量子电路的指令列表。Output: A list of instructions for a star-structured quantum circuit.

步骤1:初始化一个空列表circuit_list;Step 1: Initialize an empty list circuit_list;

步骤2:对变量i∈{0,1,···,N-1}进行循环:Step 2: Loop over the variable i∈{0,1,···,N-1}:

步骤2.1:将重置操作指令[Reset,i,None,None]加入到列表circuit_list末端;Step 2.1: Add the reset operation command [Reset,i,None,None] to the end of the circuit_list list;

步骤3:对变量i∈{0,1,···,N-2}进行循环:Step 3: Loop over the variables i∈{0,1,···,N-2}:

步骤3.1:将双量子比特门的操作指令如[CNOT,[i,N-1],None,None]加入到列表circuit_list末端;Step 3.1: Add the operation instructions of the double qubit gate such as [CNOT, [i, N-1], None, None] to the end of the list circuit_list;

步骤4:对变量i∈{0,1,···,N-1}进行循环:Step 4: Loop over the variable i∈{0,1,···,N-1}:

步骤4.1:将电路指令[Measure,i,None,None]加入到列表circuit_list末端;Step 4.1: Add the circuit command [Measure,i,None,None] to the end of the list circuit_list;

步骤5:返回circuit_list作为输出。Step 5: Return circuit_list as output.

如此,可以通过输入星型结构的量子电路的结构信息,实现星型结构的量子电路的第一指令列表的获取,其过程简单。In this way, the first instruction list of the star-structured quantum circuit can be obtained by inputting the structural information of the star-structured quantum circuit, and the process is simple.

在第一量子电路为星型结构的量子电路的情况下,可选的,所述步骤S101之前,所述方法还包括:In the case where the first quantum circuit is a star-structured quantum circuit, optionally, before step S101, the method further includes:

对包括N个量子比特的第三量子电路进行置换映射,以将所述第三量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特进行有序排列;Perform permutation mapping on a third quantum circuit including N qubits, so that the N qubits in the third quantum circuit are ordered in order from the qubits of qubit 0 to the qubits of qubit N-1;

在置换映射后的所述第三量子电路为星型结构的量子电路的情况下,确定所述第三量子电路与所述第一量子电路等效。In the case where the third quantum circuit after replacement mapping is a quantum circuit with a star structure, it is determined that the third quantum circuit is equivalent to the first quantum circuit.

针对不是标准量子电路的第三量子电路,可以将其转换为标准量子电路,若转换后得到的标准量子电路为星型结构的量子电路,则表明第三量子电路是与第一量子电路等效的。其中,标准量子电路中,N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特有序排列。For the third quantum circuit that is not a standard quantum circuit, it can be converted into a standard quantum circuit. If the standard quantum circuit obtained after conversion is a star-structured quantum circuit, it means that the third quantum circuit is equivalent to the first quantum circuit. of. Among them, in a standard quantum circuit, N qubits are arranged in order from the qubits of qubit 0 to the qubits of qubit N-1.

如此,可以扩大量子电路处理的原量子电路的适用范围。In this way, the applicable scope of original quantum circuits processed by quantum circuits can be expanded.

可选的,在置换映射后的所述第三量子电路为星型结构的量子电路的情况下,所述步骤S101具体包括:Optionally, in the case where the third quantum circuit after replacement mapping is a quantum circuit with a star structure, step S101 specifically includes:

获取所述第三量子电路的第四指令列表;Obtain the fourth instruction list of the third quantum circuit;

将所述第三量子电路中N个量子比特的第一编号列表进行置换,得到第二编号列表,所述第二编号列表是依次按照量子位0的量子比特至量子位N-1的量子比特有序排列的;The first numbered list of N qubits in the third quantum circuit is replaced to obtain a second numbered list. The second numbered list is sequentially from qubits of qubit 0 to qubits of qubit N-1. arranged in order;

基于所述第一编号列表和所述第二编号列表的映射关系,对所述第四指令列表中操作指令所作用的量子位进行变换,得到所述第一指令列表。Based on the mapping relationship between the first numbered list and the second numbered list, the qubits acted upon by the operation instructions in the fourth instruction list are transformed to obtain the first instruction list.

其中,可以基于置换矩阵将第三量子电路中N个量子比特的第一编号列表进行置换,得到第二编号列表,该置换矩阵可以由用户输入或预设得到。之后,可以基于第一编号列表和第二编号列表的映射关系,比如第三量子电路中的量子位2映射为第一量子电路中的量子位0,对第四指令列表中操作指令所作用的量子位进行变换,比如将第四指令列表中作用在量子位2的操作指令重新映射到量子位0上,以得到第一量子电路的第一指令列表。Wherein, the first numbered list of N qubits in the third quantum circuit can be permuted based on a permutation matrix to obtain a second numbered list. The permutation matrix can be input by the user or preset. Afterwards, based on the mapping relationship between the first numbered list and the second numbered list, for example, qubit 2 in the third quantum circuit is mapped to qubit 0 in the first quantum circuit, the operation instructions in the fourth instruction list act on The qubits are transformed, for example, the operation instructions acting on qubit 2 in the fourth instruction list are remapped to qubit 0 to obtain the first instruction list of the first quantum circuit.

如此,可以基于与第一量子电路等效的第三量子电路的指令列表,实现对第一量子电路的指令列表的获取。In this way, the instruction list of the first quantum circuit can be obtained based on the instruction list of the third quantum circuit that is equivalent to the first quantum circuit.

第二实施例Second embodiment

如图9所示,本公开提供一种量子电路处理装置900,包括:As shown in Figure 9, the present disclosure provides a quantum circuit processing device 900, including:

获取模块901,用于获取包括N个量子比特的第一量子电路的第一指令列表,所述第一量子电路为:星型结构的量子电路或星型结构的量子电路的子电路,所述星型结构的量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特有序排列,所述星型结构中,按照量子位从小到大的顺序分别在每个第一量子比特与目标量子比特之间作用双量子比特门,所述目标量子比特为所述N个量子比特之间任一量子比特,所述第一量子比特为所述N个量子比特中除所述目标量子比特的其他量子比特,所述子电路为从星型结构的量子电路的指令列表中删除部分操作指令所获得的量子电路,N为大于2的整数;The acquisition module 901 is used to acquire the first instruction list of a first quantum circuit including N qubits. The first quantum circuit is: a star-structured quantum circuit or a sub-circuit of a star-structured quantum circuit. The N qubits in the star-shaped quantum circuit are arranged in an orderly manner from the qubits of qubit 0 to the qubits of qubit N-1. In the star-shaped structure, the qubits are placed in each qubit in order from small to large. A two-qubit gate is used between the first qubit and the target qubit. The target qubit is any qubit among the N qubits. The first qubit is one of the N qubits. In addition to other qubits of the target qubit, the sub-circuit is a quantum circuit obtained by deleting some operation instructions from the instruction list of the star-structured quantum circuit, and N is an integer greater than 2;

等效编译模块902,用于基于所述第一指令列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表;The equivalent compilation module 902 is configured to perform equivalent compilation on the first quantum circuit based on the first instruction list to obtain a second instruction list of the second quantum circuit equivalent to the first quantum circuit;

其中,所述第二量子电路的量子比特数量小于所述第一量子电路的量子比特数量,所述等效编译包括:在所述第一指令列表中第一测量操作指令之后添加第一重置操作指令;并将所述第一指令列表中每个目标操作指令重新映射到量子位i的量子比特上,所述第一测量操作指令和所述第一重置操作指令均作用在量子位i上,所述目标操作指令作用在量子位i+1上,i的取值范围为[0,N-3]。Wherein, the number of qubits of the second quantum circuit is less than the number of qubits of the first quantum circuit, and the equivalent compilation includes: adding a first reset after the first measurement operation instruction in the first instruction list Operation instructions; and remap each target operation instruction in the first instruction list to the qubit of qubit i, and the first measurement operation instruction and the first reset operation instruction both act on qubit i On, the target operation instruction acts on qubit i+1, and the value range of i is [0, N-3].

可选的,所述等效编译模块902包括:Optionally, the equivalent compilation module 902 includes:

确定单元,用于基于所述第一指令列表,确定第一有向无环图,所述第一有向无环图包括所述第一指令列表中操作指令对应的节点和第一有向边,所述第一有向边用于表征所述第一指令列表中不同操作指令间的时序关系;A determination unit configured to determine a first directed acyclic graph based on the first instruction list, where the first directed acyclic graph includes nodes corresponding to the operation instructions in the first instruction list and first directed edges. , the first directed edge is used to characterize the timing relationship between different operation instructions in the first instruction list;

添加单元,用于在所述第一有向无环图中添加第二有向边,得到第二有向无环图和所述第二有向边构成的有向边列表,所述第二有向边包括所述第一测量操作指令对应输出节点至第二重置操作指令对应输入节点的有向边,所述第二重置操作指令为作用在量子位i+1上的重置操作指令;Adding a unit for adding a second directed edge to the first directed acyclic graph to obtain a directed edge list composed of the second directed acyclic graph and the second directed edge, the second The directed edge includes the directed edge from the output node corresponding to the first measurement operation instruction to the input node corresponding to the second reset operation instruction. The second reset operation instruction is a reset operation acting on qubit i+1. instruction;

等效编译单元,用于基于所述第二有向无环图和所述有向边列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表。An equivalent compilation unit is configured to perform equivalent compilation on the first quantum circuit based on the second directed acyclic graph and the directed edge list to obtain a second quantum circuit equivalent to the first quantum circuit. Second instruction list for quantum circuits.

可选的,所述确定单元,具体用于:Optionally, the determination unit is specifically used for:

对所述第一指令列表按照操作指令的排列顺序进行遍历;Traverse the first instruction list in the order in which the operation instructions are arranged;

将当前遍历的操作指令作为节点,并在目标列表不为空列表的情况下,添加所述目标列表中位于末尾的操作指令对应节点至当前遍历的操作指令对应节点的第一有向边;所述目标列表为当前遍历的操作指令所作用的量子位对应的列表;Use the currently traversed operation instruction as a node, and if the target list is not an empty list, add the operation instruction corresponding node at the end of the target list to the first directed edge of the currently traversed operation instruction corresponding node; so The target list is a list corresponding to the qubits acted upon by the currently traversed operation instruction;

将当前遍历的操作指令添加至所述目标列表的末尾,并在所述第一指令列表遍历完成的情况下,得到所述第一有向无环图。The currently traversed operation instructions are added to the end of the target list, and when the traversal of the first instruction list is completed, the first directed acyclic graph is obtained.

可选的,所述等效编译单元,具体用于:Optional, the equivalent compilation unit is specifically used for:

获取所述第二有向无环图对应的操作指令的拓扑排序,得到第三指令列表;Obtain the topological sorting of the operation instructions corresponding to the second directed acyclic graph and obtain a third instruction list;

针对所述有向边列表中每个所述第二有向边,将所述第三指令列表中所述第二有向边的输入节点所作用的量子位对应的各目标操作指令重新映射到所述第二有向边的输出节点所作用的量子位上,以得到所述第二指令列表。For each second directed edge in the directed edge list, remap each target operation instruction corresponding to the qubit acted on by the input node of the second directed edge in the third instruction list to The output node of the second directed edge acts on the qubit to obtain the second instruction list.

可选的,在所述第一量子电路为星型结构的量子电路的情况下,所述获取模块901,具体用于:Optionally, in the case where the first quantum circuit is a star-structured quantum circuit, the acquisition module 901 is specifically used to:

将所述第一量子电路中每个量子比特的重置操作指令添加至电路列表;Add a reset operation instruction for each qubit in the first quantum circuit to the circuit list;

确定所述目标量子比特的第一量子位,并按照量子位从小到大的顺序,将所述第一量子电路中除所述第一量子位之外的其他量子位的量子比特与所述目标量子比特之间的每个双量子比特门的操作指令添加至电路列表;Determine the first qubit of the target qubit, and compare the qubits of other qubits in the first quantum circuit except the first qubit with the target in order of qubits from small to large. The operating instructions for each two-qubit gate between qubits are added to the circuit list;

将所述第一量子电路中每个量子比特的量子测量操作指令添加至电路列表,得到所述第一指令列表。Add the quantum measurement operation instructions of each qubit in the first quantum circuit to the circuit list to obtain the first instruction list.

可选的,所述装置还包括:Optionally, the device also includes:

置换映射模块,用于对包括N个量子比特的第三量子电路进行置换映射,以将所述第三量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特进行有序排列;A permutation mapping module, used to perform permutation mapping on a third quantum circuit including N qubits, so as to sequentially map the N qubits in the third quantum circuit from qubits of qubit 0 to qubits of qubit N-1. Bits are arranged in an orderly manner;

确定模块,用于在置换映射后的所述第三量子电路为星型结构的量子电路的情况下,确定所述第三量子电路与所述第一量子电路等效。A determination module configured to determine that the third quantum circuit is equivalent to the first quantum circuit when the third quantum circuit after replacement mapping is a quantum circuit with a star structure.

可选的,在置换映射后的所述第三量子电路为星型结构的量子电路的情况下,所述获取模块901,具体用于:Optionally, when the third quantum circuit after replacement mapping is a quantum circuit with a star structure, the acquisition module 901 is specifically used to:

获取所述第三量子电路的第四指令列表;Obtain the fourth instruction list of the third quantum circuit;

将所述第三量子电路中N个量子比特的第一编号列表进行置换,得到第二编号列表,所述第二编号列表是依次按照量子位0的量子比特至量子位N-1的量子比特有序排列的;The first numbered list of N qubits in the third quantum circuit is replaced to obtain a second numbered list. The second numbered list is sequentially from qubits of qubit 0 to qubits of qubit N-1. arranged in order;

基于所述第一编号列表和所述第二编号列表的映射关系,对所述第四指令列表中操作指令所作用的量子位进行变换,得到所述第一指令列表。Based on the mapping relationship between the first numbered list and the second numbered list, the qubits acted upon by the operation instructions in the fourth instruction list are transformed to obtain the first instruction list.

可选的,所述第一量子电路中还包括至少一个单量子比特门,所述单量子比特门位于所述第一量子电路的任意位置。Optionally, the first quantum circuit also includes at least one single qubit gate, and the single qubit gate is located at any position of the first quantum circuit.

本公开提供的量子电路处理装置900能够实现量子电路处理方法实施例实现的各个过程,且能够达到相同的有益效果,为避免重复,这里不再赘述。The quantum circuit processing device 900 provided by the present disclosure can implement various processes implemented by the embodiments of the quantum circuit processing method, and can achieve the same beneficial effects. To avoid duplication, they will not be described again here.

本公开的技术方案中,所涉及的用户个人信息的收集、存储、使用、加工、传输、提供和公开等处理,均符合相关法律法规的规定,且不违背公序良俗。In the technical solution of this disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information are in compliance with relevant laws and regulations and do not violate public order and good customs.

根据本公开的实施例,本公开还提供了一种电子设备、一种可读存储介质和一种计算机程序产品。According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

图10示出了可以用来实施本公开的实施例的示例电子设备的示意性框图。电子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本公开的实现。Figure 10 shows a schematic block diagram of an example electronic device that may be used to implement embodiments of the present disclosure. Electronic devices are intended to refer to various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are examples only and are not intended to limit implementations of the disclosure described and/or claimed herein.

如图10所示,设备1000包括计算单元1001,其可以根据存储在只读存储器(ROM)1002中的计算机程序或者从存储单元1008加载到随机访问存储器(RAM)1003中的计算机程序,来执行各种适当的动作和处理。在RAM 1003中,还可存储设备1000操作所需的各种程序和数据。计算单元1001、ROM 1002以及RAM 1003通过总线1004彼此相连。输入/输出(I/O)接口1005也连接至总线1004。As shown in FIG. 10 , the device 1000 includes a computing unit 1001 that can execute according to a computer program stored in a read-only memory (ROM) 1002 or loaded from a storage unit 1008 into a random access memory (RAM) 1003 Various appropriate actions and treatments. In the RAM 1003, various programs and data required for the operation of the device 1000 can also be stored. Computing unit 1001, ROM 1002 and RAM 1003 are connected to each other via bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.

设备1000中的多个部件连接至I/O接口1005,包括:输入单元1006,例如键盘、鼠标等;输出单元1007,例如各种类型的显示器、扬声器等;存储单元1008,例如磁盘、光盘等;以及通信单元1009,例如网卡、调制解调器、无线通信收发机等。通信单元1009允许设备1000通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。Multiple components in the device 1000 are connected to the I/O interface 1005, including: input unit 1006, such as a keyboard, mouse, etc.; output unit 1007, such as various types of displays, speakers, etc.; storage unit 1008, such as a magnetic disk, optical disk, etc. ; and communication unit 1009, such as a network card, modem, wireless communication transceiver, etc. The communication unit 1009 allows the device 1000 to exchange information/data with other devices through computer networks such as the Internet and/or various telecommunications networks.

计算单元1001可以是各种具有处理和计算能力的通用和/或专用处理组件。计算单元1001的一些示例包括但不限于中央处理单元(CPU)、图形处理单元(GPU)、各种专用的人工智能(AI)计算芯片、各种运行机器学习模型算法的计算单元、数字信号处理器(DSP)、以及任何适当的处理器、控制器、微控制器等。计算单元1001执行上文所描述的各个方法和处理,例如量子电路处理方法。例如,在一些实施例中,量子电路处理方法可被实现为计算机软件程序,其被有形地包含于机器可读介质,例如存储单元1008。在一些实施例中,计算机程序的部分或者全部可以经由ROM 1002和/或通信单元1009而被载入和/或安装到设备1000上。当计算机程序加载到RAM 1003并由计算单元1001执行时,可以执行上文描述的量子电路处理方法的一个或多个步骤。备选地,在其他实施例中,计算单元1001可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行量子电路处理方法。Computing unit 1001 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processing processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 1001 performs various methods and processes described above, such as quantum circuit processing methods. For example, in some embodiments, the quantum circuit processing method may be implemented as a computer software program that is tangibly embodied in a machine-readable medium, such as storage unit 1008. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 1000 via ROM 1002 and/or communication unit 1009 . When the computer program is loaded into RAM 1003 and executed by computing unit 1001, one or more steps of the quantum circuit processing method described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to perform quantum circuit processing methods in any other suitable manner (eg, by means of firmware).

本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、芯片上系统的系统(SOC)、负载可编程逻辑设备(CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described above may be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip implemented in a system (SOC), load programmable logic device (CPLD), computer hardware, firmware, software, and/or a combination thereof. These various embodiments may include implementation in one or more computer programs executable and/or interpreted on a programmable system including at least one programmable processor, the programmable processor The processor, which may be a special purpose or general purpose programmable processor, may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device. An output device.

用于实施本公开的方法的程序代码可以采用一个或多个编程语言的任何组合来编写。这些程序代码可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器或控制器,使得程序代码当由处理器或控制器执行时使流程图和/或框图中所规定的功能/操作被实施。程序代码可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that the program codes, when executed by the processor or controller, cause the functions specified in the flowcharts and/or block diagrams/ The operation is implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.

在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of this disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media may include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include one or more wire-based electrical connections, laptop disks, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.

为了提供与用户的交互,可以在计算机上实施此处描述的系统和技术,该计算机具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给计算机。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。To provide interaction with a user, the systems and techniques described herein may be implemented on a computer having a display device (eg, a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user ); and a keyboard and pointing device (eg, a mouse or a trackball) through which a user can provide input to the computer. Other kinds of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and may be provided in any form, including Acoustic input, voice input or tactile input) to receive input from the user.

可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(LAN)、广域网(WAN)和互联网。The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., A user's computer having a graphical user interface or web browser through which the user can interact with implementations of the systems and technologies described herein), or including such backend components, middleware components, or any combination of front-end components in a computing system. The components of the system may be interconnected by any form or medium of digital data communication (eg, a communications network). Examples of communication networks include: local area network (LAN), wide area network (WAN), and the Internet.

计算机系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,也可以为分布式系统的服务器,或者是结合了区块链的服务器。Computer systems may include clients and servers. Clients and servers are generally remote from each other and typically interact over a communications network. The relationship of client and server is created by computer programs running on corresponding computers and having a client-server relationship with each other. The server can be a cloud server, a distributed system server, or a server combined with a blockchain.

应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本公开中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本公开公开的技术方案所期望的结果,本文在此不进行限制。It should be understood that various forms of the process shown above may be used, with steps reordered, added or deleted. For example, each step described in the present disclosure can be executed in parallel, sequentially, or in a different order. As long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, there is no limitation here.

上述具体实施方式,并不构成对本公开保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本公开的精神和原则之内所作的修改、等同替换和改进等,均应包含在本公开保护范围之内。The above-mentioned specific embodiments do not constitute a limitation on the scope of the present disclosure. It will be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions are possible depending on design requirements and other factors. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this disclosure shall be included in the protection scope of this disclosure.

Claims (19)

1.一种量子电路处理方法,包括:1. A quantum circuit processing method, including: 获取包括N个量子比特的第一量子电路的第一指令列表,所述第一量子电路为:星型结构的量子电路或星型结构的量子电路的子电路,所述星型结构的量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特有序排列,所述星型结构中,按照量子位从小到大的顺序分别在每个第一量子比特与目标量子比特之间作用双量子比特门,所述目标量子比特为所述N个量子比特之间任一量子比特,所述第一量子比特为所述N个量子比特中除所述目标量子比特的其他量子比特,所述子电路为从星型结构的量子电路的指令列表中删除部分操作指令所获得的量子电路,N为大于2的整数;Obtaining a first instruction list of a first quantum circuit including N qubits, the first quantum circuit being: a star-structured quantum circuit or a sub-circuit of a star-structured quantum circuit, the star-structured quantum circuit The N qubits in the qubit are arranged in order from the qubit of qubit 0 to the qubit of qubit N-1. In the star structure, each first qubit and the qubit are arranged in order from small to large. A two-qubit gate acts between target qubits, the target qubit is any qubit among the N qubits, and the first qubit is any of the N qubits except the target qubit. Other qubits, the sub-circuit is a quantum circuit obtained by deleting some operation instructions from the instruction list of a star-structured quantum circuit, and N is an integer greater than 2; 基于所述第一指令列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表;Based on the first instruction list, perform equivalent compilation on the first quantum circuit to obtain a second instruction list of the second quantum circuit equivalent to the first quantum circuit; 其中,所述第二量子电路的量子比特数量小于所述第一量子电路的量子比特数量,所述等效编译包括:在所述第一指令列表中第一测量操作指令之后添加第一重置操作指令;并将所述第一指令列表中每个目标操作指令重新映射到量子位i的量子比特上,所述第一测量操作指令和所述第一重置操作指令均作用在量子位i上,所述目标操作指令作用在量子位i+1上,i的取值范围为[0,N-3]。Wherein, the number of qubits of the second quantum circuit is less than the number of qubits of the first quantum circuit, and the equivalent compilation includes: adding a first reset after the first measurement operation instruction in the first instruction list Operation instructions; and remap each target operation instruction in the first instruction list to the qubit of qubit i, and the first measurement operation instruction and the first reset operation instruction both act on qubit i On, the target operation instruction acts on qubit i+1, and the value range of i is [0, N-3]. 2.根据权利要求1所述的方法,其中,所述基于所述第一指令列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表,包括:2. The method according to claim 1, wherein the first quantum circuit is equivalently compiled based on the first instruction list to obtain a second quantum circuit equivalent to the first quantum circuit. The second instruction list includes: 基于所述第一指令列表,确定第一有向无环图,所述第一有向无环图包括所述第一指令列表中操作指令对应的节点和第一有向边,所述第一有向边用于表征所述第一指令列表中不同操作指令间的时序关系;Based on the first instruction list, a first directed acyclic graph is determined, the first directed acyclic graph includes nodes corresponding to the operation instructions in the first instruction list and first directed edges, and the first directed acyclic graph Directed edges are used to characterize the timing relationship between different operation instructions in the first instruction list; 在所述第一有向无环图中添加第二有向边,得到第二有向无环图和所述第二有向边构成的有向边列表,所述第二有向边包括所述第一测量操作指令对应输出节点至第二重置操作指令对应输入节点的有向边,所述第二重置操作指令为作用在量子位i+1上的重置操作指令;Add a second directed edge to the first directed acyclic graph to obtain a directed edge list composed of the second directed acyclic graph and the second directed edge, where the second directed edge includes all The first measurement operation instruction corresponds to the directed edge from the output node to the second reset operation instruction corresponding to the input node, and the second reset operation instruction is a reset operation instruction acting on qubit i+1; 基于所述第二有向无环图和所述有向边列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表。Based on the second directed acyclic graph and the directed edge list, the first quantum circuit is equivalently compiled to obtain a second instruction list of the second quantum circuit equivalent to the first quantum circuit. . 3.根据权利要求2所述的方法,其中,所述基于所述第一指令列表,确定第一有向无环图,包括:3. The method of claim 2, wherein determining the first directed acyclic graph based on the first instruction list includes: 对所述第一指令列表按照操作指令的排列顺序进行遍历;Traverse the first instruction list in the order in which the operation instructions are arranged; 将当前遍历的操作指令作为节点,并在目标列表不为空列表的情况下,添加所述目标列表中位于末尾的操作指令对应节点至当前遍历的操作指令对应节点的第一有向边;所述目标列表为当前遍历的操作指令所作用的量子位对应的列表;Use the currently traversed operation instruction as a node, and if the target list is not an empty list, add the operation instruction corresponding node at the end of the target list to the first directed edge of the currently traversed operation instruction corresponding node; so The target list is a list corresponding to the qubits acted upon by the currently traversed operation instruction; 将当前遍历的操作指令添加至所述目标列表的末尾,并在所述第一指令列表遍历完成的情况下,得到所述第一有向无环图。The currently traversed operation instructions are added to the end of the target list, and when the traversal of the first instruction list is completed, the first directed acyclic graph is obtained. 4.根据权利要求2所述的方法,其中,所述基于所述第二有向无环图和所述有向边列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表,包括:4. The method according to claim 2, wherein the first quantum circuit is equivalently compiled based on the second directed acyclic graph and the directed edge list to obtain the same as the first quantum circuit. The second instruction list of a second quantum circuit equivalent to one quantum circuit includes: 获取所述第二有向无环图对应的操作指令的拓扑排序,得到第三指令列表;Obtain the topological sorting of the operation instructions corresponding to the second directed acyclic graph and obtain a third instruction list; 针对所述有向边列表中每个所述第二有向边,将所述第三指令列表中所述第二有向边的输入节点所作用的量子位对应的各目标操作指令重新映射到所述第二有向边的输出节点所作用的量子位上,以得到所述第二指令列表。For each second directed edge in the directed edge list, remap each target operation instruction corresponding to the qubit acted on by the input node of the second directed edge in the third instruction list to The output node of the second directed edge acts on the qubit to obtain the second instruction list. 5.根据权利要求1所述的方法,其中,在所述第一量子电路为星型结构的量子电路的情况下,所述获取包括N个量子比特的第一量子电路的第一指令列表,包括:5. The method according to claim 1, wherein, in the case where the first quantum circuit is a quantum circuit with a star structure, the obtaining the first instruction list of the first quantum circuit including N qubits, include: 将所述第一量子电路中每个量子比特的重置操作指令添加至电路列表;Add a reset operation instruction for each qubit in the first quantum circuit to the circuit list; 确定所述目标量子比特的第一量子位,并按照量子位从小到大的顺序,将所述第一量子电路中除所述第一量子位之外的其他量子位的量子比特与所述目标量子比特之间的每个双量子比特门的操作指令添加至电路列表;Determine the first qubit of the target qubit, and compare the qubits of other qubits in the first quantum circuit except the first qubit with the target in order of qubits from small to large. The operating instructions for each two-qubit gate between qubits are added to the circuit list; 将所述第一量子电路中每个量子比特的量子测量操作指令添加至电路列表,得到所述第一指令列表。Add the quantum measurement operation instructions of each qubit in the first quantum circuit to the circuit list to obtain the first instruction list. 6.根据权利要求1所述的方法,所述获取包括N个量子比特的第一量子电路的第一指令列表之前,还包括:6. The method according to claim 1, before obtaining the first instruction list of the first quantum circuit including N qubits, further comprising: 对包括N个量子比特的第三量子电路进行置换映射,以将所述第三量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特进行有序排列;Perform permutation mapping on a third quantum circuit including N qubits, so that the N qubits in the third quantum circuit are ordered in order from the qubits of qubit 0 to the qubits of qubit N-1; 在置换映射后的所述第三量子电路为星型结构的量子电路的情况下,确定所述第三量子电路与所述第一量子电路等效。In the case where the third quantum circuit after replacement mapping is a quantum circuit with a star structure, it is determined that the third quantum circuit is equivalent to the first quantum circuit. 7.根据权利要求6所述的方法,其中,在置换映射后的所述第三量子电路为星型结构的量子电路的情况下,所述获取包括N个量子比特的第一量子电路的第一指令列表,包括:7. The method according to claim 6, wherein, in the case where the third quantum circuit after replacement mapping is a quantum circuit with a star structure, the acquisition of the first quantum circuit including N qubits is A list of instructions, including: 获取所述第三量子电路的第四指令列表;Obtain the fourth instruction list of the third quantum circuit; 将所述第三量子电路中N个量子比特的第一编号列表进行置换,得到第二编号列表,所述第二编号列表是依次按照量子位0的量子比特至量子位N-1的量子比特有序排列的;The first numbered list of N qubits in the third quantum circuit is replaced to obtain a second numbered list. The second numbered list is sequentially from qubits of qubit 0 to qubits of qubit N-1. arranged in order; 基于所述第一编号列表和所述第二编号列表的映射关系,对所述第四指令列表中操作指令所作用的量子位进行变换,得到所述第一指令列表。Based on the mapping relationship between the first numbered list and the second numbered list, the qubits acted upon by the operation instructions in the fourth instruction list are transformed to obtain the first instruction list. 8.根据权利要求1所述的方法,其中,所述第一量子电路中还包括至少一个单量子比特门,所述单量子比特门位于所述第一量子电路的任意位置。8. The method according to claim 1, wherein the first quantum circuit further includes at least one single qubit gate, and the single qubit gate is located at any position of the first quantum circuit. 9.一种量子电路处理装置,包括:9. A quantum circuit processing device, including: 获取模块,用于获取包括N个量子比特的第一量子电路的第一指令列表,所述第一量子电路为:星型结构的量子电路或星型结构的量子电路的子电路,所述星型结构的量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特有序排列,所述星型结构中,按照量子位从小到大的顺序分别在每个第一量子比特与目标量子比特之间作用双量子比特门,所述目标量子比特为所述N个量子比特之间任一量子比特,所述第一量子比特为所述N个量子比特中除所述目标量子比特的其他量子比特,所述子电路为从星型结构的量子电路的指令列表中删除部分操作指令所获得的量子电路,N为大于2的整数;An acquisition module, configured to acquire a first instruction list of a first quantum circuit including N qubits, where the first quantum circuit is: a star-structured quantum circuit or a sub-circuit of a star-structured quantum circuit, where the star The N qubits in the quantum circuit of the star-shaped structure are arranged in an orderly manner from the qubits of qubit 0 to the qubits of qubit N-1. In the star-shaped structure, each qubit is arranged in order from small to large. A two-qubit gate operates between the first qubit and the target qubit. The target qubit is any qubit among the N qubits. The first qubit is any one of the N qubits. For other qubits of the target qubit, the sub-circuit is a quantum circuit obtained by deleting some operation instructions from the instruction list of the star-structured quantum circuit, and N is an integer greater than 2; 等效编译模块,用于基于所述第一指令列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表;An equivalent compilation module, configured to perform equivalent compilation on the first quantum circuit based on the first instruction list to obtain a second instruction list of the second quantum circuit equivalent to the first quantum circuit; 其中,所述第二量子电路的量子比特数量小于所述第一量子电路的量子比特数量,所述等效编译包括:在所述第一指令列表中第一测量操作指令之后添加第一重置操作指令;并将所述第一指令列表中每个目标操作指令重新映射到量子位i的量子比特上,所述第一测量操作指令和所述第一重置操作指令均作用在量子位i上,所述目标操作指令作用在量子位i+1上,i的取值范围为[0,N-3]。Wherein, the number of qubits of the second quantum circuit is less than the number of qubits of the first quantum circuit, and the equivalent compilation includes: adding a first reset after the first measurement operation instruction in the first instruction list Operation instructions; and remap each target operation instruction in the first instruction list to the qubit of qubit i, and the first measurement operation instruction and the first reset operation instruction both act on qubit i On, the target operation instruction acts on qubit i+1, and the value range of i is [0, N-3]. 10.根据权利要求9所述的装置,其中,所述等效编译模块包括:10. The apparatus of claim 9, wherein the equivalent compilation module includes: 确定单元,用于基于所述第一指令列表,确定第一有向无环图,所述第一有向无环图包括所述第一指令列表中操作指令对应的节点和第一有向边,所述第一有向边用于表征所述第一指令列表中不同操作指令间的时序关系;A determination unit configured to determine a first directed acyclic graph based on the first instruction list, where the first directed acyclic graph includes nodes corresponding to the operation instructions in the first instruction list and first directed edges. , the first directed edge is used to characterize the timing relationship between different operation instructions in the first instruction list; 添加单元,用于在所述第一有向无环图中添加第二有向边,得到第二有向无环图和所述第二有向边构成的有向边列表,所述第二有向边包括所述第一测量操作指令对应输出节点至第二重置操作指令对应输入节点的有向边,所述第二重置操作指令为作用在量子位i+1上的重置操作指令;Adding a unit for adding a second directed edge to the first directed acyclic graph to obtain a directed edge list composed of the second directed acyclic graph and the second directed edge, the second The directed edge includes the directed edge from the output node corresponding to the first measurement operation instruction to the input node corresponding to the second reset operation instruction. The second reset operation instruction is a reset operation acting on qubit i+1. instruction; 等效编译单元,用于基于所述第二有向无环图和所述有向边列表,对所述第一量子电路进行等效编译,得到与所述第一量子电路等效的第二量子电路的第二指令列表。An equivalent compilation unit is configured to perform equivalent compilation on the first quantum circuit based on the second directed acyclic graph and the directed edge list to obtain a second quantum circuit equivalent to the first quantum circuit. Second instruction list for quantum circuits. 11.根据权利要求10所述的装置,其中,所述确定单元,具体用于:11. The device according to claim 10, wherein the determining unit is specifically used to: 对所述第一指令列表按照操作指令的排列顺序进行遍历;Traverse the first instruction list in the order in which the operation instructions are arranged; 将当前遍历的操作指令作为节点,并在目标列表不为空列表的情况下,添加所述目标列表中位于末尾的操作指令对应节点至当前遍历的操作指令对应节点的第一有向边;所述目标列表为当前遍历的操作指令所作用的量子位对应的列表;Use the currently traversed operation instruction as a node, and if the target list is not an empty list, add the operation instruction corresponding node at the end of the target list to the first directed edge of the currently traversed operation instruction corresponding node; so The target list is a list corresponding to the qubits acted upon by the currently traversed operation instruction; 将当前遍历的操作指令添加至所述目标列表的末尾,并在所述第一指令列表遍历完成的情况下,得到所述第一有向无环图。The currently traversed operation instructions are added to the end of the target list, and when the traversal of the first instruction list is completed, the first directed acyclic graph is obtained. 12.根据权利要求10所述的装置,其中,所述等效编译单元,具体用于:12. The device according to claim 10, wherein the equivalent compilation unit is specifically used for: 获取所述第二有向无环图对应的操作指令的拓扑排序,得到第三指令列表;Obtain the topological sorting of the operation instructions corresponding to the second directed acyclic graph and obtain a third instruction list; 针对所述有向边列表中每个所述第二有向边,将所述第三指令列表中所述第二有向边的输入节点所作用的量子位对应的各目标操作指令重新映射到所述第二有向边的输出节点所作用的量子位上,以得到所述第二指令列表。For each second directed edge in the directed edge list, remap each target operation instruction corresponding to the qubit acted on by the input node of the second directed edge in the third instruction list to The output node of the second directed edge acts on the qubit to obtain the second instruction list. 13.根据权利要求9所述的装置,其中,在所述第一量子电路为星型结构的量子电路的情况下,所述获取模块,具体用于:13. The device according to claim 9, wherein, when the first quantum circuit is a quantum circuit with a star structure, the acquisition module is specifically configured to: 将所述第一量子电路中每个量子比特的重置操作指令添加至电路列表;Add a reset operation instruction for each qubit in the first quantum circuit to the circuit list; 确定所述目标量子比特的第一量子位,并按照量子位从小到大的顺序,将所述第一量子电路中除所述第一量子位之外的其他量子位的量子比特与所述目标量子比特之间的每个双量子比特门的操作指令添加至电路列表;Determine the first qubit of the target qubit, and compare the qubits of other qubits in the first quantum circuit except the first qubit with the target in order of qubits from small to large. The operating instructions for each two-qubit gate between qubits are added to the circuit list; 将所述第一量子电路中每个量子比特的量子测量操作指令添加至电路列表,得到所述第一指令列表。Add the quantum measurement operation instructions of each qubit in the first quantum circuit to the circuit list to obtain the first instruction list. 14.根据权利要求9所述的装置,还包括:14. The device of claim 9, further comprising: 置换映射模块,用于对包括N个量子比特的第三量子电路进行置换映射,以将所述第三量子电路中N个量子比特依次按照量子位0的量子比特至量子位N-1的量子比特进行有序排列;A permutation mapping module, used to perform permutation mapping on a third quantum circuit including N qubits, so as to sequentially map the N qubits in the third quantum circuit from qubits of qubit 0 to qubits of qubit N-1. Bits are arranged in order; 确定模块,用于在置换映射后的所述第三量子电路为星型结构的量子电路的情况下,确定所述第三量子电路与所述第一量子电路等效。A determination module configured to determine that the third quantum circuit is equivalent to the first quantum circuit when the third quantum circuit after replacement mapping is a quantum circuit with a star structure. 15.根据权利要求14所述的装置,其中,在置换映射后的所述第三量子电路为星型结构的量子电路的情况下,所述获取模块,具体用于:15. The device according to claim 14, wherein when the third quantum circuit after replacement mapping is a quantum circuit with a star structure, the acquisition module is specifically configured to: 获取所述第三量子电路的第四指令列表;Obtain the fourth instruction list of the third quantum circuit; 将所述第三量子电路中N个量子比特的第一编号列表进行置换,得到第二编号列表,所述第二编号列表是依次按照量子位0的量子比特至量子位N-1的量子比特有序排列的;The first numbered list of N qubits in the third quantum circuit is replaced to obtain a second numbered list. The second numbered list is sequentially from qubits of qubit 0 to qubits of qubit N-1. arranged in order; 基于所述第一编号列表和所述第二编号列表的映射关系,对所述第四指令列表中操作指令所作用的量子位进行变换,得到所述第一指令列表。Based on the mapping relationship between the first numbered list and the second numbered list, the qubits acted upon by the operation instructions in the fourth instruction list are transformed to obtain the first instruction list. 16.根据权利要求9所述的装置,其中,所述第一量子电路中还包括至少一个单量子比特门,所述单量子比特门位于所述第一量子电路的任意位置。16. The device according to claim 9, wherein the first quantum circuit further includes at least one single qubit gate, and the single qubit gate is located at any position of the first quantum circuit. 17.一种电子设备,包括:17. An electronic device, including: 至少一个处理器;以及at least one processor; and 与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein, 所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-8中任一项所述的方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any one of claims 1-8. Methods. 18.一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行根据权利要求1-8中任一项所述的方法。18. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to perform the method according to any one of claims 1-8. 19.一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现根据权利要求1-8中任一项所述的方法。19. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-8.
CN202311268026.XA 2023-09-27 2023-09-27 Quantum circuit processing method, device and electronic equipment Active CN117313883B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311268026.XA CN117313883B (en) 2023-09-27 2023-09-27 Quantum circuit processing method, device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311268026.XA CN117313883B (en) 2023-09-27 2023-09-27 Quantum circuit processing method, device and electronic equipment

Publications (2)

Publication Number Publication Date
CN117313883A true CN117313883A (en) 2023-12-29
CN117313883B CN117313883B (en) 2025-01-28

Family

ID=89249428

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311268026.XA Active CN117313883B (en) 2023-09-27 2023-09-27 Quantum circuit processing method, device and electronic equipment

Country Status (1)

Country Link
CN (1) CN117313883B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11010145B1 (en) * 2018-02-21 2021-05-18 Rigetti & Co, Inc. Retargetable compilation for quantum computing systems
US20220284336A1 (en) * 2021-07-14 2022-09-08 Beijing Baidu Netcom Science Technology Co., Ltd. Processing method for quantum circuit, electronic device, and storage medium
CN115860128A (en) * 2022-12-21 2023-03-28 北京百度网讯科技有限公司 Quantum circuit operation method and device and electronic equipment
CN116151384A (en) * 2023-02-20 2023-05-23 北京百度网讯科技有限公司 Quantum circuit processing method and device and electronic equipment
CN116151381A (en) * 2023-02-20 2023-05-23 北京百度网讯科技有限公司 Quantum circuit processing method and device and electronic equipment
CN116187458A (en) * 2023-02-20 2023-05-30 北京百度网讯科技有限公司 Quantum circuit processing method and device and electronic equipment
CN116187463A (en) * 2023-02-20 2023-05-30 北京百度网讯科技有限公司 Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment
CN116579435A (en) * 2023-05-22 2023-08-11 北京百度网讯科技有限公司 Quantum circuit classification method, quantum circuit classification device, electronic equipment, medium and product
CN116629370A (en) * 2023-06-26 2023-08-22 北京百度网讯科技有限公司 Quantum circuit processing method and device and electronic equipment

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11010145B1 (en) * 2018-02-21 2021-05-18 Rigetti & Co, Inc. Retargetable compilation for quantum computing systems
US20220284336A1 (en) * 2021-07-14 2022-09-08 Beijing Baidu Netcom Science Technology Co., Ltd. Processing method for quantum circuit, electronic device, and storage medium
CN115860128A (en) * 2022-12-21 2023-03-28 北京百度网讯科技有限公司 Quantum circuit operation method and device and electronic equipment
CN116151384A (en) * 2023-02-20 2023-05-23 北京百度网讯科技有限公司 Quantum circuit processing method and device and electronic equipment
CN116151381A (en) * 2023-02-20 2023-05-23 北京百度网讯科技有限公司 Quantum circuit processing method and device and electronic equipment
CN116187458A (en) * 2023-02-20 2023-05-30 北京百度网讯科技有限公司 Quantum circuit processing method and device and electronic equipment
CN116187463A (en) * 2023-02-20 2023-05-30 北京百度网讯科技有限公司 Quantum measurement mode-to-quantum circuit compiling method and device and electronic equipment
CN116579435A (en) * 2023-05-22 2023-08-11 北京百度网讯科技有限公司 Quantum circuit classification method, quantum circuit classification device, electronic equipment, medium and product
CN116629370A (en) * 2023-06-26 2023-08-22 北京百度网讯科技有限公司 Quantum circuit processing method and device and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
DMITRI MASLOV: "Basic circuit compilation techniques for an ion-trap quantum machine", 《NEW JOURNAL OF PHYSICS》, vol. 19, 20 February 2017 (2017-02-20), XP055568611, DOI: 10.1088/1367-2630/aa5e47 *

Also Published As

Publication number Publication date
CN117313883B (en) 2025-01-28

Similar Documents

Publication Publication Date Title
WO2020151129A1 (en) Quantum machine learning framework construction method and apparatus, and quantum computer and computer storage medium
CN116151384B (en) Quantum circuit processing method and device and electronic equipment
US20230054391A1 (en) Calibration of quantum measurement device
CN114925840B (en) Simulation method, simulation device and storage medium
CN114418107B (en) Unitary operator compiling method, computing device, unitary operator compiling apparatus and storage medium
CN114897173B (en) Method and device for determining PageRank based on variable quantum circuits
CN116151381B (en) Quantum circuit processing method and device and electronic equipment
CN116187458B (en) Quantum circuit processing method and device and electronic equipment
CN113190719B (en) Node grouping method and device and electronic equipment
CN114418108B (en) Unitary operator compiling method, computing device, apparatus and storage medium
CN116611527B (en) Quantum circuit processing method and device and electronic equipment
CN116579435B (en) Quantum circuit classification method, quantum circuit classification device, electronic equipment, medium and product
CN116227607B (en) Quantum circuit classification method, quantum circuit classification device, electronic equipment, medium and product
CN117669751A (en) Quantum circuit simulation methods, devices and electronic equipment
AU2023285953A1 (en) Method and apparatus of processing quantum noise circuit, device, and storage medium
CN117313883A (en) Quantum circuit processing method and device and electronic equipment
CN117313879A (en) Quantum circuit processing method and device and electronic equipment
CN117313878A (en) Quantum circuit processing method and device and electronic equipment
CN117436535A (en) Quantum circuit mapping method and device and electronic equipment
CA3187339A1 (en) Reducing resources in quantum circuits
Marques et al. A cloud computing based framework for general 2D and 3D cellular automata simulation
CN117313881A (en) Quantum circuit classification method and device and electronic equipment
CN117313880A (en) Quantum circuit processing method and device and electronic equipment
CN117744813A (en) Quantum circuit processing method and device and electronic equipment
CN117313882A (en) Quantum circuit processing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant