Quantum Solvers#

Ocean’s dwave-system package enables you to use a D-Wave quantum computer as a sampler. In addition to DWaveSampler, the package provides an EmbeddingComposite composite that maps unstructured problems to the graph structure of the selected sampler, a process known as minor-embedding.

Example#

Note

The Configuring Access to the Leap Service (Basic) steps you through configuring access to D-Wave quantum computers.

For a binary quadratic model (BQM) representing a Boolean AND gate (see the Formulation Example: BQM for a Boolean Circuit section for more details) the problem is defined on alphanumeric variables \(in1, in2, out\) that must be mapped to the QPU’s numerically indexed qubits.

>>> from dimod.generators import and_gate
>>> bqm = and_gate('in1', 'in2', 'out')

Because of the sampler’s probabilistic nature, you typically request multiple samples for a problem; this example sets the num_reads solver parameter to 1000.

>>> from dwave.system import DWaveSampler, EmbeddingComposite
>>> sampler = EmbeddingComposite(DWaveSampler())
>>> sampleset = sampler.sample(bqm, num_reads=1000)
>>> print(sampleset)   
  in1 in2 out energy num_oc. chain_.
0   1   0   0    0.0     321     0.0
1   1   1   1    0.0      97     0.0
2   0   0   0    0.0     375     0.0
3   0   1   0    0.0     206     0.0
4   1   0   1    2.0       1 0.33333
['BINARY', 5 rows, 1000 samples, 3 variables]

Note that the first four samples are the valid states of the AND gate and have lower energy than invalid state \(in1=1, in2=0, out=1\).

For additional beginner examples of submitting problems to D-Wave quantum computers, see the Basic QPU Examples section