Solve higher-order binary optimization problems with Q-CTRL's Optimization Solver
Usage estimate: 24 minutes on ibm_fez. (NOTE: This is an estimate only. Your runtime may vary.)
Background
This tutorial demonstrates how to solve a higher-order binary optimization (HOBO) problem using the Optimization Solver, a Qiskit Function by Q-CTRL Fire Opal. The example demonstrated in this tutorial is an optimization problem designed to find the ground-state energy of a random-bond 156-qubit Ising model possessing cubic terms. The Optimization Solver can be used for general optimization problems that can be defined as an objective function.
The Optimization fully automates the hardware-aware implementation steps of solving optimization problems on quantum hardware, and by leveraging Performance Management for the quantum execution, it achieves accurate solutions at utility scale. For a detailed summary of the full Optimization Solver workflow and benchmarking results, refer to the published manuscript.
This tutorial walks through the following steps:
- Define the problem as an objective function
- Run the hybrid algorithm using the Fire Opal Optimization Solver
- Evaluate results
Requirements
Before starting this tutorial, ensure that you have the following installed:
- Qiskit Functions (
pip install qiskit-ibm-catalog ) - SymPy (
pip install sympy ) - Matplotlib (
pip install matplotlib )
You will also need to get access to the Optimization Solver function. Fill out the form to request access.
Setup
First, import the required packages and tools.
No output produced
Define your IBM Quantum™ Platform credentials, which will be used throughout the tutorial to authenticate to Qiskit Runtime and Qiskit Functions.
No output produced
Step 1: Define the problem as an objective function
The Optimization Solver accepts either an objective function or a graph as input. In this tutorial, the Ising spin glass minimization problem is defined as an objective function, and it has been tailored for the heavy-hex topology of IBM devices.
Because this objective function contains cubic, quadratic, and linear terms, it falls into the HOBO class of problems, known to be considerably more complicated to solve than conventional quadratic unconstrained binary optimization (QUBO) problems.
For detailed discussion of the construction of the problem definition and previous results obtained from the Optimization Solver refer to this technical manuscript. The problem was originally defined and evaluated as part of a paper published by Los Alamos National Laboratory, and it has been adapted to leverage the full device width of the 156-qubit IBM Quantum Heron processors.
No output produced
Step 2: Run the hybrid algorithm using the Fire Opal Optimization Solver
Now use the Optimization Solver Qiskit Function to run the algorithm. Behind the scenes, the Optimization Solver takes care of mapping the problem to a hybrid quantum algorithm, running the quantum circuits with error suppression, and performing the classical optimization.
No output produced
Check to ensure that the chosen device has at least 156 qubits.
No output produced
The Solver accepts a string representation of the objective function.
No output produced
No output produced
You can use the familiar Qiskit Serverless APIs to check your Qiskit Function workload's status:
No output produced
The Solver returns a dictionary with the solution and associated metadata, such as the solution bitstring, number of iterations, and mapping of variables to bitstring. For a full definition of the Solver's inputs and outputs, check out the documentation.
No output produced
No output produced
Step 3: Evaluate results
Output:
Minimum ground state energy: -242.0
The Solver found the correct solution, which was validated using classical optimization software. The complexity of this utility-scale problem requires an advanced optimization software to be solved classically, such as IBM ILOG CPLEX Optimization Studio (CPLEX) or Gurobi Optimization.
As a visual analysis of the quality of results, you can plot the results by calculating the cost values from the bitstrings and their probabilities. For comparison, plot the results alongside a distribution of randomly sampled bitstrings, which is equivalent to a "brute-force" classical solution. If the algorithm consistently finds lower costs, it suggests the quantum algorithm is effectively solving the optimization problem.
No output produced
Output:
Since the goal of this optimization algorithm is to find the minimum ground state of the Ising model, lower values indicate better solutions. Therefore, it's visually apparent that the solutions generated by the Fire Opal Optimization Solver far outperform random selection.
Was this page helpful?