The Hosted Hybrid service is currently in a limited preview and only available
to customers with an active contract. Please contact
[email protected] for more information.
- Hamiltonian Energy, which takes an ansatz and a hamiltonian to perform hamiltonian energy evaluation.
- Quadratically Constrained Quadratic Program that models the objective of a (constrained) quadratic program. This
QuantumFunction
can be used to solve constrained quadratic programs.
Setup
To run hybrid workloads with this tool, you’ll need:1
2
The IonQ SDK and all its extras
Client
which will allow us to connect to IonQ’s platform, then select a backend to use with it.
Creating a demo workload
In practice, you’d be using our hamiltonian energy evaluations to evaluate your own hamiltonians and ansatze, but for this guide we’ll build a couple of functions for creating random inputs — but if you can provide your own, more the better. So first, we’ll build an example hamiltonian:print
ed it, would look something like:
Now we’ll do the same for an example ansatz and some initial parameters:
Example 1: Running a simple circuit
As a simple demonstration of functionality, let’s take our backend and submit a basic circuit job to it using our example ansatz. This is not a hybrid workflow, but a normal circuit job. Note: We’re usingionq.ionq_qiskit
, which is a helper library we are providing for translating Qiskit circuits into IonQ-native QIS.
Example 2: Running a Quantum Function
Now we’re build on this by submitting aQuantumFunction
instead of just a simple circuit.
A quantum function is a workload that has some predefined logic built in to it. In this case, we’ll pass it an ansatz and a hamiltonian, and when we send it to the backend along with a set of parameters, it will submit circuits and do an Hamiltonian Energy evaluation.
Example 3: Quadratically Constrained Quadratic Program Objective
We can also prepare the model for a constrained quadratic program, by creating a Quantum Function that takes an ansatz, a QUBO matrix, and a list of constraints. This can then be used to solve constrained quadratic programs with classical optimization methods. Let’s first model it, with some simple linear constraints and confirm it runs with a random set of parameters.Example 4: Optimizations
We can also run a (IonQ hosted!) classical loop to optimize our parameters. Here we’ll take the same quantum function we ran in Example 3, but we’ll add a 5-iteration optimization using SPSA. It doesn’t add that much complexity here, only requiring some simple additions:- What
method
to use for optimization - The maximum desired number of iterations
- The learning rate, and perturbation for each iteration
plot_results()
gives us:
And retrieving the “results” of this job will identify the
minimum_value
and optimal_parameters
for the problem: