CN-117744811-B - Quantum circuit operation result acquisition method and device and electronic equipment
Abstract
The disclosure provides a method and a device for acquiring an operation result of a quantum circuit and electronic equipment, relates to the field of computers, and particularly relates to the field of quantum computing. The method comprises the steps of obtaining a target quantum program for realizing a quantum circuit, wherein the target quantum program is nested with a quantum program for realizing a target circuit unit in the quantum circuit, the target circuit unit comprises a rotating door, the quantum program carries a target rotating parameter for adjusting the rotating angle of the rotating door in the target circuit unit, and an execution result of the target quantum program is obtained, wherein the execution result of the target quantum program is used for representing the operation result of the quantum circuit, and the rotating angle of the rotating door in the target circuit unit can be adjusted through the target rotating parameter so as to change the operation result of the quantum circuit.
Inventors
- LV SHENJIN
- LIU SHUSEN
- HE YANG
Assignees
- 北京百度网讯科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20231205
Claims (20)
- 1. A method for obtaining an operation result of a quantum circuit comprises the following steps: The method comprises the steps of obtaining a target quantum program for realizing a quantum circuit, wherein the target quantum program is nested with a quantum program for realizing a target circuit unit in the quantum circuit, the target circuit unit comprises a revolving door, and the quantum program carries a target revolving parameter for adjusting the revolving angle of the revolving door in the target circuit unit; The execution result of the target quantum program is used for representing the operation result of the quantum circuit, and the rotation angle of a rotation door in the target circuit unit can be adjusted through the target rotation parameter so as to change the operation result of the quantum circuit; The obtaining the execution result of the target quantum program includes: converting the target quantum program into quantum computing tool compatible serialized data; and obtaining a calculation result corresponding to the serialized data by using the quantum calculation tool, wherein the calculation result corresponding to the serialized data is an execution result of the target quantum program.
- 2. The method of claim 1, wherein the deriving the target quantum program for implementing the quantum circuit comprises: Obtaining an initial quantum program, wherein the initial quantum program is nested with a subprogram to be built corresponding to a target circuit unit in the quantum circuit; based on the subprogram to be built, building a subprogram carrying the target rotation parameters for realizing the target circuit unit; and obtaining a target quantum program for realizing the quantum circuit based on the quantum program.
- 3. The method according to claim 2, wherein said building a subroutine for implementing said target circuit unit carrying said target rotation parameters based on said subroutine to be built comprises: Obtaining a preset subprogram based on the subprogram to be built, wherein the preset subprogram is used for realizing an equivalent circuit of the target circuit unit, and the equivalent circuit of the target circuit unit comprises a primary quantum gate equivalent to a rotating gate in the target circuit unit; And converting the initial rotation parameters of the native quantum gate in the preset subprogram into the target rotation parameters to obtain a processed preset subprogram, wherein the processed preset subprogram is a quantum subprogram carrying the target rotation parameters for realizing the target circuit unit.
- 4. A method according to claim 2 or 3, wherein the deriving an initial quantum program comprises: Responding to a circuit building operation to obtain the quantum circuit; based on the quantum circuit, an initial quantum program corresponding to the quantum circuit is obtained.
- 5. The method of claim 1, wherein the converting the target quantum program into quantum computing tool compatible serialized data comprises: converting target rotation parameters expressed according to a suffix representation method in the target quantum program into an expression sequence meeting a Poland representation method or an inverse Poland representation method; based on the expression sequence, quantum computing tool compatible serialization data are obtained.
- 6. The method of claim 1 or 5, wherein the obtaining, with the quantum computing tool, a computation result corresponding to the serialized data comprises: Under the condition that the quantum circuit needs to run locally, the serialized data is subjected to inverse serialization analysis by utilizing a local quantum processing module, so that an executable program of the quantum computing tool is obtained; And obtaining an execution result of the executable program by using a first quantum simulator in the quantum computing tool, wherein the execution result of the executable program is a computing result corresponding to the serialized data.
- 7. The method of claim 6, wherein the inverse serializing parsing of the serialized data results in an executable program of the quantum computing tool, comprising: Performing inverse serialization analysis on an expression sequence corresponding to the target rotation parameter in the serialized data based on a data reduction mode aiming at a Polish representation method or an inverse Polish representation method to obtain a calculation result corresponding to the expression sequence; and obtaining an executable program of the quantum computing tool based on a calculation result corresponding to the expression sequence.
- 8. The method of claim 1 or 5, wherein the obtaining, with the quantum computing tool, a computation result corresponding to the serialized data comprises: the cloud server is used for carrying out inverse serialization analysis on the serialized data by utilizing a cloud quantum processing module to obtain an executable program of the quantum computing tool, and obtaining an execution result of the executable program by utilizing a second quantum simulator or quantum hardware in the quantum computing tool, wherein the execution result of the executable program is a calculation result corresponding to the serialized data; and obtaining a calculation result corresponding to the serialized data, which is returned by the cloud server.
- 9. The method of any one of claims 1-8, further comprising: And obtaining performance optimization information of the quantum circuit comprising the target circuit unit, which is realized by the target quantum program, based on the execution result of the target quantum program, wherein the performance optimization information is used for evaluating whether the quantum circuit comprising the target circuit unit meets the design requirement.
- 10. An operation result acquisition device of a quantum circuit, comprising: The quantum circuit comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring a target quantum program for realizing a quantum circuit, the target quantum program is nested with a quantum program for realizing a target circuit unit in the quantum circuit, the target circuit unit comprises a revolving door, and the quantum program carries a target rotation parameter for adjusting the rotation angle of the revolving door in the target circuit unit; The second acquisition unit is used for obtaining an execution result of the target quantum program, wherein the execution result of the target quantum program is used for representing an operation result of the quantum circuit, and the rotation angle of a rotation door in the target circuit unit can be adjusted through the target rotation parameter so as to change the operation result of the quantum circuit; wherein the second obtaining unit is configured to: converting the target quantum program into quantum computing tool compatible serialized data; and obtaining a calculation result corresponding to the serialized data by using the quantum calculation tool, wherein the calculation result corresponding to the serialized data is an execution result of the target quantum program.
- 11. The apparatus of claim 10, wherein the first acquisition unit is configured to: Obtaining an initial quantum program, wherein the initial quantum program is nested with a subprogram to be built corresponding to a target circuit unit in the quantum circuit; based on the subprogram to be built, building a subprogram carrying the target rotation parameters for realizing the target circuit unit; and obtaining a target quantum program for realizing the quantum circuit based on the quantum program.
- 12. The apparatus of claim 11, wherein the first acquisition unit is configured to: Obtaining a preset subprogram based on the subprogram to be built, wherein the preset subprogram is used for realizing an equivalent circuit of the target circuit unit, and the equivalent circuit of the target circuit unit comprises a primary quantum gate equivalent to a rotating gate in the target circuit unit; And converting the initial rotation parameters of the native quantum gate in the preset subprogram into the target rotation parameters to obtain a processed preset subprogram, wherein the processed preset subprogram is a quantum subprogram carrying the target rotation parameters for realizing the target circuit unit.
- 13. The apparatus according to claim 11 or 12, wherein the first acquisition unit is configured to: Responding to a circuit building operation to obtain the quantum circuit; based on the quantum circuit, an initial quantum program corresponding to the quantum circuit is obtained.
- 14. The apparatus of claim 10, wherein the second acquisition unit is configured to: converting target rotation parameters expressed according to a suffix representation method in the target quantum program into an expression sequence meeting a Poland representation method or an inverse Poland representation method; based on the expression sequence, quantum computing tool compatible serialization data are obtained.
- 15. The apparatus according to claim 10 or 14, wherein the second acquisition unit is configured to: Under the condition that the quantum circuit needs to run locally, the serialized data is subjected to inverse serialization analysis by utilizing a local quantum processing module, so that an executable program of the quantum computing tool is obtained; And obtaining an execution result of the executable program by using a first quantum simulator in the quantum computing tool, wherein the execution result of the executable program is a computing result corresponding to the serialized data.
- 16. The apparatus of claim 15, wherein the second acquisition unit is configured to: Performing inverse serialization analysis on an expression sequence corresponding to the target rotation parameter in the serialized data based on a data reduction mode aiming at a Polish representation method or an inverse Polish representation method to obtain a calculation result corresponding to the expression sequence; and obtaining an executable program of the quantum computing tool based on a calculation result corresponding to the expression sequence.
- 17. The apparatus according to claim 10 or 14, wherein the second acquisition unit is configured to: the cloud server is used for carrying out inverse serialization analysis on the serialized data by utilizing a cloud quantum processing module to obtain an executable program of the quantum computing tool, and obtaining an execution result of the executable program by utilizing a second quantum simulator or quantum hardware in the quantum computing tool, wherein the execution result of the executable program is a calculation result corresponding to the serialized data; and obtaining a calculation result corresponding to the serialized data, which is returned by the cloud server.
- 18. The apparatus of any one of claims 10-17, further comprising: And the third acquisition unit is used for acquiring performance optimization information of the quantum circuit comprising the target circuit unit, which is realized by the target quantum program, based on the execution result of the target quantum program, wherein the performance optimization information is used for evaluating whether the quantum circuit comprising the target circuit unit meets the design requirement.
- 19. An electronic device, comprising: At least one processor; a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.
- 20. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-9.
Description
Quantum circuit operation result acquisition method and device and electronic equipment Technical Field The present disclosure relates to the field of computers, and more particularly to the field of quantum computing. Background Quantum programs are program code written in a quantum programming language for implementing quantum circuits (such as parameterized quantum circuits) according to designed quantum algorithms. However, the existing quantum program cannot meet the individual design requirement of the quantum circuit, and limits the design flexibility of the quantum circuit. Disclosure of Invention The disclosure provides a method and a device for acquiring an operation result of a quantum circuit and electronic equipment. According to an aspect of the present disclosure, there is provided a method for obtaining an operation result of a quantum circuit, including: The method comprises the steps of obtaining a target quantum program for realizing a quantum circuit, wherein the target quantum program is nested with a quantum program for realizing a target circuit unit in the quantum circuit, the target circuit unit comprises a revolving door, and the quantum program carries a target revolving parameter for adjusting the revolving angle of the revolving door in the target circuit unit; and obtaining an execution result of the target quantum program, wherein the execution result of the target quantum program is used for representing an operation result of the quantum circuit, and the rotation angle of a rotation door in the target circuit unit can be adjusted through the target rotation parameter so as to change the operation result of the quantum circuit. According to an aspect of the present disclosure, there is provided an operation result acquisition apparatus of a quantum circuit, including: The quantum circuit comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring a target quantum program for realizing a quantum circuit, the target quantum program is nested with a quantum program for realizing a target circuit unit in the quantum circuit, the target circuit unit comprises a revolving door, and the quantum program carries a target revolving parameter for adjusting the revolving angle of the revolving door in the target circuit unit; The second acquisition unit is used for obtaining an execution result of the target quantum program, wherein the execution result of the target quantum program is used for representing an operation result of the quantum circuit, and the rotation angle of the rotating door in the target circuit unit can be adjusted through the target rotation parameter so as to change the operation result of the quantum circuit. According to a third aspect of the present disclosure, there is provided an electronic device comprising: At least one processor; a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method described above. 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 the above-described method. According to a fifth aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method described above. In this way, in the scheme of the disclosure, the target quantum program is nested with the quantum program for realizing the target circuit unit in the quantum circuit, and the target rotating parameter for adjusting the rotating angle of the rotating door contained in the target circuit unit is carried in the quantum program, so that the rotating angle of the rotating door in the target circuit unit can be flexibly adjusted through the target rotating parameter, so as to change the operation result of the quantum circuit. In this way, the target quantum program for realizing any quantum circuit can be obtained by the scheme disclosed by the invention, in other words, the scheme disclosed by the invention can be applied to any quantum circuit, has stronger universality and can meet the personalized design requirement of the quantum circuit, thereby improving the design flexibility of the quantum circuit. Drawings The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein: Fig. 1 is a schematic implementation flow diagram of a method for obtaining an operation result of a quantum circuit according to an embodiment of the present disclosure; fig. 2 is a second implementation flow chart of a method for obtaining an operation result of a quantum circuit according to an embodiment of the disclosure; fig. 3 is a schematic implementation flow diagra