Blog
20
May
,
2021
Yuval Boger

Quantum programming 2.0: a focus on intent, not gates

Share the article
Our library

When I was a kid, I imagined a computer with just one big green button labeled “DWIM”. Pressing this “Do What I Mean” button would cause the computer to do exactly that: do what I wanted it to. While we are not there yet, a rapid transition is happening from low-level quantum programming to higher-level methods of expressing the intent.

We’ve seen this process play out in electronic circuit design. Consider a simple electronic circuit: a 4-bit binary counter. How would you prefer to design it? Option 1 (see the figure below) shows this counter implemented with discrete gates. Option 2 shows a version of this counter using VHDL — a high-level design language, using a pre-written building block.

What if instead of a 4-bit counter you needed to design the 32-bit version? Option 1 would get quite large, whereas option 2 remains the same. What if you received this circuit from someone else and needed to explain it did? For most people, option 2 would be much more readable and easier to explain. As the circuit complexity grows, it is more attractive to express the intent (“I’d like an 8-bit UART”) than to design the circuit from scratch

Option 1: From: Haghparast, Majid & Samadi Gharajeh, Mohammad. (2011). Design of a nanometric reversible 4-bit binary counter with parallel load. Australian Journal of Basic and Applied Sciences. 5. 63–71.
Option 2: Adapted from Xilinx 7 Series FPGA Libraries Guide for HDL Designs UG768 April 24, 2012

The same concept that is so successful in high-speed circuit design is now available for quantum computing. Creating a simple quantum circuit using a handful of qubits and a few parametrized building blocks is fun and instructive. But solving real-world problems with dozens or hundreds of qubits requires less gate-level coding and more efficient algorithm design.

For instance, a common need in quantum algorithms is initialization and state preparation. What if preparing the state for four qubits was as simple as:

This high-level code is automatically translated — within seconds — into a working quantum circuit:

Similar to how VHDL simplifies logic programming, this approach dramatically simplifies quantum programming. It has several important advantages:

  • Create complex algorithms with relative ease. Gate-based programming is not scalable. Quantum teams today face great difficulty in designing new algorithms. A high-level representation language that gets automatically synthesized into a working quantum circuit will go a long way towards enabling novel development.
  • Faster design with fewer errors. By focusing on the intent and not low-level programming, the designer can produce results faster. Because key algorithmic blocks (such as state preparation) were created and optimized by experts ahead of time, the programming errors are less likely
  • Code re-use. Just like in VHDL, vendors and users can create reusable building blocks to perform common functions: from traveling salesperson to Grover’s algorithm.
  • Easier debugging, and explainability. An algorithm that is constructed from high-level blocks is easier to understand and debug.
  • Hardware-agnostic. The conversion from intent to gates takes into account the specific limitations of each hardware platform — such as qubit connectivity and available operators — allowing faster transition from one platform to another.

While the “DYIM” button is still far away, intent-based programming such as that from Classiq uses high-level modeling and leads to the efficient generation, analysis and debug of quantum circuits. It is a major step forward, and we hope you can join us on this exciting journey.

When I was a kid, I imagined a computer with just one big green button labeled “DWIM”. Pressing this “Do What I Mean” button would cause the computer to do exactly that: do what I wanted it to. While we are not there yet, a rapid transition is happening from low-level quantum programming to higher-level methods of expressing the intent.

We’ve seen this process play out in electronic circuit design. Consider a simple electronic circuit: a 4-bit binary counter. How would you prefer to design it? Option 1 (see the figure below) shows this counter implemented with discrete gates. Option 2 shows a version of this counter using VHDL — a high-level design language, using a pre-written building block.

What if instead of a 4-bit counter you needed to design the 32-bit version? Option 1 would get quite large, whereas option 2 remains the same. What if you received this circuit from someone else and needed to explain it did? For most people, option 2 would be much more readable and easier to explain. As the circuit complexity grows, it is more attractive to express the intent (“I’d like an 8-bit UART”) than to design the circuit from scratch

Option 1: From: Haghparast, Majid & Samadi Gharajeh, Mohammad. (2011). Design of a nanometric reversible 4-bit binary counter with parallel load. Australian Journal of Basic and Applied Sciences. 5. 63–71.
Option 2: Adapted from Xilinx 7 Series FPGA Libraries Guide for HDL Designs UG768 April 24, 2012

The same concept that is so successful in high-speed circuit design is now available for quantum computing. Creating a simple quantum circuit using a handful of qubits and a few parametrized building blocks is fun and instructive. But solving real-world problems with dozens or hundreds of qubits requires less gate-level coding and more efficient algorithm design.

For instance, a common need in quantum algorithms is initialization and state preparation. What if preparing the state for four qubits was as simple as:

This high-level code is automatically translated — within seconds — into a working quantum circuit:

Similar to how VHDL simplifies logic programming, this approach dramatically simplifies quantum programming. It has several important advantages:

  • Create complex algorithms with relative ease. Gate-based programming is not scalable. Quantum teams today face great difficulty in designing new algorithms. A high-level representation language that gets automatically synthesized into a working quantum circuit will go a long way towards enabling novel development.
  • Faster design with fewer errors. By focusing on the intent and not low-level programming, the designer can produce results faster. Because key algorithmic blocks (such as state preparation) were created and optimized by experts ahead of time, the programming errors are less likely
  • Code re-use. Just like in VHDL, vendors and users can create reusable building blocks to perform common functions: from traveling salesperson to Grover’s algorithm.
  • Easier debugging, and explainability. An algorithm that is constructed from high-level blocks is easier to understand and debug.
  • Hardware-agnostic. The conversion from intent to gates takes into account the specific limitations of each hardware platform — such as qubit connectivity and available operators — allowing faster transition from one platform to another.

While the “DYIM” button is still far away, intent-based programming such as that from Classiq uses high-level modeling and leads to the efficient generation, analysis and debug of quantum circuits. It is a major step forward, and we hope you can join us on this exciting journey.

About "The Qubit Guy's Podcast"

Hosted by The Qubit Guy (Yuval Boger, our Chief Marketing Officer), the podcast hosts thought leaders in quantum computing to discuss business and technical questions that impact the quantum computing ecosystem. Our guests provide interesting insights about quantum computer software and algorithm, quantum computer hardware, key applications for quantum computing, market studies of the quantum industry and more.

If you would like to suggest a guest for the podcast, please contact us.

See Also

No items found.

Start Creating Quantum Software Without Limits

contact us