Ocean Software Stack#
The Ocean software stack provides a chain of tools that implements the steps needed to solve your problem on a CPU, a D-Wave quantum computer, or a quantum-classical hybrid solver. As described in the Workflow Steps: Formulation and Sampling section, these steps include formulating the problem in a way the solver understands (as a supported model) and solving the formulated problem by submitting it to a D-Wave quantum computer, a classical sampler, or a hybrid solver.
It’s helpful to visualize the tool chain as layers of abstraction, each of which handles one part of the solution procedure.
Abstraction Layers#

Fig. 201 Ocean Software Stack#
The Ocean Software Stack graphic above divides Ocean software and its context into the following layers of functionality:
Compute Resources
The hardware on which the problem is solved. This might be a D-Wave quantum computer but it can also be the CPU of your laptop computer or one of the Leap service’s hybrid solvers.
Samplers
Abstraction layer of the sampler functionality. Ocean tools implement several samplers that use the D-Wave quantum computer and classical compute resources. You can use the Ocean tools to customize a sampler, create your own sampler, or use existing (classical) samplers to test your code as you develop it.
Sampler API
Abstraction layer that represents the problem in a form that can access the selected sampler; for example, a dimod binary quadratic model (BQM) class representing your problem wrapped in a minor-embedding composite that handles the mapping between your problem’s variables and the sampler’s topology.
Methods
Tools that help formulate a problem as supported models; for example the dwave_networkx package for graph-related problems.
Application
Original problem in its context (“problem space”); for example, circuit fault diagnosis attempts to identify failed logic gates during chip manufacturing.
Problem-to-Solution Tool Chain#
As described in the Workflow Steps: Formulation and Sampling section, problems can be posed in a variety of formulations; the D-Wave quantum computer solves binary quadratic models (term:BQM) and other hybrid solvers handle more abstract models. Ocean tools assist you in converting the problem from its original form to a form native to the solver and sending the compatible problem for solving.
This section will familiarize you with the different tools and how you can fit them together to solve your problem.
Bottom-Up Approach#
One approach to envisioning how you can map your problem-solving process to Ocean software is to start from the bottom—the hardware doing the computations—and work your way up the Ocean stack to see the complete picture. This subsection shows how you might map each stage of the process to a layer of the Ocean stack.
Compute resource
You will likely use some combination of both local classical resources and a D-Wave quantum computer in your work with Ocean software. When would you use which?
CPU: For offline testing, small problems that can be solved exactly or heuristically in a reasonable amount of time.
QPU: Hard problems or for learning how to use quantum resources to solve such problems.
Hybrid of both QPU and CPU/GPU: Large, complex problems that need to run classically but may benefit from having some parts allocated to a quantum computer for solution.
Sampler
Your sampler provides access to the compute resource that solves your problem.
The table below shows some Ocean samplers and considerations for selecting one or another.
Table 58 Ocean Samplers# Computation
Tool & Sampler
Usage
Notes
Classical
Find all states for small (<20 variables) problems.
For code-development testing.
Classical
Random sampler for testing.
For code-development testing.
Classical
Simulated annealing sampler for testing.
For code-development testing.
Classical
A steepest-descent solver for binary quadratic models.
For post-processing and convex problems.
Classical
Simulated annealing sampler.
Quantum
Quick incorporation of the D-Wave quantum computer as a sampler.
Typically part of a composite that handles minor-embedding.
Quantum
Quick incorporation of the D-Wave quantum computer as a sampler.
Handles minor-embedding for clique (complete graph) problems.
Quantum
dwave-cloud-client
Solver()
D-Wave quantum computer as a sampler.[1]
For low-level control of problem submission.
Hybrid
dimod-compatible hybrid asynchronous decomposition sampler.
For problems of arbitrary structure and size.
Hybrid
Leap service’s
LeapHybridNLSampler
Cloud-based quantum-classical hybrid solver.
For application problems formulated as nonlinear models.
Hybrid
Leap service’s
LeapHybridCQMSampler
Cloud-based quantum-classical hybrid solver.
For constrained quadratic models (CQM) of arbitrary structure and size.
dimod custom
Write a custom sampler for special cases.
See examples in the dimod reference documentation.
Pre- and Post-Processing
Samplers can be composed of composite patterns that layer pre- and post-processing to binary quadratic programs without changing the underlying sampler.
The table below shows some Ocean composites and considerations for selecting one or another.
Table 59 Ocean Composites# Tool & Composite
Usage
Notes
dwave-system package’s
EmbeddingComposite
classMaps unstructured problems to a structured sampler.
Enables quick incorporation of the D-Wave quantum computers as a sampler by handling the minor-embedding to the QPU’s topology of qubits.
dwave-system package’s
FixedEmbeddingComposite
classMaps unstructured problems to a structured sampler.
Uses a pre-calculated minor-embedding for improved performance.
dwave-system package’s
TilingComposite
classTiles small problems multiple times to a structured sampler.
Enables parallel sampling for small problems.
dimod package’s
TrackingComposite
classTracks inputs and outputs.
Helps with testing and debugging.
dwave-preprocessing package’s
SpinReversalTransformComposite
classApplies spin reversal transform preprocessing.
Improves QPU results by reducing the impact of possible analog and systematic errors.
dimod package’s
StructureComposite
classCreates a structured composed sampler from an unstructured sampler.
Maps from a problem graph (e.g., a square graph) to a sampler’s graph.
In addition to composites that provide pre- and post-processing, Ocean also provides stand-alone tools to handle complex or large problems. For example:
minorminer for minor-embedding might be used to improve solutions by fine tuning parameters or incorporating problem knowledge into the embedding.
dwave-samplers provides a steepest-descent solver for binary quadratic models that can be run on the samples returned from solvers such as the
DWaveSampler
sampler to find local minima in the neighbourhoodsdwave-hybrid splits problems too large for the QPU into pieces solved either via a D-Wave quantum computer or a classical solver.
Map to a Supported Format
Typically, you formulate your problem as a binary quadratic model (BQM), which you solve by submitting to the sampler (with its pre- and post-processing composite layers) you select based on the considerations listed above.
Ocean provides tools for formulating the BQM:
dwavebinarycsp for constraint satisfaction problems with small constraints over binary variables. For example, many problems can be posed as satisfiability problems or with Boolean logic.
dwave_networkx for implementing graph-theory algorithms of the D-Wave quantum computer. Many problems can be posed in a form of graphs—this tool handles the construction of BQMs for several standard graph algorithms such as maximum cut, cover, and coloring.
You might formulate a BQM mathematically; see the NOT Gate: Simple QUBO section for a mathematical formulation for a two-variable problem.
See the Reformulating a Problem section for more information on techniques for formulating problems as BQMs.
Formulate
The first step in solving a problem is to express it in a mathematical formulation. For example, the Map Coloring: Complex Constraints problem is to assign a color to each region of a map such that any two regions sharing a border have different colors. To begin solving this problem on any computer, classical or quantum, it must be concretely defined; an intuitive approach, for the map problem, is to think of the regions as variables representing the possible set of colors, the values of which must be selected from some numerical scheme, such as natural numbers.
The selection function must express the problem’s constraints:
Each region is assigned one color only, of C possible colors.
The color assigned to one region cannot be assigned to adjacent regions.
Now solving the problem means finding a permissible value for each of the variables.
When formulating a problem for the D-Wave quantum computer, bear in mind a few considerations:
Mathematical formulations must use binary variables because the solution is implemented physically with qubits, and so must translate to spins \(s_i \in {−1, +1}\) or equivalent binary values \(x_i \in {0, 1}\).
Relationships between variables must be reducible to quadratic (e.g., a QUBO) because the problem’s parameters are represented by qubits’ weights and couplers’ strengths on a QPU.
Formulations should be sparing in its number of variables because a QPU has a limited number of qubits and couplers.
Alternative formulations may have different implications for performance.
Ocean demo applications, which formulate known problems, include:
Top-Down Approach#
Another approach to envisioning how you can map your problem-solving process to Ocean software is to start from the top—your (possibly abstractly defined) problem—and work your way down the Ocean stack.
Step |
Description |
---|---|
State the Problem |
Define your problem concretely/mathematically; for example, as a constraint satisfaction problem (term:CSP) or a graph problem. |
Formulate as a BQM |
Reformulate an integer problem to use binary variables, for example, or convert a nonquadratic (high-order) polynomial to a QUBO. Ocean’s dwavebinarycsp and dwave_networkx packages can be helpful for some problems. |
Decompose |
Allocate large problems to classical and quantum resources. Ocean’s dwave-hybrid package provides a framework and building blocks to help you create hybrid workflows. |
Embed |
Consider whether your problem has repeated elements, such as logic
gates, when deciding what tool to use to minor-embed your BQM
on the QPU. You might start with fully automated embedding (using
the |
Configure the QPU |
Use spin-reversal transforms to reduce errors, for example, or examine the annealing with reverse anneal. See the Basic QPU Configuration section for more information. |