Hybrid compiling device and method for quantum-classical code sequence
By adding a quantum instruction set and a quantum engine to the processor, supporting the execution of hybrid classic-quantum algorithms, the problem that existing systems are difficult to support hybrid programs is solved, and efficient execution of hybrid algorithms and dynamic parameter optimization in quantum computers is achieved.
Patent Information
- Application Number
- CN202280090681.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-01-31
- Filing Date
- 2022-12-29
- Publication Date
- 2024-11-08
Smart Images

Figure CN118922811A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention generally relate to the field of quantum computing. More particularly, these embodiments relate to apparatus and methods for hybrid compilation of quantum-classical code sequences. Background Art
[0002] Quantum computing refers to a field of study related to computing systems that use quantum mechanical phenomena to manipulate data. These quantum mechanical phenomena, such as superposition (where a quantum variable can exist in multiple different states simultaneously) and entanglement (where multiple quantum variables have correlated states regardless of the distance between them in space or time), have no analogues in the world of classical computing and, therefore, cannot be implemented using classical computing devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0003] A better understanding of the present invention can be obtained from the following detailed description in conjunction with the following drawings, in which: Figures 1A-1F illustrates various views of an example quantum dot device according to one embodiment; Figure 2 One embodiment of a processor pipeline for processing quantum and non-quantum instructions is illustrated; Figure 3 An embodiment of a front-end circuit for a processor for processing quantum and non-quantum instructions is illustrated; Figure 4A-4B An embodiment of a quantum-classical processor interface is illustrated; Figure 5A-5B illustrates an example quantum circuit and program code for implementing the quantum circuit; Figure 6A-6B illustrates an example in which quantum instructions are generated by a compiler, decoded into μops, and executed within a quantum execution engine; Figure 7 A method according to an embodiment of the present invention is illustrated; Figure 8 One embodiment of a qubit index generator for addressing qubits within a quantum processor is illustrated; Fig. 9 A method for determining a qubit index value for identifying a qubit is illustrated; Fig.10 An example of a system for decoding and correcting quantum errors is illustrated; Fig.11 The diagram shows a typical quantum error correction cycle; Fig.12 illustrates a sequence of operations for compiling source code and linking object files; Fig.13illustrates an embodiment in which quantum runtime services / libraries are used to compile and link non-quantum code and quantum code from a unified source file; Fig.14A An implementation for performing parameter optimization is illustrated; Fig. 14B illustrates a hardware / software stack according to one implementation; Fig.15 An implementation of a quantum device compiler including a method for generating a quantum integration header file is illustrated; Fig.16 illustrates timing associated with execution of a quantum basic block; Fig.17 An embodiment is illustrated in which a host program performs dynamic parameter updates to quantum instructions; Fig.18 illustrates a sequence of operations and components for generating a quantum integration header file; Fig.19 Figure 1 shows the quantum basic block descriptors and instructions added to the ELFQ file header; Fig. 20 illustrates a series of transactions between a host processor and a quantum runtime executing on a quantum computing unit; Fig.21 illustrates a quantum gate used to test an embodiment of the present invention; and Figure 22-23 The test results are shown graphically. DETAILED DESCRIPTION
[0004] In the following description, for the purpose of explanation, many specific details are set forth in order to provide a thorough understanding of the embodiments of the invention described below. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without some of these specific details. In other examples, well-known structures and devices are shown in block diagram form to avoid obscuring the basic principles of embodiments of the invention.
[0005] introduce Quantum computers use quantum mechanical phenomena such as superposition and entanglement to perform calculations. Compared to digital computers that store data in one of two clear states (0 or 1), quantum computing uses quantum bits (qbits), which can be in a superposition of states. Quantum bits can be implemented using physically distinguishable quantum states of elementary particles such as electrons and photons. For example, the polarization of photons can be used, where the two states are vertical polarization and horizontal polarization. Similarly, the spin of an electron can have distinguishable states, such as "spin up" and "spin down".
[0006] Quantum states are typically represented by the bracket notation |0> and |1>. In traditional computer systems, bits are exclusively in one state or the other (i.e., "0" or "1"). However, a qbit in a quantum mechanical system can be in a superposition of both states simultaneously, a feature that is unique and fundamental to quantum computing.
[0007] The quantum computing system executes an algorithm containing quantum logic operations performed on qubits. The sequence of operations is statically compiled into a calendar, and the qubits are addressed using an indexing scheme. The algorithm is then executed a sufficient number of times until the confidence interval of the calculated answer is above a threshold (e.g., ~95+%). Hitting the threshold means that the expected algorithm result has been achieved.
[0008] A variety of different technologies capable of manipulating and reading quantum states have been used to implement qubits. These include, but are not limited to, quantum dot devices (spin-based and spatial-based), trapped ion devices, superconducting quantum computers, optical lattices, nuclear magnetic resonance computers, solid-state NMR Kane quantum devices, electron-on-helium quantum computers, cavity quantum electrodynamics (CQED) devices, molecular magnet computers, and fullerene-based ESR quantum computers, to name a few. Thus, although quantum dot devices are described below with respect to certain embodiments of the present invention, the basic principles of the present invention may be employed in conjunction with any type of quantum computer, including but not limited to those listed above. The specific physical implementation for a qbit is independent of the embodiments of the present invention described herein.
[0009] Quantum dot devices Quantum dots are small semiconductor particles, typically a few nanometers in size. Due to this small size, quantum dots operate according to the rules of quantum mechanics, which have optical and electronic properties that are different from macroscopic entities. Quantum dots are sometimes called "artificial atoms" to allude to the fact that quantum dots are single objects with discrete bound electronic states, as is the case with atoms or molecules.
[0010] Figures 1A-1F are various views of a quantum dot device 100 that may be used with the embodiments of the present invention described below. Figure 1A 1 is a top view of a portion of a quantum dot device 100 with some of the material removed such that first gate line 102, second gate line 104, and third gate line 106 are visible. Although many of the figures and descriptions herein may refer to a particular set of lines or gates as "barriers" or "quantum dot" lines or gates, respectively, this is only for ease of discussion, and in other embodiments, the roles of "barriers" and "quantum dot" lines and gates may be switched (e.g., a barrier gate may instead act as a quantum dot gate, and vice versa). Figures 1B-1F yes Figure 1AA cross-sectional side view of a quantum dot device 100; in particular, Figure 1B It passes through Figure 1A A view of section BB, Figure 1C It passes through Figure 1A A view of section CC, Figure 1D It passes through Figure 1A A view of the cross section DD, Figure 1E It passes through Figure 1A A view of a cross section EE, and Figure 1F It passes through Figure 1A A cross-sectional view of FF.
[0011] The quantum dot device 100 can be operated in any of a variety of ways. For example, in some embodiments, an electrical signal such as a voltage, current, radio frequency (RF) and / or microwave signal can be provided to one or more of the first gate line 102, the second gate line 104 and / or the third gate line 106 to form a quantum dot (e.g., a quantum dot based on electron spin or a quantum dot based on hole spin) in the quantum well stack 146 under the third gate 166 of the third gate line 106. The electrical signal provided to the third gate line 106 can control the potential of the quantum well under the third gate 166 of the third gate line 106, and the electrical signal provided to the first gate line 102 (and / or the second gate line 104) can control the potential barrier under the first gate 162 of the first gate line 102 (and / or the second gate 164 of the second gate line 104) between adjacent quantum wells. Quantum interactions between quantum dots in different quantum wells in quantum well stack 146 (eg, beneath different quantum dot gates) may be controlled in part by the potential energy barrier provided by a barrier potential applied between them (eg, through an intervening barrier gate).
[0012] In general, the quantum dot device 100 disclosed herein can further include a source of a magnetic field (not shown) that can be used to create energy differences in the generally degenerate quantum dot states (e.g., spin states of quantum dots based on electron spins), and the quantum dot states (e.g., spin states) can be manipulated by applying electromagnetic energy to the gate lines to create quantum bits that can be computed. The source of the magnetic field can be one or more magnet wires, as discussed below. Thus, the quantum dot device 100 disclosed herein can be capable of manipulating the position, number, and quantum state (e.g., spin) of the quantum dots in the quantum well stack 146 by controlled application of electromagnetic energy.
[0013] In the quantum dot device 100, the gate dielectric 114 can be disposed on the quantum well stack 146. The quantum well stack 146 can include: at least one quantum well layer 152 (not shown in FIG. 1), in which quantum dots can be positioned during operation of the quantum dot device 100. The gate dielectric 114 can be any suitable material, such as a high-k material. A plurality of parallel first gate lines 102 can be disposed on the gate dielectric 114, and a spacer material 118 can be disposed on the sides of the first gate lines 102. In some embodiments, a patterned hard mask 110 can be disposed on the first gate lines 102 (having a pattern corresponding to the pattern of the first gate lines 102), and the spacer material 118 can extend upward along the side of the hard mask 110, as shown. The first gate lines 102 can each be a first gate 162. Different ones of the first gate lines 102 may be electrically controlled in any desired combination (eg, each first gate line 102 may be electrically controlled separately, or some or all first gate lines 102 may be shorted together in one or more groups, as desired).
[0014] A plurality of parallel second gate lines 104 may be disposed above the first gate lines 102 and between the first gate lines 102. As illustrated in FIG. 1 , the second gate lines 104 may be arranged perpendicular to the first gate lines 102. The second gate lines 104 may extend above the hard mask 110 and may include: a second gate 164 extending downward toward the quantum well stack 146 and contacting the gate dielectric 114 between adjacent gate lines in the first gate lines 102, such as Figure 1D . In some embodiments, the second gate 164 may fill the area between adjacent gate lines / spacer material structures in the first gate line 102 / spacer material 118 structure; in other embodiments, an insulating material (not shown) may be present between the first gate line 102 / spacer material 118 structure and the adjacent second gate 164. In some embodiments, the spacer material 118 may be disposed on the side of the second gate line 104; in other embodiments, no spacer material 118 may be disposed on the side of the second gate line 104. In some embodiments, the hard mask 115 may be disposed above the second gate line 104. Multiple second gates in the second gates 164 of the second gate lines 104 are electrically continuous (due to the shared conductive material of the second gate lines 104 above the hard mask 110). Different gate lines in the second gate lines 104 may be electrically controlled in any desired combination (e.g., each second gate line 104 may be electrically controlled separately, or some or all of the second gate lines 104 may be shorted together in one or more groups, as desired). The first gate lines 102 and the second gate lines 104 together may form a grid.
[0015] A plurality of parallel third gate lines 106 may be disposed above the first gate line 102 and the second gate line 104 and between the first gate line 102 and the second gate line 104. As illustrated in FIG. 1 , the third gate line 106 may be arranged obliquely with the first gate line 102 and obliquely with the second gate line 104. In particular, the third gate line 106 may be arranged obliquely above an opening in a grid formed by the first gate line 102 and the second gate line 104. The third gate line 106 may include: a third gate 166 extending downwardly to the gate dielectric 114 in the opening in the grid formed by the first gate line 102 and the second gate line 104; therefore, each third gate 166 may border two different first gate lines 102 and two different second gate lines 104. In some embodiments, the third gate 166 may border the insulating material 128; in other embodiments, the third gate 166 may fill the opening in the grid (e.g., contacting the spacer material 118 disposed on the side adjacent to the first gate line 102 and the second gate line 104, not shown). Additional insulating material 117 may be disposed on and / or around the third gate line 106. Multiple of the third gates 166 of the third gate lines 106 are electrically continuous (due to the shared conductive material of the third gate lines 106 above the first gate line 102 and the second gate line 104). Different ones of the third gate lines 106 may be electrically controlled in any desired combination (e.g., each third gate line 106 may be electrically controlled separately, or some or all of the third gate lines 106 may be shorted together in one or more groups, as desired).
[0016] although Figure 1A -F illustrates a specific number of first gate lines 102, second gate lines 104, and third gate lines 106, but this is for illustration purposes only, and any number of first gate lines 102, second gate lines 104, and third gate lines 106 may be included in the quantum dot device 100. Other examples of arrangements of the first gate lines 102, second gate lines 104, and third gate lines 106 are possible. Electrical interconnects (e.g., vias and wires) may contact the first gate lines 102, second gate lines 104, and third gate lines 106 in any desired manner.
[0017] Not shown in FIG. 1 is an accumulation region that may be electrically coupled to a quantum well layer of the quantum well stack 146 (e.g., laterally close to the quantum well layer). The accumulation region may be separated from the gate line by a thin layer of intervening dielectric material. The accumulation region may be a region where carriers accumulate (e.g., due to doping or due to the presence of a large electrode that pulls carriers into the quantum well layer), and may act as a reservoir for carriers that may be selectively dragged into a region of the quantum well layer below the third gate 166 (e.g., by controlling the voltage on the quantum dot gate, the first gate 162, and the second gate 164) to form a carrier-based quantum dot (e.g., an electron or hole quantum dot, including a single charge carrier, a plurality of charge carriers, or no charge carriers). In other embodiments, the quantum dot device 100 may not include a lateral accumulation region, but may instead include doped layers within the quantum well stack 146. These doped layers may provide carriers to the quantum well layer. Any combination of accumulation regions (eg, doped or undoped) or doped layers in the quantum well stack 146 may be used in any of the embodiments of the quantum dot device 100 disclosed herein.
[0018] Device and method for hybrid classical quantum computer After Richard Feynman asked in 1982 whether quantum computers could be used to efficiently simulate quantum physics, many efforts to research quantum computers have focused on their versatility and efficiency compared to classical computing. One such example is David Deutsch's 1985 quantum Turing machine, which can be programmed to perform any computational task that can be performed by any physical object.
[0019] Compared to theory and algorithms, quantum physics machines are still in their infancy. Efforts to build quantum information processing systems have so far achieved little success. Small quantum computers that can perform a small set of quantum operations on very few quantum bits represent the state of the art in quantum computing. In addition, quantum states are fragile in the sense that they only remain coherent for a limited duration. This divergence between algorithms and physical machines has driven the efforts to invent hybrid classical-quantum algorithms. Some recent quantum algorithm developments have focused on short-depth quantum circuits to implement quantum computing formed as subroutines embedded in larger classical optimization loops, such as variational eigensolvers (PJJ O'Malley, 2016). Quantum languages, tools, and processes have been developed to provide software layers / stacks to translate and optimize applications to quantum physics layers to cope with strict resource constraints in quantum computing (Frederic T. Chong, 2017, September 14).
[0020] On the hardware side, classical computers have been used to perform error correction for quantum computing. The "quantum coprocessor" model is the most advantageous prevailing execution model, in which the classical CPU controls the quantum processing unit in a manner similar to how the CPU interacts with the GPU in a modern computer system. As described in (X. Fu, May 2016) and (X. Fu, 2018), the microarchitecture for the experimental superconducting quantum coprocessor includes features such as: an arbitrator on the code acquisition data path for directing classical instructions to the host CPU and quantum instructions to the quantum coprocessor; an exchange register file for synchronizing register files between the host CPU and the quantum coprocessor; and a quantum instruction cache.
[0021] However, the microarchitecture for these mechanisms is not well-defined, and explicit support for hybrid classical-quantum programs is missing. Therefore, it is unclear how quantum coprocessors will be implemented in quantum computers, especially how they will be implemented in quantum computers required to run a diverse set of quantum programs. Flexible and programmable models have not yet been developed for executing hybrid classical-quantum algorithms.
[0022] One embodiment of the present invention adds a set of quantum instructions to the instruction set architecture (ISA) of a processor such as a CPU. As an example, these instructions can be included in an extension to the ISA (e.g., such as the AVX-512 extension for the x86 platform). In addition, in one embodiment, a quantum engine is added to the execution unit of the processor, and new quantum instructions are obtained, decoded, scheduled, and executed on the functional unit of the quantum engine. In one embodiment, the quantum engine uses a shared register stack and / or system memory to interact with the classical execution engine. When executing quantum instructions (or in some embodiments described herein, quantum μops), the quantum execution engine generates control signals to manipulate the state of the quantum bits within the quantum processor. The quantum engine also executes instructions to take the measurement results of a specified set of quantum bits and store the results. In these embodiments, the quantum / classical interface provides connectivity between the quantum processor and the quantum engine of the classical processor.
[0023] Figure 2 One embodiment of a processor or core 210 is illustrated, which fetches, decodes and executes quantum instructions 201A and non-quantum instructions 201B, thereby using the same pipeline resources as non-quantum instructions 201B. The processor / core 210 of this embodiment supports quantum extensions to the existing ISA of the processor / core 210 (e.g., extending the ISA to include quantum instructions 201A). Program code 205C including quantum and non-quantum instructions is generated by a compiler 205B from source code 205A written by a programmer (e.g., using an extended ISA). Various source / program code examples are provided below.
[0024] Quantum and non-quantum instructions 201A-B are fetched from memory 205 at the front end of the instruction pipeline and stored in a level 1 (L1) instruction cache 201. Instructions and data may also be stored in a level 2 or level 3 cache within a cache / memory subsystem 215, which manages memory requests and cache coherency.
[0025] Decoder 202 decodes instruction 201A-B into micro-operations or μops 203A, which are scheduled for execution by scheduler 203 and executed by execution circuit 204. In one embodiment, certain stages of the pipeline are enhanced to include hardware support for processing quantum instructions 201B, while other stages are unchanged. For example, quantum decoding circuit 202A may be added to decoder 202 for decoding quantum instructions 201A, just as non-quantum decoding circuit 202B decodes non-quantum instructions 201B. Although in Figure 2 202A and non-quantum decoding circuitry 202B may include a common or overlapping set of circuits and / or microcode. For example, in one embodiment, an existing decoder may be extended to include microcode support for quantum instructions (e.g., in a microcode ROM) to generate a new set of quantum μops. Depending on the processor architecture, decoder 202 includes other decoding circuitry, such as a set of decode table structures (see, e.g., Figure 3 and associated text).
[0026] In one embodiment, decoder 202 generates a sequence of μops 203A in response to decoding instructions 201A-B. In implementations with quantum and non-quantum instructions, the μops may include a mixture of quantum μops and non-quantum μops, which are then scheduled by instruction scheduler 203 for execution.
[0027] The quantum and non-quantum μops 203A generated by decoder 202 may be initially queued for execution within one or more μop queues of scheduler 203, which dispatches μops from the μop queues based on dependencies and / or execution resource availability. Embodiments of the present invention may be implemented on a variety of different types of processors with different types of schedulers. For example, in one embodiment, a set of execution "ports" couples scheduler 203 to execution circuitry 204, where each execution port is capable of issuing μops to a specific set of functional units 204C-E. Figure 2In the example architecture shown in , for example, SIMD and floating point (FP) μops may be issued by scheduler 203 on FP / SIMD execution ports coupled to a set of FP / SIMD functional units 204C, and integer μops may be issued on integer ports coupled to a set of integer functional units 204D. Although only two types of non-quantum functional units are shown for simplicity, processor / core 210 may include various other / additional non-quantum functional units (e.g., such as load / store address generation units, branch units, additional SIMD and integer units, etc.).
[0028] exist Figure 2 In the particular embodiment shown in , the quantum engine functional unit 204E shares the same set of register files 204A-B used by the traditional processor functional units 204C-D. In this particular example, the register files 204A-B include: FP / SIMD register file 204A, which stores floating point and SIMD operands used by the FP / SIMD functional unit 204C; and integer register file 204B, which stores integer operands for the integer functional unit 204D. In one implementation, the FP / SIMD register file 204A includes 512-bit vector registers, and the integer register file 204B includes 64-bit scalar registers. Of course, different processor architectures will use different types of registers shared by the quantum engine functional unit 204E. Various other types of registers may also be used, such as a set of control / status registers and mask registers.
[0029] In embodiments where quantum μops are mixed with non-quantum μops, quantum μops are issued on one or more quantum ports to a collection of quantum engine functional units 204E, which execute quantum μops to perform basic quantum operations. For example, quantum engine functional unit 204E, in response to quantum μops, can generate control signals on quantum-classical interface 206 to manipulate and retrieve measurement results of quantum bits of quantum processor 207.
[0030] The quantum-classical interface 206 includes a digital-to-analog (DA) circuit to convert the digital quantum control signal generated by the quantum engine functional unit 204E into an analog signal required to control the quantum processor 207 (e.g., such as a codeword triggered pulse generation (CTPG) unit and an arbitrary waveform generator (AWG) described below), and the quantum-classical interface 206 also includes an analog-to-digital (AD) circuit to convert the physical quantum bit measurement results into digital result data.
[0031] In one embodiment, quantum-classical interface 206 is integrated on the same semiconductor chip as other components of the instruction processing pipeline (e.g., instruction circuit 204, scheduler 203, decoder 202, etc.). As discussed in detail below, different types of circuit / logic components may be used depending on the specific physical implementation of quantum processor 207.
[0032] Figure 3 An embodiment is illustrated in which quantum instruction processing support is added to a low power processing pipeline, including a pre-decode buffer 301B, a 2-way decoder 302 with dual sets of quantum / non-quantum decoder circuits 202A-B, 302A-B, dual lookup tables for instruction translation (XLAT), and a μ-code ROM 304. In one embodiment, the XLAT components 303, 305 and the μ-code ROM 304 are extended to support quantum instructions, as indicated by logic blocks 303Q-305Q. The pre-decode buffer 301B detects and marks macroinstruction boundaries before being fully decoded into μops by the 2-way decoder 302.
[0033] Operands for quantum and non-quantum μops are stored in a set of shared registers 321 (as described above) and accessed by quantum functional unit 320 when executing the μop. QC interface 320 controls the operation of quantum processor 207 in response to quantum μops.
[0034] exist Figure 4A Different examples of quantum-classical interfaces 206 are illustrated in FIG. Figure 4A The QC interface 206 in the embodiment includes: a plurality of μop units 401A-C, which generate codewords in response to μops executed by the quantum engine functional unit 204E to control the operation of a plurality of codeword trigger pulse generation (CTPG) units 402A-C. In response, the CTPG units 402A-C generate pulse sequences to control the qubits of the quantum processor 207. Once the quantum processor 207 has reached a specified execution state, the quantum measurement result is taken by one or more of the measurement result discrimination units (MDUs) 403A-B.
[0035] Figure 4BThe QC interface 206 shown in FIG. 4 includes a set of components for performing microwave complex signal generation, including an RF microwave unit 451, a multi-channel arbitrary waveform generator (AWG) 452, one or more digital-to-analog converters (DACs) 453, and one or more measurement units 454. In one embodiment, the input to each of these components includes a set of codewords generated by the quantum engine functional unit 204E, and the output is a simulated waveform that manipulates the state of the qubits of the quantum processor 207. The measurement unit 454 measures the current state associated with one or more qubits at a specified point in the execution.
[0036] In order to further guide the analysis and discussion, Figure 5A A specific example is shown in FIG. Figure 5A The quantum circuit for the many-body disordered Hamiltonian is shown as time evolving. Note that R is derived from several parameters x and R y The angle through which it rotates. In particular, hk where k∈{0,1,…,5,6} z and hk x are randomly generated and used to simulate large multi-body systems that require a much larger number of qubits than the underlying quantum chip supports.
[0037] exist Figure 5B An example of a quantum program that uses this circuit for part of its computation is illustrated in Figure 5B Includes a mixture of quantum and non-quantum instructions (as indicated by the comments to the right of the source code). In this example, NR is the number of out-of-order realizations (i.e., multiple small random realizations used to simulate a large multi-body system), NQ is the number of qubits, NP is the number of iterations to achieve the required accuracy in probability (Pr), NT is the number of Trotter steps, and a[i] accumulates qubit measurements. The probability of a qubit being in state |0> or |1> is obtained by repeated measurements (NP) and averaging.
[0038] This program structure shows how classical and quantum operations can be tightly interwoven and executed on the classical-quantum processing architecture described herein. The most efficient way to execute this program is to process all instructions in a pipeline such as those described above using a quantum engine functional unit 204E that controls qubits that are configured as execution engine counterparts (such as integer, floating point, etc.) to other classical execution engines 204A-B.
[0039] Figure 6A-6B Provided in response to Figure 5A Examples of quantum operations performed by using the program code in . In particular, Fig. 6A The diagram shows the Figure 5A 501 of the quantum assembly language (QASM) code 601 of the highlighted portion of the quantum circuit in FIG. 501. The QASM code 601 is compiled into the hybrid processor program code 602 in the memory 205. In this example, registers RBX and RBX+1 from the shared register file 321 or 204B are used to hold qubit indices to address logical qubits #2 and #3, respectively, in this particular example. The mapping of the relevant portion of the QASM code 601 to the hybrid processor program code 602 is indicated by the arrows.
[0040] Figure 6B The diagram illustrates how the quantum microinstruction QCNOTUP (used to implement a CNOT gate) is decoded by the decoder 202 into a series of μops 605. The μops 605 are executed by the quantum engine functional unit 204E to generate a codeword having a specified codeword or command packet format 606. In one particular format, the first data field indicates the qubit on which the operation is to be performed (in the example, qubit 3), the second data field indicates the channel on which the operation is to be transmitted (channel 4), the third field is to indicate the command state (e.g., single command state), and the fourth data field is to indicate the type of qubit (transmit sub-qubit). Of course, the underlying principles of the present invention are not limited to any particular encoding format.
[0041] exist Figure 7 A method according to one embodiment of the present invention is illustrated in . The method may be implemented within the context of the processor architecture described above, but is not limited to any particular processor or system architecture.
[0042] At 701, source code containing quantum instructions is compiled to generate runtime program code with quantum and non-quantum instructions. At 702, quantum / non-quantum instructions are retrieved from memory and stored in a local cache (e.g., L1 instruction cache) or instruction buffer. As mentioned, quantum instructions can be freely mixed with non-quantum instructions within the pipeline.
[0043] At 703, quantum and non-quantum instructions are decoded into sets of quantum and non-quantum μops, respectively, and the quantum and non-quantum instructions are stored in a queue before execution. At 704, quantum / non-quantum μops are scheduled for execution based on μops and / or resource dependencies. For example, if a first μop depends on the result of a second μop, the first μop can be scheduled for execution only when the data produced by the second μop is available in one of the registers. Similarly, if a particular functional unit is busy, the scheduler can wait for an indication that the functional unit is available before scheduling the μop that requires the functional unit. Various other / additional scheduling techniques (e.g., scheduling based on priority, register load, etc.) can be implemented.
[0044] At 705, the quantum μops and non-quantum μops are executed on corresponding functional units within the execution circuitry. As mentioned, a set of shared registers may be used to store the source and destination operands required by these μops.
[0045] At 706, the results generated by the execution of the quantum μop can be used as input to the interface unit to control the quantum state of the qubits in the quantum processor. In one embodiment, a series of codewords or command packets can be generated that identify the quantum channel, one or more qubits within the quantum processor, the qubit type, and / or the command state. The specific physical operation performed in response to the codeword or command packet is based on the basic type of quantum processor used.
[0046] The embodiments described herein integrate quantum instructions within existing processor pipelines. Due to the tight integration, these embodiments significantly reduce various overheads / bottlenecks associated with current coprocessor designs. These overheads / bottlenecks include, for example, communication between the classical computing layer / module and the quantum computing layer / module in the software stack and between the classical CPU and the quantum chip via message queues. Given the relatively small size of quantum routines, current GPU-based coprocessor implementations are inefficient.
[0047] The hybrid coprocessor model reduces some of the overhead due to the increased classical processing power. In a specific implementation that supports the hybrid coprocessor model, many new microarchitectural mechanisms are introduced. However, these microarchitectural mechanisms are not clearly defined as the boundary between the classical CPU and the quantum coprocessor.
[0048] In contrast, in the hybrid architecture described herein, the classical computing pipeline is equipped to fully support a defined set of quantum instructions that can be freely intermixed with non-quantum instructions both at the front end of the pipeline (i.e., at the macroinstruction level) and within the back end of the pipeline (e.g., where quantum μops are mixed with non-quantum μops), and executed on functional units within the execution circuitry of the processor.
[0049] Scalable qubit addressing mode for quantum execution engines and / or coprocessors In quantum computing, a qubit is a unit of quantum information that is the quantum analog of a classical binary bit. Computations are achieved by applying quantum gates representing quantum logic operations directly to the qubits. Mathematically, this computational process is described as a qubit undergoing a unitary transformation. At the completion of the computation, the qubit is measured to obtain information about the state of the qubit.
[0050] Therefore, in order to describe quantum operations, it is necessary to identify the quantum bit or quantum bit set to which the operation is to be applied. In a quantum program, each quantum instruction needs to encode both the operation to be performed and the one or more quantum bits on which the operation is to be performed. In existing quantum instruction set architectures (such as QASM, open QASM, QIS, etc.), register operands are usually encoded in the opcode of the instruction. This scheme works for classical computing, because the number of registers is very limited (such as 16, 32, 64, etc.). However, this scheme is not scalable for quantum computing, because quantum instructions will eventually need to address a very large number of quantum bits. Therefore, encoding the quantum bit address in the opcode field of the quantum instruction will decompose the instruction width.
[0051] As described above, in one embodiment, quantum instructions and non-quantum instructions are processed together within a shared processor pipeline. Thus, quantum instructions can rely on the same addressing modes as those available to non-quantum instructions. Thus, qubits in this embodiment are addressed in a similar manner to non-quantum instructions that access system memory, thereby providing an address space large enough to accommodate a large number of qubits.
[0052] like Figure 8 As shown in FIG. 1 , in this embodiment, the quantum engine functional unit 204E includes: a qubit index generation unit (QIG) 802 that determines a qubit index value or qubit ID in response to one or more μops 805. One or more quantum operation units 801 process the operations specified by the μops. The qubit index value (e.g., in the example, for qubit 3,011) is then incorporated into a codeword / command packet 606, possibly together with one or more commands generated by the quantum operation unit 801 in response to processing the μops 805.
[0053] QIG 802 may operate according to different addressing modes supported by the processor. In one embodiment, the instruction identifies a shared register in shared registers 321 that contains a qubit index value (sometimes referred to as a qubit ID). It may then use the qubit index value to identify a qubit within codeword / command packet 606, and / or use the qubit index value to perform an operation to generate one or more additional qubit index values. For example, it may add the qubit ID value to an integer specified by the μop to generate a second qubit ID.
[0054] The following example demonstrates one way in which QIG 802 generates qubit IDs using x86 assembly syntax in response to μops. These operations may be performed within an x86 pipeline extended to support quantum instructions. However, the same general principles may be implemented on any processor architecture.
[0055] A single qubit instruction “QIROTX[RDI],1” applies the X gate to the qubit number stored in RDI. Thus, if RDI contains 5, then the X gate is applied to qubit number 5. In this example, QIG 802 determines the qubit ID simply by reading the value stored in RDI (which, in this example, is one of shared registers 321). In this embodiment, the RDI value was previously stored by another μop. As another example, if architectural register RBX contains the value 2, then a two-qubit instruction “QCNOTUP[RBX+3],” applies a CNOT operation, where qubit 2 (q[2]) is the control qubit and qubit 5 (q[5]) is the target qubit. The QIG interprets the [RBX+3] notation as: the ID of the control qubit is stored in RBX, and the ID of the control qubit+3 is the target qubit ID. Thus, the addressing scheme is extended so that two different qubits can be addressed with a single instruction (i.e., CNOT). In contrast, in classical computing, only one memory location is addressed per instruction.
[0056] Figure 8Also illustrated is a codeword trigger pulse generator (CTPG) 402A, which includes control logic and an analog-to-digital converter for interpreting codewords / command packets 606 to identify one or more qubits (in the example, Q3) and generate a pulse sequence to implement a specified quantum operation. When all quantum operations have been performed, as specified by program code 205C, quantum operation circuitry 801 and QIG 802 generate codewords / command packets 606 to cause one or more MDUs 403A-B to take measurement results of one or more qubits (as specified by QIG 802 that generated the qubit index). As mentioned, the MDU includes analog-to-digital circuitry to convert analog measurement results into digital values, which are then processed by a quantum error correction unit 808 to detect and potentially correct errors. If valid result data has been received, it can be stored in one or more of the shared registers 321 and / or accumulated with prior measurement data. In addition to error correction, the measurement results can also be used for program flow control based on measurement result feedback.
[0057] The quantum error correction unit 808 may implement various techniques for detecting and correcting quantum errors. For example, in one embodiment, an error decoder (within the QEC unit 808) decodes multi-qubit measurements from the quantum processor 207 to determine whether an error has occurred, and if so, implements corrective action (if possible). It is possible to take erroneous measurements from multiple qubits in a manner that does not disturb the quantum information in the encoded state of the qubit (e.g., using an auxiliary qubit). In response, the QEC unit 808 generates error syndrome data, based on which it can identify the error that has occurred and implement corrective actions. In one embodiment, the error syndrome data includes a stabilizer code, such as a surface code. In some cases, the response may be simply to reinitialize the qbit and start over. However, in other cases, modifications to the quantum algorithm implemented in the quantum program code 205C may be made to stabilize the region of the quantum processor responsible for the error (e.g., where the compiler 205B includes a just-in-time (JIT) compiler). In either case, the CTPG 402A performs basic physical operations under the control of the codeword / command packet 606 generated by the QEFU 204E. For example, the CTPG 402A may generate electromagnetic pulses to adjust the phase of one or more qbits based on a detected phase error, or to reset the phase / spin of all qbits if reinitialization is required.
[0058] The qubits are addressed in a manner similar to how the address memory of a classical CPU provides the scalability characteristics / attributes required for future quantum processor implementations. In particular, the embodiments described above provide qubit indexing that integrates seamlessly within existing processor ISAs and scales to large numbers of qubit systems. These embodiments also remove pressure from the quantum instruction opcode space by quantum extensions to x86 or other architectures to address the qubit space and integrate quantum operations into existing processor pipelines.
[0059] exist Fig. 9 A method according to an embodiment of the present invention is illustrated in FIG. The method can be implemented on the architecture described above, but is not limited to any specific processor or system architecture.
[0060] At 901, quantum and non-quantum instructions from runtime program code are retrieved and decoded to generate quantum and non-quantum μops. At 902, an index generation unit evaluates the quantum μop including a register identifier and optionally evaluates one or more values included with the μop to determine a qubit index value. As described above, the index may be generated using a variety of techniques including reading a qubit index value from a register identified by the μop and using an integer value included with the μop to generate additional qubit index values.
[0061] At 903, the quantum execution circuit generates a codeword specifying a quantum operation to be performed on the qubit identified by the calculated qubit index value. At 904, the quantum operation is performed on the specified qubit. At 905, qubit measurements are performed in response to another codeword generated based on the additional μop. At 906, the analog measurement results made on one or more of the qubits are converted to digital values. Error correction and / or flow control can then be performed based on the resulting digital result values stored in the register file of the processor.
[0062] Fig.10 A typical quantum computer arrangement with error detection and correction is illustrated. The illustrated example includes: a quantum computer runtime 1001 (e.g., implemented in QASM program code) executed by a quantum execution pipeline 1005 of a quantum execution unit 1002. By way of example and not limitation, the quantum execution unit 1002 may be an application specific integrated circuit ASIC, a general purpose processor, or a programmable functional unit for executing quantum instructions.
[0063] In response to the execution of the quantum program code, the quantum execution pipeline 1005 transmits commands to the qubit drive controller 1010, which performs physical quantum operations on the quantum chip 1020. Depending on the implementation, this can be accomplished by a sequence of RF pulses to manipulate the qubits Q0-Q15 of the quantum chip 1020.
[0064] After all or a certain number of program operations have been completed, the measurement unit 1015 reads / estimates the quantum state of one or more of the qubits Q0-Q15, and provides the measurement result to the decoding / error correction unit 1016, which uses error correction decoding technology to decode the measurement result. For example, the decoding / error correction unit 1016 decodes the multi-qubit measurement results from the quantum processor 1020 to determine whether an error has occurred, and if so, implements corrective measures where possible. It is possible to take error measurements from multiple qubits in a manner that does not disturb the quantum information in the encoded state of the qubit (e.g., using an auxiliary qubit). In response, error syndrome data can be generated, based on which errors and correction operations can be identified. In one embodiment, the error syndrome data includes a stabilizer code, such as a surface code. In some cases, the response may be simply to reinitialize and restart qbit Q0-Q15. However, in other cases, modifications to the quantum algorithm can be implemented in the quantum program code 1001.
[0065] The decoded / corrected results are provided to the quantum execution unit 1002 for further processing according to the quantum runtime 1001. Typical operation flow of current quantum computer designs based on fixed cycle times for each quantum operation performed by the quantum execution pipeline 1005 and each measurement result taken by the measurement unit 1015.
[0066] Fig.11 An embodiment of a quantum error correction cycle that can be implemented by the architecture described herein is illustrated. At 1101, the logical qubit state of the system is initialized. For example, if electron spins are used as quantum states, electrons within the quantum system can be prepared (e.g., the electrons are initialized to a specific spin orientation, and / or entangled using electromagnetic control signals from a quantum controller).
[0067] At 1102, the state of the quantum system evolves in response to additional electromagnetic inputs specified by the quantum runtime 1001 and implemented by the quantum controller 1010. For example, different sets of qubits, including satellite qubits, can be entangled and manipulated according to the quantum runtime 1001.
[0068] At 1103, a measurement of the quantum system is taken. For example, the current spin of one of the entangled electrons may be measured. The system may subsequently be reinitialized before the next measurement (i.e., to account for the fact that taking a measurement or learning any information about the quantum system disturbs the quantum state). The physical qubits may be measured periodically during each error correction cycle.
[0069] At 1104, error detection / classification is performed on the measured results to determine if an error has occurred. The error loop completes an error correction operation at 1105 using a specified set of codes, which attempts to correct any detected errors.
[0070] Hybrid compilation device and method for quantum-classical code sequences The execution flow of quantum algorithms for current quantum computing systems consists of compiling long lists of quantum logic gates, which are organized into quantum circuits and executed serially on a collection of laboratory instruments that generate sequences of RF pulses to manipulate the qubits of a quantum processor (e.g., such as an arbitrary waveform generator).
[0071] There is very little interaction and feedback between the quantum algorithms running on the accelerator and the classical processor or control unit. This is due to the fact that very few mechanisms exist for integrating quantum computing logic with classical logic using the tools available and developed in the 60 years of classical computing.
[0072] The implementation described below utilizes existing classical tools to provide complex runtime management of instruction flows for both quantum accelerator hardware (sometimes referred to below as quantum controllers) and classical computing hardware. In particular, standard compilation tools such as compilers, linkers, and assemblers, as well as OS support tools such as libraries and program loaders, are extended to implement a new quantum runtime library for managing the interaction of quantum accelerator logic and classical instruction flows. This is accomplished in part by enhancing OS loader files (executable and linkable format (ELF) files). In addition, quantum basic blocks (QBBs) are defined and implemented, which group the quantum acceleration portion of the program code into quantum measurement-terminated code blocks accessible to the quantum runtime library in the final executable file.
[0073] Specifically, some embodiments of the invention include compiler front-end language extensions to support intrinsic quantum operations as part of the normal program writing process. Quantum operators are specified using intrinsic functions that delineate blocks of quantum code intermixed with native host processor code. In addition, certain embodiments perform compiler extraction of quantum basic blocks (QBBs), which can be linked into a unified QBB and stored using an extension to the Executable and Linking Format (ELF), referred to herein as ELF Quantum or ELFQ.
[0074] In addition, at least some embodiments of the present invention include: a quantum runtime environment that allows classical host code to trigger the upload and processing of quantum basic blocks at the correct location in the program executable control flow. These embodiments ensure that the correct block ID is loaded and published at the correct time, and the results are reported back in the specified CPU register or memory location for further processing on the classical processing side.
[0075] The quantum accelerator and the classical host processor can be configured to interact in various ways. At one extreme, there may be limited or no interaction between the classical processor and the quantum accelerator (a "non-interactive" or "pure quantum" implementation). This represents the system used by the quantum computing community today. In these implementations, the host processor only maintains a loop counter and keeps issuing the same basic block of quantum acceleration code and waiting for measurement results. There is no classical-quantum interaction through branches.
[0076] A software-driven "hybrid" quantum system is controlled via classical software that provides selection between quantum blocks based on classical variables and also allows the qubit state to be moved into registers of the host processor. The state can then be used to select a new quantum block. Hybrid schemes are being seriously explored in the quantum computing community today.
[0077] Hardware-driven hybrid quantum systems allow full interaction between quantum accelerator code and classical host processor instructions. The hardware-driven hybrid solution allows a simplified compiler and reduces the need for the ELFQ extension format. However, this solution has not been seriously considered by the quantum community at least in part due to the cost and time of developing such a system. This system takes advantage of execution speed, but introduces integration problems and noise problems (and increased errors) caused by classical processing overhead. In addition, in order to be fully integrated, the classical processor will need to operate at a currently impossible quantum refrigeration temperature (e.g., 0 m Kelvin).
[0078] To address the above limitations, embodiments of the present invention include a complex compilation tool chain to manage all three of these interaction scenarios.
[0079] Fig.12 An overview of how to compile, load, and run a classic program on a modern computer system is illustrated. A compiler 1205 translates a source file 1201 written in a specific programming language (e.g., such as C++, Python, etc.) to generate an object file 1210. A linker 1215 links multiple object files 1210 together to form an executable file 1220, which is then loaded into memory by an OS loader 1225 and executed on a host processor 1230.
[0080] refer to Fig.13, a compiler 1321 according to an embodiment of the present invention includes cross-compile logic 1320 to compile a hybrid source file 1301 containing a combination of non-quantum source code 1305 and quantum source code 1306. The non-quantum source code specifies operations to be performed on a classical processor, and the quantum source code 1306 specifies qubit operations to be performed by a quantum controller, which is sometimes referred to herein as quantum acceleration hardware.
[0081] The cross-compile logic 1320 extracts blocks of quantum operations or instructions 1306 generated based on the source code 1301 and compiles them into quantum basic block (QBB) target object files 1316 (or into QBB sections of target object files). The cross-compile logic 1320 also compiles non-quantum code 1305 into non-quantum target object files 1315 (or non-quantum sections of target object files). In at least one embodiment, the cross-compile logic 1320 forms these quantum basic blocks of code 1316 by detecting sequences of quantum operations or instructions generated from the program source file 1301, grouping them together, and binding them with classical host processor operations / instructions (e.g., immediately before and after each quantum basic block). If the cross-compile logic 1320 detects a quantum measurement while it is scanning the quantum operations / instructions, it will terminate the quantum basic block and start a new quantum basic block directly after the measurement. This quantum basic block delineation process allows for the adaptation of quantum algorithms that are designed to complete a quantum error correction cycle through parity measurements. A quantum building block can be as short as a single pair of parity measurements or as long as a complete quantum program.
[0082] When the cross compiler logic 1301 has found a quantum basic block and delineated it, it injects a call to the quantum runtime services (QRTS) module with a block identifier for the QBB. This allows the classical compiler 1321 toolchain to compile the source code 1301 classically without any knowledge of the quantum accelerator sequence.
[0083] During the linking phase, the linker 1330 assembles the cross-compiled quantum basic block object files 1316 and the generated classical / non-quantum object files 1315 by compiling the source code with the injected quantum runtime services (QRTS) 1350 function calls into a unified quantum executable and linker format (ELFQ) file 1340. The ELFQ file format is extended to contain a new section called ".qbbs", which contains a table structure for listing individual QBBs. Each QBB is delineated by a table entry in the .qbbs table section header. The job of the linker 1330 is to assemble the quantum basic block sections 1316 in each object file into one or more unified QBB sections in the extended ELFQ file 1340.
[0084] The final compiled ELFQ executable 1340 includes not only classical code, but also a quantum runtime library (QRTL) 1350, which, when executed on the host processor 1260, extracts the ELFQ quantum basic block instructions from the ELFQ executable 1340 and issues them to the quantum accelerator hardware 1265, which responsively controls the qubits in the quantum processor 1270. During program execution, the quantum runtime service (QRTS) 1350 causes the host processor 1260 to issue quantum basic blocks at appropriate points in program flow control, thereby allowing hybrid operation of quantum-classical computers. Although in Fig.13 Although illustrated as a separate unit in FIG. 1 , quantum acceleration hardware 1265 (sometimes referred to as a quantum controller) can be integrated on the same chip or in the same package as host processor 1260 .
[0085] therefore, Fig.13 The tool chain, flow and process for combining classical and quantum program execution on a single host computer system are illustrated. This complex mode of operation is future-proof in the sense that it can accommodate this hybrid interaction designed for all quantum computers. When quantum instructions are integrated as first class operations in the classical instruction set, only the QBB can be removed and the ELFQ file can be used without changes to the compilation framework, runtime tools or flow.
[0086] Hybrid Compilation and Execution Model for Quantum-Classical Variational Algorithms with Quantum Compiler Toolchain The following sections build on the concepts set forth above with respect to additional hybrid classical / quantum compilation techniques and specific architectural arrangements and algorithms. However, it should be noted that the underlying principles of the invention are not necessarily limited to these specific details.
[0087] Quantum computing has the potential to solve classically intractable problems. Current quantum computers in the noisy intermediate-scale quantum (NISQ) regime are limited by the total number of operations that can be reliably performed and the total number of qubits available. One of the most promising applications for demonstrating quantum acceleration for NISQ systems is hybrid quantum-classical algorithms, such as variational quantum eigensolvers (VQEs) and quantum approximate optimization algorithms (QAOAs). These applications depend on the close relationship between classical computing and quantum accelerators during program execution.
[0088] Fig.14AA quantum-classical optimization loop implemented between a classical computer 1410 and a quantum computer 1420 is illustrated. Parameter optimization logic 1415 executed on the classical computer 1410 trains parameters to be used by a parameterized circuit 1425 on the quantum computer 1420 by evaluating each candidate solution. The parameters in the quantum circuit 1425 of each iteration depend on the previous results in the optimization loop. In the variational algorithm, the rotation angle is changed in each iteration and passed back as a variational parameter for the next round of optimization. Embodiments of the present invention focus on compiler and runtime technologies that allow programmers to design hybrid quantum-classical variational algorithms in a single C++ source code and generate a binary executable file that performs classical computations on a host processor (e.g., a CPU or other processor type) and quantum computations on a quantum accelerator.
[0089] Some of the embodiments described herein include quantum extensions to the C++ programming language that leverage the LLVM infrastructure to compile quantum programs. The LLVM infrastructure is a collection of compiler and toolchain technologies designed around a language-independent intermediate representation (IR) for designing front ends for programming languages and back ends for instruction set architectures.
[0090] Using C++ to handle analysis and optimization of large quantum programs has been shown to be faster than other higher-level languages such as Python. The embodiments described below adopt the programming language model originally demonstrated by JavadiAbhari et al, in Parallel Computing 45, 2 (2015), Computing Frontiers 2014, to the extent of defining custom data types, custom intrinsic functions, and utilizing the LLVM pass infrastructure. In addition, the embodiments of the invention described herein are designed to express hybrid quantum-classical algorithms, thereby supporting the use of a single compilation pair for dynamic parameters of quantum circuits, code generators for qubit control processors, quantum runtime libraries for managing execution, together with the definition of an application binary interface (ABI) for executable files.
[0091] The LLVM framework includes Clang, a compiler for C family languages, with a target-independent optimizer, an extensible backend for new targets and a linker. The front end parses the input source program in a high-level programming language, performs lexical, syntactic and semantic analysis, and generates a lower-level intermediate representation (IR) as output. The optimizer stage is responsible for improving execution performance. In LLVM. This is managed by a transformation pass that translates the IR into an optimized IR. The back end is associated with a specific target machine (e.g., a specific X86 processor model) and performs code generation by mapping the IR to the target instruction set.
[0092] To realize the capabilities of quantum computing, embodiments of the present invention include a full stack of system software and hardware. Fig. 14B An example of this layered architecture is illustrated, which includes a quantum compiler toolchain 1421 (e.g., based on LLVM) for translating application source code 1411 written in hybrid quantum-classical unified C++. The translated code is processed by a qubit control processor 1450 via a quantum runtime 1430, where the qubit control processor 1450, associated control electronics 1460, and backend perform quantum computations using well-defined interfaces. The modular design allows multiple components to be supported in each layer and any individual component to be easily swapped out.
[0093] Application 1411 includes quantum algorithms and any related classical logic expressed in C++ source code. Compiler toolchain 1421 translates the unified C++ source file into a binary executable file. Quantum runtime 1430 provides library calls for managing quantum-classical interactions and communicates with qubit control processor 1450, which manages execution on the quantum backend via control electronics 1460. The qubit backend can also be a quantum dot simulator 1470 or a physical quantum dot qubit chip 1480.
[0094] A quantum circuit simulator 1440, such as the Intel Quantum Simulator (IQS), can directly interface with the quantum runtime 1430 and execute quantum circuits. A quantum dot qubit chip 1480 or its equivalent simulator 1470 additionally requires a qubit control processor 1450 and supporting electronics 1460 for generating the necessary control signals.
[0095] The embodiments of the present invention perform compilation of quantum programs by extending the LLVM compiler framework, which allows programmers to use existing compiler technology for quantum program analysis, optimization, and executable code generation.
[0096] In addition, at least some embodiments include a compilation and execution model for hybrid quantum-classical variational algorithms. Using the techniques described herein, the hybrid program 1411 only needs to be compiled once for executing multiple algorithm iterations, thereby significantly reducing execution latency.
[0097] A full stack software platform including C++ quantum extensions, compiler, runtime and simulator is described. The feasibility of these embodiments is demonstrated by running a hybrid quantum-classical algorithm that prepares a thermal equilibrium state known as a dual thermal field (TFD) state. This variational TFD algorithm is important for application areas in materials design or simulations of complex electronic materials.
[0098] The quantum compiler toolchain 1420 provides a software platform that allows programmers to design, compile, and execute hybrid quantum-classical applications. In some implementations, the quantum compiler toolchain 1420 includes two components: a host compiler, which is a Clang compiler based on LLVM; and a device compiler, which targets the quantum instruction set architecture (QuISA) as described herein.
[0099] Fig.15 The hybrid compilation workflow according to an embodiment of the present invention is illustrated, which supports the compilation of hybrid quantum-classical variational algorithms. The input to the compiler is a single source file 1501 (for example, in some embodiments, a C++ file), which represents the application layer, classical functions, and quantum kernels. The compilation process is orchestrated by a compiler driver 1505, which logically splits the process into a quantum device compilation flow and a classical host compilation flow, and calls the necessary components in the tool chain to process the input. The quantum compiler driver 1505 extracts the quantum kernel from the unified source code 1501 and passes them to the quantum device compiler 1510, which performs analysis and optimization of the quantum kernel, thereby generating an integrated header file 1515 that provides quantum kernel information, such as function names, symbols, function lengths, and macros for the runtime library. The host compiler 1525 receives the quantum integrated header 1515, merges the quantum logic back with the classical logic, and links with the quantum runtime library 1520. Once all compilation processes are completed, an output binary executable file 1530 is created in the quantum executable and linking format (ELF) (ELFQ). ELFQ contains the information required to run hybrid applications.
[0100] As mentioned above, some embodiments of the invention compile quantum kernels into quantum basic blocks (QBBs), where each QBB is a linear sequence of quantum operations with no classical operations. Fig.16An example of runtime execution control flow on a host processor 1260 and quantum acceleration hardware 1265 is illustrated. The program is started by the host processor 1260 and includes a first program code sequence 1610 that generates initial parameters in a QBB 1601 that it issues to a quantum device 1265. A wait loop 1611 is executed on the host processor 1260 during execution of the QBB 1601. In some embodiments, the wait loop waits for an event such as completion of the QBB 1601 to restart execution. A second program code sequence 1612 reads the measurement results and / or updates the parameters that it issues to the quantum device 1265 in the next QBB 1602. Another wait loop 1613 is executed in parallel with the second QBB 1602. Non-quantum and quantum instruction sequences alternate in this manner until a final QBB 1603 is executed on a final set of parameters in parallel with a final wait loop 1614. The final program code sequence 1615 executed on the host processor 1260 then computes the final result, which may be stored in the processor registers and / or cache / memory subsystem of the host processor 1260. Once the quantum kernel is called by the program, the host processor uses a blocking call to issue the corresponding QBB 1601-1602 and transfer control to the quantum hardware 1265. After the QBB execution is completed (e.g., in the example, after QBB 1602 completes execution), the result is passed to the host program 1600, and program control is transferred back to the host processor 1260.
[0101] Embodiments of the present invention facilitate tight integration of processors and quantum accelerators, and dynamically update instructions in the instruction stream for parameterized circuits 1425 at runtime. The design allows users to specify both quantum and classical functions in a single program file 1501, and generate a single integrated executable binary file. Therefore, our scheme can utilize symbolic mapping to update parameters used in quantum circuits at runtime.
[0102] Fig.17The workflow for updating quantum instructions 1701 at runtime according to various embodiments of the present invention is illustrated. An index value 1700 identifying the relevant instruction within a quantum runtime (QRT) library 1702 is provided. A host program 1710 dynamically updates the parameters (at 1701) of one or more instructions of the QRT library 1702, the parameters being identified by the index value 1700. In one embodiment, the host program generates or uses an array 1704 that maps classical arguments to quantum instructions. The QRT library 1702 uses dynamic parameters to update the instructions - replacing the variables in the instructions with actual values. The updated quantum instructions 1710 are then issued to the qubit control processor 1450, which performs the basic operations according to the updated parameters. Therefore, instead of recompiling the entire circuit at runtime, the QRT library 1702 only replaces the variables with actual values for the parameterized instructions. Using these techniques, the programmer only needs one compilation to execute the variational algorithm for all iterations, thereby obtaining a significant performance advantage.
[0103] Fig.18 The stages in the quantum device compilation workflow broken down into multiple steps are illustrated. At 1802, the front end parses and translates a hybrid quantum-classical source file 1501 including both quantum and classical functions to extract quantum specific logic 1803. One or more optimization passes are then performed 1804 to identify the most efficient order of quantum operations. The optimized code is provided to the back-end code generation logic 1805, which generates the target code to be executed by the qubit control processor 1450, and the integration header generator 1806 generates a quantum integration header 1515. As previously described, the quantum integration header 1515 provides quantum kernel information such as function names, symbols, function lengths, and macros for the runtime library that are used by the host compiler 1525 to generate a binary executable file 1530.
[0104] Additional details associated with certain embodiments of the present invention described with respect to LLVM and ELF extensions are provided below.It should be noted, however, that the underlying principles of the present invention are not limited to any particular programming standard or framework.
[0105] A. Front-end extensions The quantum_kernel and quantum_shared_var attributes are defined, as well as the qbit and cbit data types for language extensions. The quantum kernel attribute identifies quantum-specific functions in a program to allow for the intermixing of classical and quantum code in a unified source file. Arrays annotated with the attribute quantum_shared_var enable sharing of data from classical functions with quantum functions. The data types qbit and cbit are used to represent operands for quantum bits and classical data values, respectively.
[0106] The standard set of quantum logic gates is made available through the quintrinsics.h header file, which resides in the clang / quantum directory in the LLVM structure. Although each quantum operation has an identifier name, the gates are defined by their matrix representation as indicated below in the example program code sequence. This avoids any ambiguity about the behavior of the quantum gates and allows the names to be easily changed for future standards. Users can also define custom operations by defining the gates using these fields. The file also defines two macros, quantum_kernel and quantum_shared_double_array, as shorthand to apply the newly defined attributes to functions and array variables, respectively. / *Pauli-X gate* /
[0107] The front end 1802 is responsible for translating the source code 1501 from a higher level language (e.g., C++) to an intermediate representation (IR). By default, the IR file generated by LLVM has a .IL extension. At this stage, the input is a user-defined unified C++ source file 1501 with intermixed quantum-classical logic. Thus, the output is also an intermixed quantum-classical intermediate representation.
[0108] B. Transformation and Optimization Passes Some embodiments of the present invention utilize the LLVM pass framework to define custom transformation passes that perform IR-to-IR translation for quantum programs (e.g., Fig.18 1803 in ). In addition to LLVM's built-in passes (such as dead code elimination, instruction combining, loop unrolling, constant folding), these embodiments also include custom passes for extracting and filtering quantum functions, such as Pauli rotation product (PoPR) synthesis for QuISA, physical qubit mapping, gate scheduling, and gate decomposition.
[0109] The LLVM framework provides classes and APIs for traversing and updating the source in its IR form, which is used for optimization 1804. Some key custom transformation passes implemented by embodiments of the present invention are described below.
[0110] Extracting quantum specific logic 1803 : This pass takes the combined classical-quantum IR and filters it to extract only the quantum logic and its dependencies. The quantum specific IR will be processed by the quantum device backend.
[0111] optimization : This step consists of a collection of passes for efficient representation of quantum logic by means such as PoPR synthesis.
[0112] Gate decomposition: Standard gates are transformed into quantum operations natively supported by the quantum device, as defined in QuISA.
[0113] Quantum bit mapping : To optimally utilize the available resources, program qubits are assigned to available physical qubits taking into account qubit connectivity and availability.
[0114] Scheduling : Update the sequence of quantum operations taking into account the timing information for the target quantum device.
[0115] C. Backend expansion For quantum extensions, a new LLVM backend is defined that converts IR into code for a quantum target machine. This process is also called CodeGen, which stands for machine code generation. It involves directed acyclic graph (DAG) legalization, instruction selection, register allocation, and machine code emission.
[0116] A custom backend target is implemented in LLVM that converts IR into machine code for the qubit control processor 1450 instruction set. A new class is defined for a quantum machine inherited from the TargetMachine class. In this phase, relocatable machine code is generated - called a quantum object file (identified by the .qo extension). The backend can optionally generate an assembly file for a human-readable version of the machine code.
[0117] The linker is extended to add support for ELFQ and generate an executable file 1530 from the quantum object file. The binary executable file 1530 places the quantum instructions in the .qbbs text section and also creates a header in the .qbbs section.
[0118] D. Integrated Header Generator The integration header generator 1806 constructs a quantum integration header file that is merged back into the classical portion of the code. The integration header generator 1806 also creates metadata in the form of a mapping file that maps functions annotated with quantum kernel attributes to their identifiers in the .qbbs section of the ELFQ file.
[0119] E. LibTooling LibTooling is a library provided by Clang to support source-to-source translation tools. An embodiment of the present invention utilizes this facility in the LLVM framework to implement a tool called QuantumKernelReplacer. The tool instantiates the FrontendActionFactory class in Clang, which calls the specified action in the Clang front end. Using the classes MatchFinder and ASTConsumer, the tool parses the abstract syntax tree (AST) of the input source program, finds calls to functions annotated with quantum kernel attributes, and replaces them with equivalent quantum runtime library API calls using mappings from the integrated header generator 1806. Therefore, the quantum computing logic is represented in a different format and is merged back into the classical-only portion of the code.
[0120] F. Extensible and Linkable Files Quantum (ELFQ) Extensions to the industry standard Extensible and Linkable File (ELF) format are defined to enable program executable binary files generated by a compiler toolchain to carry with them both classical and quantum program code in 64-bit binary form. Fig.19 A high-level view of an ELFQ file 1900 is provided in accordance with at least some embodiments of the present invention. As mentioned, quantum kernels are compiled into binary instructions and placed in a quantum basic block section 1902 (.qbbs text). A header in the .qbbs section 1901 is generated that holds an identifier for each quantum kernel, its size, alignment, and offset. The placement, selection, and release of quantum basic blocks to quantum accelerators during the standard flow of a classical program is an important component of the quantum runtime execution model and is implemented by the operating system program loader that resolves the location of the quantum basic block headers.
[0121] G. Quantum runtime The quantum runtime (QRT) library 1520 provides an application programming interface (API) for initialization of the underlying quantum target, scheduling of quantum functions synchronously or asynchronously with the quantum target device, and retrieval of results from quantum measurement operations. Fig. 20 The interaction between the classical host computer 1410 and the quantum device 1420 as managed by the QRT 1430 is depicted in FIG. The quantum runtime 1430 solves for parameters that are unknown at compile time and calculated at runtime. This allows variational algorithms to be executed without having to recompile the application. In addition, the quantum runtime 1430 initializes and schedules quantum kernels for execution by the quantum device 1420. It also captures measurement data from the quantum device 1420 and makes the data accessible to the host computer 1410 (e.g., storing the measurement data in a designated register).
[0122] H. Sample Application The following is a sample program demonstrating the use of dynamic quantum parameters for variational algorithms according to an embodiment of the present invention:
[0123] New applications can take advantage of embodiments of the present invention by performing the following: 1. Include the quintrinsics.h header file to use any of the predefined standard gates: {X,Y,Z,H,S,S + ,T,T + ,CZ,CNOT,SWAP,CCNOT,R X (θ),R Y (θ),R Z (θ)} 2. Define qubits as global variables - single or multiple, individual or array or any combination. Similarly, define classical bits used to capture measurement results. The number of available qubits depends on the target quantum device or simulator. 3. Define an array of the desired size annotated with the attribute quantum_shared_var to hold any dynamic parameters that will be modified during runtime. 4. Encapsulate all quantum operations in functions annotated with quantum kernel properties. 5. Define computationally intensive logic and classical code in traditional C++ functions.
[0124] Example workload A. Overview An example workload was performed using a specific embodiment of the invention. The example workload considered in this manuscript is the generation of dual thermal field (TFD) states, a variational algorithm that operates similarly to QAOA. To demonstrate the capabilities of this embodiment, TFD states of size Nq = {4, 6, 8, 10, 12, 14, 16, 18, 20} were generated. The results were confirmed using a standalone optimization implementation in MATLAB for system sizes up to Nq = 12.
[0125] A. Algorithm Details The TFD generation algorithm is based on the use of entanglement for the purpose of modeling the degree of mixture required for the final desired thermal state. To prepare the thermal state of L qubits, a total of 2L qubits are required by the algorithm. Here, we focus on preparing the TFD state for the transverse field Ising model (TFIM) in a one-dimensional ring described by the following Hamiltonian,
[0126] The implementation is limited to the case where g = 1 due to the presence of critical points in the behavior of the system. The process begins by preparing pairwise Bell states between corresponding qubits in two subsystems (A and B) each containing L qubits. This achieves an infinite temperature TFD state. Then, the intra-system operators corresponding to the Hamiltonian equations are applied within each of the subsystems, followed by mixing / entanglement operations between the subsystems. Each of the intra-system and inter-system operations has an associated variational angle that must be classically optimized for generating the desired TFD state.
[0127] exist Fig.21 A full quantum circuit for a variable number of qubits is shown in . The stages include: (I) preparation of infinite temperature TFD state, (II) intra-system X operation with angle γ1, (III) intra-system ZZ operation with angle γ2, (IV) inter-system XX operation with angle α1, (V) inter-system ZZ operation with angle α2.
[0128] The degree of mixture / entanglement depends on the desired temperature and is effectively encoded within the calculation of the cost function. The example results in this work are obtained based on a single-step TFD generation (four variation angles), but for higher fidelity with higher qubit numbers, it is desirable to have more steps and thus more variation angles to be optimized. In this implementation, the four variation angles are labeled γ1, γ2, α1, α2. The cost function for evaluating the validity of the generated states in this work is given by: C(β)= <XA〉+<XB〉+〈ZZA〉+〈ZZB〉-β-1(<XXAB〉+ <zzab>) where single-subscript operators act within the corresponding subsystem, and double-subscript operators represent operators acting between subsystems A and B. Here, β is the inverse temperature, and the expected value is evaluated with respect to the resulting state. C. Quantum Programming Considerations Using the Intel Quantum Simulator, the final state vector can be accessed at the end of the quantum system evolution. If the resulting state vector is used, only one experiment is required per iteration. However, for this demonstration, probability registers are used, which store the probabilities for each unique basis state combination. For example, in a three-qubit system, a single circuit evaluation using IQS will give us access to the probabilities for each of the following states: 000, 001, 010, 011, 100, 101, 110, 111.
[0129] With this information available after each circuit evaluation, two rounds of the same circuit are performed for each optimization iteration. In the first round, measurements will be performed in the traditional Z basis, allowing us to compute the Z-related operators in (β). In the second round, Hadamard operations will be applied to all qubits before the measurements, resulting in X-basis measurements that will allow us to compute the residual X-related expectation values in (β). The optimizations are performed using the popular dlib library. This library contains several different optimization routines, and in this work we found that finding the min bobyqa function performs well.
[0130] D. result The accuracy of TFD state generation is evaluated by calculating the fidelity of the generated state with respect to the ideal thermal state at each temperature. First, by tracing on subsystem B to generate ρ sim , the pure state on 2L qubits is simplified to the density matrix corresponding to the L qubit mixed state. Then, the thermal state accuracy is calculated as the ideal density matrix (ρ ideal ) and the generated density matrix (ρ sim ), as the fidelity between
[0131] Fig. 22 A comparison of thermal state accuracy for variational optimization performed on Intel Quantum SDK and MATLAB is illustrated. When comparing the results obtained using Intel Quantum SDK and standalone MATLAB scripts, excellent consistency up to Nq=12 can be observed between optimizations. Outside this system size, MATLAB implementation slows down considerably. The trend of decreasing fidelity for low temperatures with increasing system size continues as expected for Nq>12. Calculations of thermal state accuracy were performed using MATLAB scripts, and for Nq>16, the analysis was found to be intractable with respect to simple techniques. More complex analysis and verification techniques are expected to enable analysis for larger system sizes.
[0132] exist Fig.23 In , the behavior of the optimized angles γ1, γ2, α1, α2 is visualized with the system size. The angles γ1 and α2 are found to have almost the same temperature dependence regardless of the system size. For γ2 and α1, we observe a partitioning of the optimized values, but this is expected due to the degeneracy present in the system and does not indicate system size dependence. In the case of α1 and α2, some degree of instability is observed in the optimized angles, especially for β < 10-2, and we attribute this to the low dependence of these variational angles.
[0133] All in all, the results are as expected and highlight several challenges that need to be addressed when using quantum computers for realistic workloads.
[0134] A full stack framework for compilation and execution of quantum programs is critical to exploiting the power of quantum computing. Embodiments of the present invention include an LLVM-based C++ framework with quantum extensions that support compilation and execution of hybrid quantum-classical algorithms. Using these embodiments, only a single compilation is required for running quantum-classical variational algorithms due to support for dynamic parameters.
[0135] In the above detailed description, reference is made to the accompanying drawings, which form a part thereof and in which are shown as illustrations embodiments that can be practiced. It should be understood that other embodiments may be utilized and that structural or logical changes may be made without departing from the scope of the present disclosure. Therefore, the following detailed description should not be taken in a limiting sense.
[0136] Various operations may then be described as multiple discrete actions or operations in a manner that is most helpful in understanding the claimed subject matter. However, the order of description should not be understood to imply that these operations necessarily rely on order. In particular, these operations may not be performed in the order presented. The described operations may be performed in an order different from the described embodiments. Various additional operations may be performed, and / or the described operations may be omitted in additional embodiments. Terms such as "first", "second", "third", etc. do not imply a specific ordering unless otherwise specified.
[0137] For purposes of this disclosure, the phrase "A and / or B" means (A), (B), or (A and B). For purposes of this disclosure, the phrase "A, B, and / or C" means (A), (B), (C), (A and B), (A and C), (B and C), or (A, B, and C). The term "between" when used with reference to a measurement range includes the ends of the measurement range. As used herein, the notation "A / B / C" means (A), (B), and / or (C).
[0138] The description uses the phrases "in one embodiment" or "in an embodiment", which can refer to one or more of the same or different embodiments. In addition, the terms "including", "comprising", "having", etc. as used with respect to the embodiments of the present disclosure are synonymous.
[0139] Example The following are example implementations of different embodiments of the invention.
[0140] Example 1. A machine-readable medium having program code stored thereon, the program code, when executed by a machine, causing the machine to perform operations comprising: reading source code, the source code specifying both non-quantum operations to be performed by a host processor and quantum operations to be performed by a quantum accelerator; and compiling the source code to generate one or more target object files, wherein portions of the source code specifying the quantum operations are to be compiled into quantum basic blocks, each quantum basic block comprising one or more quantum instructions to be performed by the quantum accelerator, and wherein portions of the source code specifying the non-quantum operations are compiled into native processor instructions executable by the host processor.
[0141] Example 2. The machine-readable medium of Example 1, wherein compiling the source code further comprises: evaluating quantum operations specified in the source code; and grouping corresponding quantum instructions into the quantum basic blocks based on the evaluation of the quantum operations.
[0142] Example 3. The machine-readable medium of Example 2, wherein grouping corresponding quantum instructions further comprises: terminating a first quantum basic block in response to detecting a quantum measurement operation; and starting a second quantum basic block directly after the quantum measurement operation.
[0143] Example 4. The machine-readable medium of Example 2, wherein compiling the source code further comprises: sequentially binding one or more of the quantum basic blocks that do not include quantum measurement results with the portion of the native processor instructions.
[0144] Example 5. The machine-readable medium of Example 1, further comprising program code for causing the machine to perform the following operations: for each quantum basic block, injecting calls to a quantum runtime module into the one or more target object files, each call being associated with one of the quantum basic blocks.
[0145] Example 6. The machine-readable medium of Example 5, further comprising program code for causing the machine to perform the following operations: assemble quantum basic blocks and native processor instructions from the one or more target object files into a unified executable file.
[0146] Example 7. The machine-readable medium of Example 6, wherein the executable file is a Quantum Executable and Linker Format (ELFQ) file.
[0147] Example 8. The machine-readable medium of Example 1, wherein the quantum operations are arranged in one or more quantum kernels, and wherein compiling further comprises: extracting the quantum kernel from the source code; generating an integration header file to store quantum kernel information; and using the quantum kernel information in generating the one or more target object files.
[0148] Example 9. The machine-readable medium of Example 8, wherein the operations of extracting the quantum kernel and generating the integrated header are performed by a first compiler or compiler component, and wherein the quantum kernel information is used by a second compiler or compiler component.
[0149] Example 10. A method comprising: reading source code, the source code specifying both non-quantum operations to be performed by a host processor and quantum operations to be performed by a quantum accelerator; and compiling the source code to generate one or more target object files, wherein portions of the source code specifying the quantum operations are to be compiled into quantum basic blocks, each quantum basic block comprising one or more quantum instructions to be performed by the quantum accelerator, and wherein portions of the source code specifying the non-quantum operations are compiled into native processor instructions executable by the host processor.
[0150] Example 11. The method of Example 10, wherein compiling the source code further comprises: evaluating quantum operations specified in the source code; and grouping corresponding quantum instructions into the quantum basic blocks based on the evaluation of the quantum operations.
[0151] Example 12. The method of Example 11, wherein grouping corresponding quantum instructions further comprises: terminating a first quantum basic block in response to detecting a quantum measurement operation; and starting a second quantum basic block directly after the quantum measurement operation.
[0152] Example 13. The method of Example 11, wherein compiling the source code further comprises: sequentially binding one or more of the quantum basic blocks that do not include quantum measurement results with the portion of the native processor instructions.
[0153] Example 14. The method of Example 10, further comprising: for each quantum basic block, injecting calls to a quantum runtime module into the one or more target object files, each call being associated with one of the quantum basic blocks.
[0154] Example 15. The method of Example 14, further comprising: assembling quantum basic blocks and native processor instructions from the one or more target object files into a unified executable file.
[0155] Example 16. The method of Example 15, wherein the executable file is a Quantum Executable and Linker Format (ELFQ) file.
[0156] Example 17. The method of Example 10, wherein the quantum operations are arranged in one or more quantum kernels, and wherein compiling further comprises: extracting the quantum kernels from the source code; generating an integration header file to store quantum kernel information; and using the quantum kernel information in generating the one or more target object files.
[0157] Example 18. The method of Example 17, wherein extracting the quantum kernel and generating an integrated header are performed by a first compiler or compiler component, and wherein the quantum kernel information is used by a second compiler or compiler component.
[0158] Example 19. A system comprising: a host processor; a quantum accelerator coupled to the host processor; a memory to store source code, the source code specifying both non-quantum operations to be performed by the host processor and quantum operations to be performed by the quantum accelerator; and the host processor executing program code to: compile portions of the source code specifying the quantum operations into quantum basic blocks, each quantum basic block comprising one or more quantum instructions to be performed by the quantum accelerator, and compile portions of the source code specifying the non-quantum operations into native processor instructions executable by the host processor.
[0159] Example 20. The system of Example 19, wherein compiling the source code further comprises: evaluating quantum operations specified in the source code; and grouping corresponding quantum instructions into the quantum basic blocks based on the evaluation of the quantum operations.
[0160] Example 21. The system of Example 20, wherein grouping corresponding quantum instructions further comprises: terminating a first quantum basic block in response to detecting a quantum measurement operation; and starting a second quantum basic block directly after the quantum measurement operation.
[0161] Example 22. The system of Example 20, wherein compiling the source code further comprises: sequentially binding one or more of the quantum basic blocks that do not include quantum measurement results with the portion of the native processor instructions.
[0162] Example 23. The system of Example 19, further comprising: for each quantum basic block, injecting calls to a quantum runtime module into the one or more target object files, each call being associated with one of the quantum basic blocks.
[0163] Example 24. The system of Example 22, further comprising: assembling quantum basic blocks and native processor instructions from the one or more target object files into a unified executable file.
[0164] Example 25. The system of Example 24, wherein the executable file is a Quantum Executable and Linker Format (ELFQ) file.
[0165] Example 26. The system of Example 19, wherein the quantum operations are arranged in one or more quantum kernels, and wherein compiling further comprises: extracting the quantum kernel from the source code; generating an integration header file to store quantum kernel information; and using the quantum kernel information in generating the one or more target object files.
[0166] Example 27. The system of Example 26, wherein the operations of extracting the quantum kernel and generating an integrated header are performed by a first compiler or compiler component executed by the host processor, and wherein the quantum kernel information is used by a second compiler or compiler component executed by the host processor.
[0167] Embodiments of the present invention may include various steps described above. The steps may be embodied in machine executable instructions, which may be used to cause a general or special purpose processor to perform the steps. Alternatively, the steps may be performed by specific hardware components containing hardwired logic for performing the steps, or by any combination of programmed computer components and custom hardware components.
[0168] As described herein, instructions may refer to a specific configuration of hardware, such as an application specific integrated circuit (ASIC) configured to perform certain operations or having predetermined functionality or software instructions stored in a memory embodied in a non-transitory computer readable medium. Thus, the techniques shown in the various figures may be implemented using code and data stored and executed on one or more electronic devices (e.g., end stations, network elements, etc.). Such electronic devices use computer machine readable media to store and communicate (internally and / or with other electronic devices over a network) code and data, such as non-transitory computer machine readable storage media (e.g., magnetic disks; optical disks; random access memory; read-only memory; flash memory devices; phase change memory) and transient computer machine readable communication media (e.g., electrical, optical, acoustic, or other forms of propagated signals - such as carrier waves, infrared signals, digital signals, etc.).
[0169] In addition, such electronic devices typically include a set of one or more processors coupled to one or more other components, such as one or more storage devices (non-transient machine-readable storage media), user input / output devices (e.g., keyboards, touch screens, and / or displays), and network connections. The coupling of the set of processors and other components is typically through one or more buses and bridges (also referred to as bus controllers). The storage device and the signal carrying the network traffic represent one or more machine-readable storage media and machine-readable communication media, respectively. Therefore, the storage device of a given electronic device typically stores code and / or data for execution on the set of one or more processors of the electronic device. Of course, different combinations of software, firmware, and / or hardware can be used to implement one or more parts of an embodiment of the present invention. Throughout this detailed description, for the purpose of explanation, many specific details are set forth in order to provide a thorough understanding of the present invention. However, it will be apparent to those skilled in the art that the present invention can be practiced without some of these specific details. In some instances, known structures and functions are not described in detail in order to avoid obscuring the subject matter of the present invention. Accordingly, the scope and spirit of the present invention should be judged with respect to the appended claims.< / zzab>
Claims
1. A machine-readable medium having program code stored thereon, the program code, when executed by a machine, causing the machine to perform operations comprising: reading source code that specifies both non-quantum operations to be performed by a host processor and quantum operations to be performed by a quantum accelerator; and Compiling the source code to generate one or more target object files, wherein the portion of the source code specifying the quantum operation is to be compiled into quantum basic blocks, each quantum basic block comprising one or more quantum instructions to be executed by the quantum accelerator, and Wherein the portion of the source code specifying the non-quantum operation is compiled into native processor instructions executable by the host processor.
2. The machine-readable medium of claim 1, wherein compiling the source code further include: evaluating quantum operations specified in the source code; as well as The corresponding quantum instructions are grouped into the quantum basic blocks based on the evaluation of the quantum operations.
3. The machine-readable medium of claim 2, wherein the grouping of corresponding quantum instructions further comprises: include: terminating the first quantum basic block in response to detecting the quantum measurement operation; as well as Directly after the quantum measurement operation a second quantum basic block is started.
4. The machine-readable medium of claim 2 or 3, wherein compiling the source code further include: One or more of the quantum basic blocks that do not include quantum measurement results are sequentially bound to the portion of the native processor instructions.
5. The machine-readable medium of any one of claims 1 to 4, further comprising program code for causing the machine to perform the following operations: For each quantum basic block, calls to a quantum runtime module are injected into the one or more target object files, each call being associated with one of the quantum basic blocks.
6. The machine-readable medium of claim 5, further comprising program code that causes the machine to perform the following operations: assemble quantum basic blocks and native processor instructions from the one or more target object files into a unified executable file.
7. The machine-readable medium of claim 6, wherein the executable file is a Quantum Executable and Linker Format (ELFQ) file.
8. The machine-readable medium of any one of claims 1 to 7, wherein the quantum operations are arranged in one or more quantum kernels, and wherein the compilation further include: extracting the quantum kernel from the source code; Generate an integration header file to store quantum kernel information; as well as The quantum kernel information is used in generating the one or more target object files.
9. The machine-readable medium of claim 8, wherein the operations of extracting the quantum kernel and generating an integrated header are performed by a first compiler or compiler component, and wherein the quantum kernel information is used by a second compiler or compiler component.
10. A method, include: reading source code that specifies both non-quantum operations to be performed by a host processor and quantum operations to be performed by a quantum accelerator; as well as Compiling the source code to generate one or more target object files, wherein the portion of the source code specifying the quantum operation is to be compiled into quantum basic blocks, each quantum basic block comprising one or more quantum instructions to be executed by the quantum accelerator, and Wherein the portion of the source code specifying the non-quantum operation is compiled into native processor instructions executable by the host processor.
11. The method of claim 10, wherein compiling the source code further comprises: include: evaluating quantum operations specified in the source code; as well as The corresponding quantum instructions are grouped into the quantum basic blocks based on the evaluation of the quantum operations.
12. The method of claim 11, wherein the grouping of corresponding quantum instructions further comprises: include: terminating the first quantum basic block in response to detecting the quantum measurement operation; as well as Directly after the quantum measurement operation a second quantum basic block is started.
13. The method according to claim 11 or 12, wherein compiling the source code further comprises: include: One or more of the quantum basic blocks that do not include quantum measurement results are sequentially bound to the portion of the native processor instructions.
14. The method according to any one of claims 10 to 13, further comprising: include: For each quantum basic block, calls to a quantum runtime module are injected into the one or more target object files, each call being associated with one of the quantum basic blocks.
15. The method of claim 14, further comprising: include: Quantum basic blocks and native processor instructions from the one or more target object files are assembled into a unified executable file.
16. The method of claim 15, wherein the executable file is a Quantum Executable and Linker Format (ELFQ) file.
17. The method of any one of claims 10 to 16, wherein the quantum operations are arranged in one or more quantum kernels, and wherein the compilation further include: extracting the quantum kernel from the source code; Generate an integration header file to store quantum kernel information; as well as The quantum kernel information is used in generating the one or more target object files.
18. The method of claim 17, wherein the operations of extracting the quantum kernel and generating an integrated header are performed by a first compiler or compiler component, and wherein the quantum kernel information is used by a second compiler or compiler component.
19. A system, include: Host processor; a quantum accelerator coupled to the host processor; a memory to store source code specifying both non-quantum operations to be performed by the host processor and quantum operations to be performed by the quantum accelerator; as well as The host processor executes program code to: compiling the portion of the source code specifying the quantum operation into quantum basic blocks, each quantum basic block comprising one or more quantum instructions to be executed by the quantum accelerator, and The portion of the source code specifying the non-quantum operation is compiled into native processor instructions executable by the host processor.
20. The system of claim 19, wherein compiling the source code further include: evaluating quantum operations specified in the source code; as well as The corresponding quantum instructions are grouped into the quantum basic blocks based on the evaluation of the quantum operations.
21. The system of claim 20, wherein the grouping of corresponding quantum instructions further comprises: include: terminating the first quantum basic block in response to detecting the quantum measurement operation; as well as Directly after the quantum measurement operation a second quantum basic block is started.
22. The system of claim 20 or 21, wherein compiling the source code further include: One or more of the quantum basic blocks that do not include quantum measurement results are sequentially bound to the portion of the native processor instructions.
23. The system of any one of claims 19 to 22, further comprising: include: For each quantum basic block, calls to a quantum runtime module are injected into the one or more target object files, each call being associated with one of the quantum basic blocks.
24. The system of claim 22 or 23, further comprising: include: Quantum basic blocks and native processor instructions from the one or more target object files are assembled into a unified executable file.
25. The system of claim 24, wherein the executable file is a Quantum Executable and Linker Format (ELFQ) file.
