D-Wave Sampler

A dimod sampler for the D-Wave system.

See Ocean Glossary for explanations of technical terms in descriptions of Ocean tools.


class DWaveSampler(**config)[source]

A class for using the D-Wave system as a sampler.

Inherits from dimod.Sampler and dimod.Structured.

Enables quick incorporation of the D-Wave system as a sampler in the D-Wave Ocean software stack. Also enables optional customizing of input parameters to D-Wave Cloud Client (the stack’s communication-manager package).

Typically you store the parameters used to identify and communicate with your D-Wave system in a configuration file, the D-Wave Cloud Client configuration file, which may include more than one profile, and are selected when not overridden by explicit input arguments or environment variables. For more information, see D-Wave Cloud Client.

  • config_file (str, optional) – Path to a D-Wave Cloud Client configuration file that identifies a D-Wave system and provides connection information.
  • profile (str, optional) – Profile to select from the configuration file.
  • endpoint (str, optional) – D-Wave API endpoint URL.
  • token (str, optional) – Authentication token for the D-Wave API to authenticate the client session.
  • solver (dict/str, optional) – Solver (a D-Wave system on which to run submitted problems) to select given as a set of required features. Supported features and values are described in get_solvers(). For backward compatibility, solver name, formatted as a string, is accepted.
  • proxy (str, optional) – Proxy URL to be used for accessing the D-Wave API.
  • **config – Keyword arguments passed directly to from_config().


This example submits a two-variable Ising problem mapped directly to qubits 0 and 1 on the example system.

Example configuration file /home/susan/.config/dwave/dwave.conf:

endpoint = https://url.of.some.dwavesystem.com/sapi
client = qpu
solver = {"num_qubits__gte": 2000}
token = ABC-123456789123456789123456789
>>> from dwave.system.samplers import DWaveSampler
>>> sampler = DWaveSampler()
>>> response = sampler.sample_ising({0: -1, 1: 1}, {})
>>> for sample in response.samples():  # doctest: +SKIP
...    print(sample)
{0: 1, 1: -1}

See Ocean Glossary for explanations of technical terms in descriptions of Ocean tools.

Sampler Properties

D-Wave System Documentation lists and describes the parameters and properties of D-Wave systems.

DWaveSampler.properties D-Wave solver properties as returned by a SAPI query.
DWaveSampler.parameters D-Wave solver parameters in the form of a dict, where keys are keyword parameters accepted by a SAPI query and values are lists of properties in DWaveSampler.properties for each key.
DWaveSampler.nodelist List of active qubits for the D-Wave solver.
DWaveSampler.edgelist List of active couplers for the D-Wave solver.
DWaveSampler.adjacency Adjacency structure formatted as a dict, where keys are the nodes of the structured sampler and values are sets of all adjacent nodes for each key node.
DWaveSampler.structure Structure of the structured sampler formatted as a namedtuple Structure(nodelist, edgelist, adjacency), where the 3-tuple values are the nodelist and edgelist properties and adjacency() method.

Sample Methods

DWaveSampler.sample(bqm, **parameters) Samples from a binary quadratic model using an implemented sample method.
DWaveSampler.sample_ising(h, J, **kwargs) Sample from the specified Ising model.
DWaveSampler.sample_qubo(Q, **kwargs) Sample from the specified QUBO.


DWaveSampler.validate_anneal_schedule(…) Raise an exception if the specified schedule is invalid for the sampler.