dwave-system enables easy incorporation of the D-Wave system as a sampler—the component used to find variable values that minimize the binary quadratic model (BQM) representing a problem—in the typical Ocean problem-solving procedure:
- Formulate the problem as a BQM.
- Solve the BQM with a sampler.
This example solves a small example of a known graph problem, minimum
vertex cover. It uses the NetworkX
graphic package to create the problem, Ocean’s dwave_networkx
to formulate the graph problem as a BQM, and dwave-system’s
DWaveSampler() to use a D-Wave system as the sampler.
(Access to a D-Wave system has been set up in
a configuration file that is used implicitly.) dwave-system’s
EmbeddingComposite() handles mapping between the problem graph
to the D-Wave system’s numerically indexed qubits, a mapping known as minor-embedding.
>>> import networkx as nx >>> import dwave_networkx as dnx >>> from dwave.system.samplers import DWaveSampler >>> from dwave.system.composites import EmbeddingComposite ... >>> s5 = nx.star_graph(4) # a star graph where node 0 is hub to four other nodes >>> sampler = EmbeddingComposite(DWaveSampler()) >>> print(dnx.min_vertex_cover(s5, sampler)) 
Using the D-Wave System as a Sampler¶
The dimod API makes it possible to easily interchange samplers in your code. For example, you might develop code using dwave_neal, Ocean’s simulated annealing sampler, and then swap in a D-Wave system composed sampler.
Using a D-Wave System explains how you set up access to a D-Wave system.
D-Wave System Documentation describes the D-Wave system, its features, parameters, and properties. The documentation provides guidance on programming the D-Wave system, including how to formulate problems and configure parameters.
Samplers are processes that sample from low energy states of a problem’s objective function. A BQM sampler samples from low energy states in models such as those defined by an Ising equation or a Quadratic Unconstrained Binary Optimization (QUBO) problem and returns an iterable of samples, in order of increasing energy.
Ocean software provides a variety of dimod samplers, which
all support ‘sample_qubo’ and ‘sample_ising’ methods as well as the generic BQM sampler method.
In addition to
DWaveSampler(), classical solvers, which run on CPU or GPU, are available and
useful for developing code or on a small versions of a problem to verify code.
Hybrid Quantum-Classical Samplers¶
Quantum-classical hybrid is the use of both classical and quantum resources to solve problems, exploiting the complementary strengths that each provides.
D-Wave’s Leap Quantum Application Environment provides state-of-the-art hybrid solvers you can submit arbitrary BQMs to. dwave-hybrid provides you with a Python framework for building a variety of flexible hybrid workflows that use quantum and classical resources together to find good solutions to your problem.
Samplers can be composed. The composite pattern allows layers of pre- and post-processing to be applied to binary quadratic programs without needing to change the underlying sampler implementation. We refer to these layers as composites. A composed sampler includes at least one sampler and possibly many composites.
To solve an arbitrarily posed binary quadratic problem directly on a D-Wave system requires mapping,
called minor embedding, to a Chimera graph that represents the system’s quantum processing unit.
This preprocessing can be done by a composed sampler consisting of the
DWaveSampler() and a composite that performs minor-embedding.
(This step is handled automatically by
and dwave-hybrid reference samplers.)