AI programming your quantum algorithms

Programming classical computers can already be extremely challenging, but programming a quantum computer may be even more difficult. Luckily, Classiq already makes this a lot easier by abstracting away a lot of the low-level gate-based programming that is typically needed. But it can still be challenging, that is why Classiq now supports AI programming agents to support your development. Let's see how to set it up VS Code. This is just a way to use it there are multiple.

Step 1 - Environment setup.

  • I will be using VS Code, which can be freely downloaded here.
  • Install the Cline extension, which can be found here.
  • Click the Cline icon on the left, it should look like this:
  • Select the right agent and insert your API via the model selector at the bottom, like this:
  • I am using Anthropic, but it could be other AI agents in the dropdown as well.

Step 2 - Set up the Classiq environment

  • Clone the Classiq library to your computer.
  • Open the Classiq library folder with your VS Code, it should look something like this:
  • [Optional] Run a notebook like tutorials -> entanglement to make sure your Classiq environment works.
  • If you have never logged into Classiq. In the notebook, run the command: authenticate(). This will log you in.

Step 3 - Teach the AI how to use Classiq.

  • Open the Cline extension again, and type this text in the box:
You are a quantum algorithms expert specializing in the Classiq python SDK. Your task is to help write quantum algorithms using Classiq's high-level quantum programming approach.

Key Guidelines:
- **Python by default:** use Classiq's python SDK only. read `*.qmod` files only when specifically asked to write code in native QMOD.
- Use Classiq's high-level synthesis approach rather than low-level gate-level programming
- Leverage Classiq's built-in functions and operators for common quantum operations
- Follow Classiq's best practices for circuit design and optimization
- Reference the examples and documentation in this library repository for patterns and approaches


Key Resources (under classiq-library/):
- algorithms/ - Production quantum algorithms (Shor's, Grover's, QAOA, VQE, QML, etc.)
- applications/ - Real-world implementations (finance, chemistry, optimization, ML)
- tutorials/ - Step-by-step guides for learning quantum programming with Classiq
- .internal/docs/ - Complete QMOD language reference with types, operators, and syntax
- functions/ - Reusable quantum function library

When writing code:
1. Start with a clear problem statement
2. Use Classiq's high-level constructs and functions
3. Include proper imports and setup
4. Add comments explaining the quantum logic
5. Consider circuit optimization and resource constraints

There could be a newer version for this prompt, so check here to get the latest.

The AI should now be analyzing the repo, it should output a message, something like this:

When you get this message, you can ask the AI to program what you are working on.


Step 4 - Use the AI agent to create your desired program

I asked the AI agent to program a quantum program to price butterfly options. This is not in the library, but the building blocks to create this program are already in the library, which will be used when creating the program. My prompt was:

I would like you to create a quantum application that uses Classiq to price butterfly options. This program should also show a comparison of classical pricing and the quantum implementation. 

The output was a Python program that did exactly what I asked it to do and even created some nice graphs.

I hope AI will help you make some amazing quantum programs using Classiq.