A sampler accepts a binary quadratic model (BQM) and returns variable assignments. Samplers generally try to find minimizing values but can also sample from distributions defined by the BQM.


class DWaveSampler(failover=False, retry_interval=-1, **config)[source]

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

Uses parameters set in a configuration file, as environment variables, or explicitly as input arguments for selecting and communicating with a D-Wave system. For more information, see D-Wave Cloud Client.

Inherits from dimod.Sampler and dimod.Structured.

  • failover (bool, optional, default=False) – Switch to a new QPU in the rare event that the currently connected system goes offline. Note that different QPUs may have different hardware graphs and a failover will result in a regenerated nodelist, edgelist, properties and parameters.
  • retry_interval (number, optional, default=-1) – The amount of time (in seconds) to wait to poll for a solver in the case that no solver is found. If retry_interval is negative then it will instead propogate the SolverNotFoundError to the user.
  • config_file (str, optional) – Path to a 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, a 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 a D-Wave system selected by explicitly requiring that it have these two active qubits. Other required parameters for communication with the system, such as its URL and an autentication token, are implicitly set in a configuration file or as environment variables, as described in Configuring a D-Wave System.

>>> from dwave.system.samplers import DWaveSampler
>>> sampler = DWaveSampler(solver={'qubits__issuperset': {0, 1}})
>>> sampleset = sampler.sample_ising({0: -1, 1: 1}, {})
>>> for sample in sampleset.samples():  # doctest: +SKIP
...    print(sample)
{0: 1, 1: -1}

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


For parameters and properties of D-Wave systems, see D-Wave System Documentation. 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 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, edgelist and adjacency attributes.


DWaveSampler.sample(bqm, **parameters) Sample from a binary quadratic model.
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.