Hosted Hybrid Service
Run hybrid execution loops using functions managed by IonQ’s Cloud.
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.
IonQ’s Hosted Hybrid Service allows users to run hybrid quantum-classical workloads without needing to write or host the classical optimization logic. This means that you can run a hybrid algorithm like a VQE, optimize the inputs with a method like SPSA, and do it all without having to write-or-run any of the code yourself.
This service introduces a two new things to our platform:
A Quantum Function is an abstraction that represents a composition of classical and quantum logic to perform simple computations. We currently expose two types of Quantum Functions:
- 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.
An Optimization looks for the optimal parameters for a Quantum Function using a supported optimization function. Once completed, the solution returned is the minimum energy value and the optimal parameters used to achieve it.
These new tools allow you take a problem that you want to solve, represent it in the form of a function, and run it through an optimization routine—without having to run any of the classical code yourself in a local notebook, or manage a remote execution environment.
Setup
To run hybrid workloads with this tool, you’ll need:
The IonQ SDK and all its extras
We’ll start by setting up our our 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:
Which, if we print
ed it, would look something like:
Now we’ll do the same for an example ansatz and some initial parameters:
Which will produce an ansatz that looks something like:
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 using ionq.ionq_qiskit
, which is a helper library we are providing for translating Qiskit circuits into IonQ-native QIS.
And plotting this circuit we’ll see something like:
Example 2: Running a Quantum Function
Now we’re build on this by submitting a QuantumFunction
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
These values will define how each iteration in the series will change based on the results of the previous job.
As before, we’ve provided some useful helpers for visualization. running plot_results()
gives us:
And retrieving the “results” of this job will identify the minimum_value
and optimal_parameters
for the problem:
Learn more
This service is still in a private alpha at this time, but reach out to [email protected] for more information, or contact your account manager.
Was this page helpful?