Search

US-20260127482-A1 - USING CLASSICAL CONTROL FLOW IN QUANTUM PROGRAMMING

US20260127482A1US 20260127482 A1US20260127482 A1US 20260127482A1US-20260127482-A1

Abstract

A method, apparatus and product are provided for using classical control flow in quantum programming. A quantum program that comprises a sequence of instructions including compilable instructions and a non-compilable instruction is received. A first subset of the compilable instructions is selected based on the non-compilable instruction. The first subset is compiled to obtain a first quantum circuit, which is executed using a quantum execution platform. An outcome of the execution is determined. A second subset of the compilable instructions, different from the first subset, is selected. The second subset is compiled to obtain a second quantum circuit executable by the quantum execution platform. In another aspect, compilable instructions are selected based on the type and position of a non-compilable instruction. The selected instructions are compiled to obtain an executable quantum circuit.

Inventors

  • Amir Naveh
  • Shmuel Ur
  • Eyal Cornfeld
  • Nati Erez
  • Nir Minerbi

Assignees

  • Classiq Technologies LTD.

Dates

Publication Date
20260507
Application Date
20241030

Claims (20)

  1. 1 . A method comprising: receiving a quantum program comprising a sequence of instructions, the sequence of instructions comprising compilable instructions and a non-compilable instruction; selecting a first subset of the compilable instructions, wherein said selecting the first subset is performed based on the non-compilable instruction; compiling the first subset of the compilable instructions, whereby obtaining a first quantum circuit; executing the first quantum circuit using a quantum execution platform; determining an outcome of the execution of the first quantum circuit; selecting a second subset of the compilable instructions, wherein the first subset and the second subset are different; and compiling the second subset of the compilable instructions, whereby obtaining a second quantum circuit that can be executed by the quantum execution platform.
  2. 2 . The method of claim 1 , wherein said selecting the first subset is performed based at least on a position of the non-compilable instruction in the sequence of instructions.
  3. 3 . The method of claim 2 , wherein the sequence of instructions comprises a first compilable instruction, the non-compilable instruction, and a second compilable instruction, arranged in that specific order within the sequence of instructions, wherein the first subset comprises the first compilable instruction and excludes the second compilable instruction, wherein the second subset comprises the second compilable instruction.
  4. 4 . The method of claim 3 , wherein the second subset comprises the first compilable instruction.
  5. 5 . The method of claim 2 , wherein the sequence of instructions comprises a first compilable instruction, the non-compilable instruction, a second non-compilable instruction, a second compilable instruction, arranged in that specific order within the sequence of instructions, wherein the first subset comprises the first compilable instruction and excludes the second compilable instruction, wherein the second subset comprises the second compilable instruction and excludes the first compilable instruction, wherein the second non-compilable instruction is an instruction that initiates a new phase of program execution or alters the control flow of the quantum program.
  6. 6 . The method of claim 1 further comprises executing the second quantum circuit using the quantum execution platform.
  7. 7 . The method of claim 1 further comprising repeatedly: selecting a subset of the compilable instructions, compiling the subset to obtain a quantum circuit, executing the quantum circuit, and determining control flow based on an outcome of the execution of the quantum circuit.
  8. 8 . The method of claim 1 , wherein said executing the first quantum circuit is performed a plurality of times, wherein a number of times the first quantum circuit is executed depends on the determination made for said determining the outcome of the execution of the first quantum circuit.
  9. 9 . The method of claim 1 , wherein said executing the first quantum circuit is performed a plurality of times, wherein the method further comprises performing quantum state tomography on results of the plurality of executions of the first quantum circuit to reconstruct a quantum state, wherein said determining the outcome is performed using the reconstructed quantum state.
  10. 10 . The method of claim 1 , wherein the non-compilable instruction is a control flow instruction that is based on an evaluation of a condition, wherein said determining the outcome of the execution of the first quantum circuit comprises evaluating the condition.
  11. 11 . The method of claim 10 , wherein the non-compilable instruction is selected from a group consisting of: IF statement, DO-WHILE statement, UNTIL statement, SWITCH statement, and CONDITIONAL GOTO statement.
  12. 12 . A method comprising: receiving a quantum program comprising a sequence of instructions, the sequence comprising a plurality of compilable instructions and at least one non-compilable instruction; selecting at least one of the compilable instructions for compiling, wherein said selecting is performed based at least on a type of the non-compilable instruction and on a position of the non-compilable instruction in the sequence; and compiling the selected at least one compilable instruction, whereby obtaining a quantum circuit that is executable by a quantum execution platform.
  13. 13 . The method of claim 12 , further comprising performing at least one early compilation step, wherein the early compilation step comprises: compiling and executing at least one instruction appearing in the sequence before the position of the non-compilable instruction, and conditioning compilation of at least one remaining instruction of the quantum program upon at least one result of said early compilation step.
  14. 14 . The method of claim 13 , wherein said early compilation step comprises repeatedly compiling and executing the at least one instruction appearing in the sequence before the position of the non-compilable instruction, for a predetermined number of times.
  15. 15 . The method of claim 13 , wherein said early compilation step comprises repeatedly compiling and executing the at least one instruction appearing in the sequence before the position of the non-compilable instruction until a predetermined condition is satisfied.
  16. 16 . The method of claim 13 , wherein the early compilation step comprises at least two early compilation steps, and each one of the early compilation steps is repeated for a different number of times.
  17. 17 . The method of claim 13 , wherein the at least one non-compilable instruction defines that a set of one or more compilable instructions is to be executed a predetermined number of times, wherein the predetermined number of times is ascertainable prior to execution of the quantum program, wherein the quantum circuit comprises a sequence of replicated layers, each of which corresponds to the set of one or more compilable instructions.
  18. 18 . A system comprising: a classical processor; a quantum execution platform; and wherein the system is configured to: receive a quantum program comprising a sequence of instructions, the sequence of instructions comprising compilable instructions and a non-compilable instruction; select a first subset of the compilable instructions, wherein the selection is performed based on the non-compilable instruction; compile the first subset of the compilable instructions, whereby obtaining a first quantum circuit; execute the first quantum circuit using the quantum execution platform; after the execution of the first quantum circuit, select a second subset of the compilable instructions, wherein the first subset and the second subset are different; and compile the second subset of the compilable instructions, whereby obtaining a second quantum circuit that can be executed by the quantum execution platform.
  19. 19 . The system of claim 18 , wherein the non-compilable instruction does not have a counterpart instruction in any of the first quantum circuit and the second quantum circuit.
  20. 20 . The system of claim 18 , wherein the non-compilable instruction is a control flow instruction that is based on an evaluation of a condition, wherein the evaluation of the condition is performed after the first quantum circuit is executed and based on an outcome thereof, wherein the second subset of the compilable instructions is determined based on the evaluation of the condition.

Description

TECHNICAL FIELD The present disclosure relates to quantum computing in general, and to implementing control flow structures in quantum programming, in particular. BACKGROUND Quantum computing is an emerging field that leverages the principles of quantum mechanics to perform computations. Unlike classical computers that use bits to represent information as 0 or 1, quantum computers use quantum bits or qubits that can exist in superposition states. This allows quantum computers to potentially solve certain complex problems much faster than classical computers. Programming quantum computers presents unique challenges compared to classical programming. Quantum algorithms often require manipulating qubits through quantum gates and measurements. As quantum systems are inherently probabilistic, multiple executions of a quantum program may be needed to obtain meaningful results. Additionally, quantum states are fragile and susceptible to errors, necessitating error correction techniques. These fundamental differences from classical computing create a need for new programming paradigms and tools tailored for quantum systems. BRIEF SUMMARY One exemplary embodiment of the disclosed subject matter is a method comprising receiving a quantum program comprising a sequence of instructions, the sequence of instructions comprising compilable instructions and a non-compilable instruction. The method includes selecting a first subset of the compilable instructions, wherein said selecting the first subset is performed based on the non-compilable instruction. The method further comprises compiling the first subset of the compilable instructions, whereby obtaining a first quantum circuit, executing the first quantum circuit using a quantum execution platform, and determining an outcome of the execution of the first quantum circuit. The method also includes selecting a second subset of the compilable instructions, wherein the first subset and the second subset are different, and compiling the second subset of the compilable instructions, whereby obtaining a second quantum circuit that can be executed by the quantum execution platform. Optionally, selecting the first subset is performed based at least on a position of the non-compilable instruction in the sequence of instructions. Optionally, the sequence of instructions comprises a first compilable instruction, the non-compilable instruction, and a second compilable instruction, arranged in that specific order within the sequence of instructions, wherein the first subset comprises the first compilable instruction and excludes the second compilable instruction, wherein the second subset comprises the second compilable instruction. Optionally, the second subset comprises the first compilable instruction. Optionally, the sequence of instructions comprises a first compilable instruction, the non-compilable instruction, a second non-compilable instruction, a second compilable instruction, arranged in that specific order within the sequence of instructions, wherein the first subset comprises the first compilable instruction and excludes the second compilable instruction, wherein the second subset comprises the second compilable instruction and excludes the first compilable instruction, wherein the second non-compilable instruction is an instruction that initiates a new phase of program execution or alters the control flow of the quantum program. Optionally, the method further comprises executing the second quantum circuit using the quantum execution platform. Optionally, the method further comprises repeatedly: selecting a subset of the compilable instructions, compiling the subset to obtain a quantum circuit, executing the quantum circuit, and determining control flow based on an outcome of the execution of the quantum circuit. Optionally, executing the first quantum circuit is performed a plurality of times, wherein a number of times the first quantum circuit is executed depends on the determination made for determining the outcome of the execution of the first quantum circuit. Optionally, executing the first quantum circuit is performed a plurality of times, wherein the method further comprises performing quantum state tomography on results of the plurality of executions of the first quantum circuit to reconstruct a quantum state, wherein determining the outcome is performed using the reconstructed quantum state. Optionally, the non-compilable instruction is a control flow instruction that is based on an evaluation of a condition, wherein determining the outcome of the execution of the first quantum circuit comprises evaluating the condition. Optionally, the non-compilable instruction is selected from a group consisting of: IF statement, DO-WHILE statement, UNTIL statement, SWITCH statement, and CONDITIONAL GOTO statement. Another exemplary embodiment of the disclosed subject matter is a method comprising receiving a quantum program comprising a sequence of instructions, the sequence