Giter Site home page Giter Site logo

dwavesystems / dwave-system Goto Github PK

View Code? Open in Web Editor NEW
87.0 14.0 61.0 2.04 MB

An API for easily incorporating the D-Wave system as a sampler, either directly or through Leap's cloud-based hybrid samplers

Home Page: https://docs.ocean.dwavesys.com/

License: Apache License 2.0

Python 100.00%
quantum-computing

dwave-system's Introduction

PyPI - Python Version https://circleci.com/gh/dwavesystems/dwave-system.svg?style=shield

dwave-system

dwave-system is a basic API for easily incorporating the D-Wave system as a sampler in the D-Wave Ocean software stack, directly or through Leap's cloud-based hybrid solvers. It includes DWaveSampler, a dimod sampler that accepts and passes system parameters such as system identification and authentication down the stack, LeapHybridSampler, for Leap's hybrid solvers, and other. It also includes several useful composites---layers of pre- and post-processing---that can be used with DWaveSampler to handle minor-embedding, optimize chain strength, etc.

Installation

Installation from PyPI:

pip install dwave-system

Installation from PyPI with drivers:

Note

Prior to v0.3.0, running pip install dwave-system installed a driver dependency called dwave-drivers (previously also called dwave-system-tuning). This dependency has a restricted license and has been made optional as of v0.3.0, but is highly recommended. To view the license details:

from dwave.drivers import __license__
print(__license__)

To install with optional dependencies:

pip install dwave-system[drivers] --extra-index-url https://pypi.dwavesys.com/simple

Installation from source:

pip install -r requirements.txt
python setup.py install

Note that installing from source installs dwave-drivers. To uninstall the proprietary components:

pip uninstall dwave-drivers

License

Released under the Apache License 2.0. See LICENSE file.

Contributing

Ocean's contributing guide has guidelines for contributing to Ocean packages.

dwave-system's People

Contributors

akashnarayanan avatar arcondello avatar bellert avatar boothby avatar conta877 avatar djohnson-dwavesys avatar jackraymond avatar joelpasvolsky avatar joseppinilla avatar m3ller avatar marshall-dw avatar oneklc avatar pau557 avatar pierrelouisp avatar randomir avatar shinichi-takayanagi avatar thisac avatar wbernoudy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dwave-system's Issues

Embedding composites should also transform parameters.

Some parameters are "qubit specific", like initial state or anneal offsets. Would be good if they were transformed the same way the problem is transformed.

For example, suppose I have a small "logical" problem, and I use an embedding to sample from it with the hardware. If I want to use reverse annealing, the initial state I will provide will be in the "logical" space, and won't be mapped to the "embedded" space before being passed to the child sampler.

Propagate chain break resolution methods through embedding composites

Current Problem
dimod provides several different chain break methods, but EmbeddingComposite and FixedEmbeddingComposite are hard-coded to use the default 'majority vote'.

Proposed Solution

EmbeddingComposite(DWaveSampler()).sample(bqm, chain_break_method=dimod.discard)
FixedEmbeddingComposite(DWaveSampler(), embedding, chain_break_method=dimod.discard).sample(bqm)

Make DWaveSampler picklable

DWaveSampler is not picklable. It should be in order to integrate for example with sklearn.

In [1]: from dwave.system.samplers import DWaveSampler

In [2]: import pickle

In [3]: annealer = DWaveSampler()

In [4]: pickle.dumps(annealer)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-bef1022bace0> in <module>()
----> 1 pickle.dumps(annealer)

TypeError: can't pickle _thread.lock objects

How to fix random state like Decision Tree?

I'm using DWaveSampler, and want to compare results of two different settings.
They should return same result, however, the results are always different.
Is there random state in DWaveSampler? If so, how do I fix the random state?
Thanks!

LazyFixedEmbeddingComposite

Current Problem
It would be nice to have something between the EmbeddingComposite and FixedEmbeddingComposite

Proposed Solution
A LazyEmbeddingComposite that uses minorminer to embed the first bqm handed to it, the reuses that embedding in the future.

>>> sampler = LazyEmbeddingComposite(DWaveSampler())
>>> sampler.nodelist
None
>>> sampler.edgelist
None
>>> sampler.sample_ising({}, {(0, 1): -1, (1, 2): -1, (2, 0): -1})
>>> sampler.nodelist
[0, 1, 2]
>>> sampler.edgelist
[(0, 1), (1, 2), (0, 2)]

Dummy Issue

Dummy issue: testing out GitHub Slack integration.

VirtualGraphComposite: Improve error message for out-of-range qubit

If an embedding specifies a qubit that is outside the range of the child sampler, it would be nice to see a more specific error -- users might not always be aware of the ranges of different solvers.

embedding = {'x': {1}, 'y': {5}, 'z': {0,4}, 'a': {4000}}
sampler = VirtualGraphComposite(DWaveSampler(), embedding, flux_biases=False)

KeyError Traceback (most recent call last)
in ()
----> 1 sampler = VirtualGraphComposite(DWaveSampler(), embedding, flux_biases=False)

/usr/local/lib/python2.7/dist-packages/dwave/system/composites/virtual_graph.pyc in init(self, sampler, embedding, chain_strength, flux_biases, flux_bias_num_reads, flux_bias_max_age)
128 # Derive the structure of our composed from the target graph and the embedding
129 #
--> 130 source_adjacency = embutil.target_to_source(target_adjacency, embedding)
131 try:
132 nodelist = sorted(source_adjacency)

/usr/local/lib/python2.7/dist-packages/dwave_embedding_utilities.pyc in target_to_source(target_adjacency, embedding)
140 # v is node in target, n node in source
141 for v, n in iteritems(reverse_embedding):
--> 142 neighbors = target_adjacency[v]
143
144 # u is node in target

KeyError: 4000

Remove the dwave_networkx requirement

The dnx requirement creates a dependency loop. I think the logic that is being imported from dnx is sufficiently small and self-contained enough that it can be duplicated in dwave-system.
Thoughts @bellert ?

VirtualGraphComposite fails for 1:1 logical:physical qubit mapping

More information: this seems to happen only when flux_biases=True:

embedding = {'x': {1}, 'y': {5}, 'z': {0,4}}
sampler = VirtualGraphComposite(DWaveSampler(), embedding, chain_strength = 1.5, flux_biases=False)

The above works but the next one fails:

sampler = VirtualGraphComposite(DWaveSampler(), embedding, chain_strength = 1.5)---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
in ()
----> 1 sampler = VirtualGraphComposite(DWaveSampler(), embedding, chain_strength = 1.5)

/usr/local/lib/python2.7/dist-packages/dwave/system/composites/virtual_graph.pyc in init(self, sampler, embedding, chain_strength, flux_biases, flux_bias_num_reads, flux_bias_max_age)
147 # If nothing is provided, then we either get them from the cache or generate them
148 flux_biases = get_flux_biases(sampler, embedding, num_reads=flux_bias_num_reads,
--> 149 max_age=flux_bias_max_age)
150 elif flux_biases:
151 if FLUX_BIAS_KWARG not in sampler.accepted_kwargs:

/usr/local/lib/python2.7/dist-packages/dwave/system/flux_bias_offsets/flux_bias_offsets.pyc in get_flux_biases(sampler, embedding, num_reads, chain_strength, max_age)
20
21 fbo = dst.oneshot_flux_bias(sampler, embedding.values(),
---> 22 num_reads=num_reads, chain_strength=chain_strength)
23
24 # store them in the cache

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in oneshot_flux_bias(sampler, chains, flux_bias_list, num_reads, target_J, chain_strength, **sampler_kwargs)
57 submitted_sweeps = submit_flux_bias_sweeps(sampler, chains, flux_bias_list, num_reads, target_J,
58 chain_strength, **sampler_kwargs)
---> 59 return calculate_flux_biases(submitted_sweeps, chains)
60
61

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in calculate_flux_biases(submitted_sweeps, chains)
177
178 for averages, chain in zip(chain_averages, chains):
--> 179 averages[flux_bias_magnitude] = chain_average(chain, response)
180
181 submitted_sweeps = waiting

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in chain_average(chain, response)
224
225 if response.label_to_idx is not None:
--> 226 columns = [response.label_to_idx[v] for v in chain]
227 else:
228 columns = list(chain)

KeyError: 5

Another example:

Setting an embedding with a single qubit,

embeddingQ = {1: [0], 2: {1, 5}}
sampler = VirtualGraphComposite(DWaveSampler(), embeddingQ, chain_strength = 2, flux_bias_num_reads=2)


KeyError Traceback (most recent call last)
in ()
----> 1 sampler = VirtualGraphComposite(DWaveSampler(), embeddingQ, chain_strength = 2, flux_bias_num_reads=2)

/usr/local/lib/python2.7/dist-packages/dwave/system/composites/virtual_graph.pyc in init(self, sampler, embedding, chain_strength, flux_biases, flux_bias_num_reads, flux_bias_max_age)
147 # If nothing is provided, then we either get them from the cache or generate them
148 flux_biases = get_flux_biases(sampler, embedding, num_reads=flux_bias_num_reads,
--> 149 max_age=flux_bias_max_age)
150 elif flux_biases:
151 if FLUX_BIAS_KWARG not in sampler.accepted_kwargs:

/usr/local/lib/python2.7/dist-packages/dwave/system/flux_bias_offsets/flux_bias_offsets.pyc in get_flux_biases(sampler, embedding, num_reads, chain_strength, max_age)
20
21 fbo = dst.oneshot_flux_bias(sampler, embedding.values(),
---> 22 num_reads=num_reads, chain_strength=chain_strength)
23
24 # store them in the cache

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in oneshot_flux_bias(sampler, chains, flux_bias_list, num_reads, target_J, chain_strength, **sampler_kwargs)
57 submitted_sweeps = submit_flux_bias_sweeps(sampler, chains, flux_bias_list, num_reads, target_J,
58 chain_strength, **sampler_kwargs)
---> 59 return calculate_flux_biases(submitted_sweeps, chains)
60
61

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in calculate_flux_biases(submitted_sweeps, chains)
177
178 for averages, chain in zip(chain_averages, chains):
--> 179 averages[flux_bias_magnitude] = chain_average(chain, response)
180
181 submitted_sweeps = waiting

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in chain_average(chain, response)
224
225 if response.label_to_idx is not None:
--> 226 columns = [response.label_to_idx[v] for v in chain]
227 else:
228 columns = list(chain)

KeyError: 0

Here's another:

embedding = {'x': [1], 'y': [5], 'z': {0,4}}
sampler = VirtualGraphComposite(DWaveSampler(), embedding, chain_strength = 2, flux_bias_num_reads=2)

KeyError Traceback (most recent call last)
in ()
----> 1 sampler = VirtualGraphComposite(DWaveSampler(), embedding, chain_strength = 2, flux_bias_num_reads=2)

/usr/local/lib/python2.7/dist-packages/dwave/system/composites/virtual_graph.pyc in init(self, sampler, embedding, chain_strength, flux_biases, flux_bias_num_reads, flux_bias_max_age)
147 # If nothing is provided, then we either get them from the cache or generate them
148 flux_biases = get_flux_biases(sampler, embedding, num_reads=flux_bias_num_reads,
--> 149 max_age=flux_bias_max_age)
150 elif flux_biases:
151 if FLUX_BIAS_KWARG not in sampler.accepted_kwargs:

/usr/local/lib/python2.7/dist-packages/dwave/system/flux_bias_offsets/flux_bias_offsets.pyc in get_flux_biases(sampler, embedding, num_reads, chain_strength, max_age)
20
21 fbo = dst.oneshot_flux_bias(sampler, embedding.values(),
---> 22 num_reads=num_reads, chain_strength=chain_strength)
23
24 # store them in the cache

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in oneshot_flux_bias(sampler, chains, flux_bias_list, num_reads, target_J, chain_strength, **sampler_kwargs)
57 submitted_sweeps = submit_flux_bias_sweeps(sampler, chains, flux_bias_list, num_reads, target_J,
58 chain_strength, **sampler_kwargs)
---> 59 return calculate_flux_biases(submitted_sweeps, chains)
60
61

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in calculate_flux_biases(submitted_sweeps, chains)
177
178 for averages, chain in zip(chain_averages, chains):
--> 179 averages[flux_bias_magnitude] = chain_average(chain, response)
180
181 submitted_sweeps = waiting

/usr/local/lib/python2.7/dist-packages/dwave/system/tuning/flux_bias_offsets.pyc in chain_average(chain, response)
224
225 if response.label_to_idx is not None:
--> 226 columns = [response.label_to_idx[v] for v in chain]
227 else:
228 columns = list(chain)

KeyError: 5

VirtualGraph warning

In [14]: sampler = VirtualGraphComposite(DWaveSampler(), embedding) 
/home/gmarsden/.local/lib/python2.7/site-packages/dwave/system/flux_bias_offsets/flux_bias_offsets.py:20: UserWarning: Package dwave-system-tuning not found. Flux biases will not be used. warnings.warn("Package dwave-system-tuning not found. Flux biases will not be used.")

@gmarsden

sample() method should accept very large num_reads value (not limited by underlying HW solver)

Current Problem
Related to dwavesystems/dwavebinarycsp#57, the need to obtain an inordinately large number of samples meant that the straightforward problem statement, to request a large number of samples, had to be turned into a while() loop (lines 46-62 in attached code)
maxCut_csp.py.gz
because the EmbeddingComposite.sample() method is limited to 10,000 samples, which was not enough to find a valid sample. The higher-level sample() method should accept a large value (at least millions) and, if necessary, strip-mine that number to comply with lower-level sampler constraints.

Split EmbeddingComposite into FindEmbeddingComposite and ApplyEmbeddingComposite

A user may want to only use the part of the EmbeddingComposite layer that handles seamlessly embedding and unembedding, but not calculate a new embedding each time. They may already have an embedding or they may want to use another tool (other than minorminer) to calculate their embedding.

As well, this logic is duplicated in VirtualGraph. Having the embed --> sample --> unembed workflow in one place would make it easier to update in the future.

Incorporate autoscaling into VirtualGraphComposite

Current Problem
Scaling must be done manually for VirtualGraphComposite, but autoscaling is available for FixedEmbeddingComposite and EmbeddingComposite.

Proposed Solution
Add autoscale to VirtualGraphComposite in same manner as for the other composites.

Alternatives Considered
Provide a separate autoscale method

Additional context

Response is showing auxiliary variables and looks broken

Description
Using EmbeddingComposite I get back samples for what look like auxiliary variables

Steps To Reproduce

>>> from dwave.system.samplers import DWaveSampler
>>> from dwave.system.composites import EmbeddingComposite
>>> linear = {'x0': -1, 'x1': -1, 'x2': -1}
>>> quadratic = {('x0', 'x1'): 2, ('x0', 'x2'): 2, ('x1', 'x2'): 2}
>>> Q = dict(linear)
>>> Q.update(quadratic)
>>> response = EmbeddingComposite(DWaveSampler()).sample_qubo(Q, num_reads=1000)
>>>for sample, energy, num_occurrences in response.data():
   ...     print(sample, "Energy: ", energy, "Occurrences: ", num_occurrences)
{'x': 1, '0': 1, '1': 1, '2': 1, 'x0': 0, 'x1': 1, 'x2': 0} Energy:  -3.0 Occurrences:  113
{'x': 1, '0': 1, '1': 1, '2': 1, 'x0': 0, 'x1': 0, 'x2': 0} Energy:  -3.0 Occurrences:  177
{'x': 1, '0': 1, '1': 1, '2': 1, 'x0': 1, 'x1': 0, 'x2': 0} Energy:  -3.0 Occurrences:  482
{'x': 1, '0': 1, '1': 1, '2': 1, 'x0': 0, 'x1': 0, 'x2': 1} Energy:  -3.0 Occurrences:  228

Expected Behavior
No auxiliary variables

Environment

  • OS: both Ubuntu and Windows
  • Python version: 3.x

Additional Context
Also, the solution (the samples for the problem variables) looks wrong -- low energy for invalid solutions

Rescaling composite layer needed

A composite layer that rescales the Hamiltonian would add a lot of convenience. It would rescale the input Hamiltonian to fit within specified ranges, then reverse the rescaling so the energies match the original Hamiltonian.

I currently use the following function to rescale Hamiltonians, with an additional feature that allows clipping large values so that the Hamiltonian doesn't have to be scaled down as much (the tradeoff being that the Hamiltonian is not a faithful rescaling if clipping < 1).

def rescale(hh, jj, h_range, j_range, clipping=1.):
    """Rescale the Hamiltonian.

    Clipping truncates values at a certain fraction of the provided range to lessen the
    required compression.
    """

    # Unpack the bounds.
    min_h, max_h = map(float, h_range)
    min_j, max_j = map(float, j_range)

    # Find the natural rescaling factor
    scalars = [
        1.,
        max([h / min_h for h in hh]),
        max([h / max_h for h in hh]),
        max([j / min_j for j in jj.values()]),
        max([j / max_j for j in jj.values()]),
        ]

    scalar = max(scalars)
    # Adjust for clipping
    scalar *= clipping

    hh_scaled = [min_h if h/scalar <= min_h else max_h if h/scalar >= max_h else h/scalar for h in hh]
    jj_scaled = {k: min_j if v/scalar <= min_j else max_j if v/scalar >= max_j else v/scalar for k, v in jj.iteritems()}

    return hh_scaled, jj_scaled, scalar

Embeddings mixes Ising and QUBO methods

from dwave.system.composites import EmbeddingComposite
from dwave.system.samplers import DWaveSampler
sampler = EmbeddingComposite(DWaveSampler(profile='prod', solver='DW_2000Q_1'))
response = sampler.sample_ising({0: -1, 1: 1}, {})

image

response = sampler.sample_qubo({(0, 0): -1, (4, 4): -1, (0, 4): 2})

image

The problem happens when using any of the embedding methods (e.g., sampler = TilingComposite(DWaveSampler(...)

Add .travis.yml

Make sure dwave-system passes unittests on all OS and Python versions

Incorrect answers returned from EmbeddingComposite(DWaveSampler())

Using EmbeddingComposite(DWaveSampler()) for the following bqm does not return correct answers

'{"info": {}, "linear_terms": [{"bias": 9.0, "label": "carry02"}, {"bias": 3.0, "label": "carry03"}, {"bias": 3.0, "label": "carry01"}, {"bias": 7.0, "label": "and20"}, {"bias": 7.0, "label": "and21"}, {"bias": 5.0, "label": "and22"}, {"bias": -4.0, "label": "b0"}, {"bias": 0.0, "label": "b1"}, {"bias": 0.0, "label": "b2"}, {"bias": 5.0, "label": "and02"}, {"bias": 7.0, "label": "and01"}, {"bias": 2.0, "label": "sum12"}, {"bias": 0.0, "label": "sum11"}, {"bias": 5.0, "label": "carry11"}, {"bias": 3.0, "label": "carry12"}, {"bias": 0.0, "label": "a1"}, {"bias": -4.0, "label": "a0"}, {"bias": 0.0, "label": "a2"}, {"bias": 7.0, "label": "and11"}, {"bias": 7.0, "label": "and10"}, {"bias": 7.0, "label": "and12"}], "offset": -17.5, "quadratic_terms": [{"bias": 2.0, "label_head": "and10", "label_tail": "and01"}, {"bias": 2.0, "label_head": "carry03", "label_tail": "carry12"}, {"bias": 2.0, "label_head": "and21", "label_tail": "carry11"}, {"bias": 2.0, "label_head": "a0", "label_tail": "b2"}, {"bias": -4.0, "label_head": "b2", "label_tail": "and02"}, {"bias": -4.0, "label_head": "a0", "label_tail": "and01"}, {"bias": -4.0, "label_head": "and11", "label_tail": "carry11"}, {"bias": 2.0, "label_head": "and02", "label_tail": "carry01"}, {"bias": 2.0, "label_head": "a2", "label_tail": "b0"}, {"bias": -2.0, "label_head": "and21", "label_tail": "sum12"}, {"bias": -4.0, "label_head": "carry01", "label_tail": "carry02"}, {"bias": -4.0, "label_head": "and02", "label_tail": "carry02"}, {"bias": -4.0, "label_head": "a2", "label_tail": "and22"}, {"bias": -4.0, "label_head": "a0", "label_tail": "and02"}, {"bias": 4.0, "label_head": "carry11", "label_tail": "sum11"}, {"bias": 2.0, "label_head": "sum11", "label_tail": "and02"}, {"bias": -4.0, "label_head": "b0", "label_tail": "and10"}, {"bias": -4.0, "label_head": "a1", "label_tail": "and11"}, {"bias": -4.0, "label_head": "b1", "label_tail": "and11"}, {"bias": -4.0, "label_head": "and01", "label_tail": "carry01"}, {"bias": -4.0, "label_head": "sum12", "label_tail": "carry03"}, {"bias": -2.0, "label_head": "and12", "label_tail": "sum12"}, {"bias": 2.0, "label_head": "a0", "label_tail": "b1"}, {"bias": 4.0, "label_head": "carry12", "label_tail": "sum12"}, {"bias": 2.0, "label_head": "a1", "label_tail": "b0"}, {"bias": -4.0, "label_head": "b0", "label_tail": "and20"}, {"bias": 2.0, "label_head": "and20", "label_tail": "and11"}, {"bias": 2.0, "label_head": "and12", "label_tail": "carry11"}, {"bias": -4.0, "label_head": "b2", "label_tail": "and22"}, {"bias": 2.0, "label_head": "sum11", "label_tail": "carry01"}, {"bias": -4.0, "label_head": "a2", "label_tail": "and21"}, {"bias": 2.0, "label_head": "a2", "label_tail": "b2"}, {"bias": 2.0, "label_head": "a1", "label_tail": "b1"}, {"bias": 2.0, "label_head": "sum12", "label_tail": "carry02"},{"bias": -4.0, "label_head": "b2", "label_tail": "and12"}, {"bias": -4.0, "label_head": "carry02", "label_tail": "carry03"}, {"bias": -4.0, "label_head": "b1", "label_tail": "and01"}, {"bias": 2.0, "label_head": "a0", "label_tail": "b0"}, {"bias": -4.0, "label_head": "a1", "label_tail": "and10"}, {"bias": -4.0, "label_head": "and20", "label_tail": "carry11"}, {"bias": -2.0, "label_head": "and20", "label_tail": "sum11"}, {"bias": -4.0, "label_head": "a2", "label_tail": "and20"}, {"bias": 2.0, "label_head": "and22", "label_tail": "carry12"}, {"bias": 2.0, "label_head": "and21", "label_tail": "and12"}, {"bias": -4.0, "label_head": "a1", "label_tail": "and12"}, {"bias": 2.0, "label_head": "a1", "label_tail": "b2"}, {"bias": 2.0, "label_head": "a2", "label_tail": "b1"}, {"bias": -2.0, "label_head": "and11", "label_tail": "sum11"}, {"bias": -4.0, "label_head": "carry11", "label_tail": "carry12"}, {"bias": -4.0, "label_head": "b1", "label_tail": "and21"}, {"bias": -4.0, "label_head": "and21", "label_tail": "carry12"}, {"bias": -4.0, "label_head": "sum11", "label_tail": "carry02"}, {"bias": -2.0, "label_head": "carry11", "label_tail": "sum12"}, {"bias": 2.0, "label_head": "and22", "label_tail": "carry03"}, {"bias": -4.0, "label_head": "and10", "label_tail": "carry01"}, {"bias": -4.0, "label_head": "and12", "label_tail": "carry12"}], "variable_labels": ["carry02", "carry03", "carry01", "and20", "and21", "and22", "b0", "b1", "b2", "and02", "and01", "sum12", "sum11", "carry11", "carry12", "a1", "a0", "a2", "and11", "and10", "and12"], "variable_type": "BINARY", "version": {"bqm_schema": "1.0.0", "dimod": "0.6.8"}}'

EmbeddingComposite fails to embed for disconnected bqm

Q = {(0, 0): 2230, (1, 1): 1631, (2, 2): 1566, (3, 3): 1346, (4, 4): 1352, (5, 5): 1204, (6, 6): 845, (7, 7): 707, (8, 8): 1001, (9, 9): 947, (10, 10): 1484, (11, 11): 627, (12, 12): 773, (13, 13): 424, (14, 14): 644, (15, 15): 302, (16, 16): 341, (17, 17): 1027, (18, 18): 368, (19, 19): 916, (20, 20): 702, (0, 1): 2, (0, 2): 2, (0, 3): 2, (0, 4): 2, (0, 5): 2, (1, 2): 2, (1, 3): 2, (1, 4): 2, (1, 5): 2, (2, 3): 2, (2, 4): 2, (2, 5): 2, (3, 4): 2, (3, 5): 2, (4, 5): 2, (6, 7): 2, (6, 8): 2, (6, 9): 2, (6, 10): 2, (7, 8): 2, (7, 9): 2, (7, 10): 2, (8, 9): 2, (8, 10): 2, (9, 10): 2, (11, 12): 2, (11, 13): 2, (11, 14): 2, (12, 13): 2, (12, 14): 2, (13, 14): 2, (15, 16): 2, (15, 17): 2, (16, 17): 2, (18, 19): 2}

bqm = BinaryQuadraticModel.from_qubo(Q)

# onto the QPU
sampler = EmbeddingComposite(DWaveSampler())

Fails because 20 is disconnected.

DWaveSampler does not correctly set Response.vartype

h = [0,0,0,0,0]
J = {(0,4): 1}
bqm = BinaryQuadraticModel.from_ising(h, J)
print bqm
 
# onto the QPU
sampler = DWaveSampler()
response = sampler.sample(bqm,num_reads=2000)
samples_matrix = response.samples_matrix
for i in samples_matrix:
    print i

why does the solution come out in 0’s and 1’s, instead of Ising?

Documentation comments

Courtesy of @fionahanington

REFERENCE DOCUMENTATION

Included Samplers

Say what a sampler is.

Included Composites

Say what a composite is.

D-Wave Sampler

Overview

'dimod' is not defined anywhere. Suggest you add it to the Glossary.

a D-Wave Micro Client > the D-Wave Micro Client

Id > ID

Note inconsistent casing of "URL" here (here, make both uppercase. Lowercase OK when parm):

URL of the SAPI server. None will return the default url (see configuration). > URL of the SAPI server. None will return the default URL (see configuration). [and see suggestion below, which affects the second sentence]

Change all "None will return..." to "If unspecified, returns..."

Sampler Properties

sapi > SAPI (more than 1 instance)

Structure Properties

Can you give an example of an adjacency structure?

Methods

bqm is undefined. What is this? In the definition, case as BQM. Add to Glossary.

Embedding Composite

============================

Overview

Can you explain what unstructured samplers are vs. structured?

Sampler Properties

Contains one key �child_properties� which has a copy of the child sampler�s properties. > Contains one key, child_properties, which has a copy of the child sampler�s properties. [format so redenders as literal - compare with how you've formatted "children" under Composite Properties]

Methods

Same point about BQM (this is probably shared content, right?)

TimingComposite

Overview

Typo: accross

chimera > Chimera

D-WAVE > D-Wave

sub Chimera > sub-Chimera (more than one instance)

shore ? What is this? I've not heard this term before. Add to glossary

Sampler Properties

Same point about wording/formatting of the child_properties definition (this is probably shared content, right?)

Methods

sub Chimera > sub-Chimera
Do you need to include the sample_Ising methods that other samplers have?
Same comments made elsewhere re methods apply here too (assuming shared content)

VirtualGraphComposite

Overview

Should briefly give context - what is virtual graph and why would you want to use it.

Something like:

The D-Wave virtual graph tools simplify the process of minor-embedding by enabling you to more easily create, optimize, use, and reuse an embedding for a given working graph. When you submit an embedding and specify a chain strength using these tools, they automatically calibrate the qubits in a chain to compensate for the effects of biases that may be introduced as a result of strong couplings.

Also, it's not clear how you will reuse an existing embedding. How is this done?

Parameters:

Problem with the link here (dimod_):

sampler (DWaveSampler) � A dimod_ sampler.

typo in flux_biases description: the the

In this sentence, I think "samplers" should be "samples." Also, hyphenate flux-bias value: The number of samplers to collect per flux bias value

Sampler Properties

Same point re formatting of key names and param names.

Methods

same points as above

Installation

Note casing of PyPI (see https://pypi.python.org/pypi)

PyPi > PyPI

Suggest change wording re license:

Please note that this package depends on a package dwave-system-tuning which has a proprietary license. To view the license details: >

Downloaded with this package is a dependency called dwave-system-tuning that has a restricted license. To view the license details:

Ocean Overview

Bad link: D-Wave Ocean. Looks like goes to "todo" page? remove the link for now.

Contributing to Ocean

  • I get a 404 when clicking the "Ocean Contributors" link

Glossary

Awkward sentence (verb form reads awkwardly even if grammatically correct). Suggest simplify to:

The field of quantum computing has many domain-specific terms.

Main Glossary page

I know this is very much a work in progress, so these suggestions are just the minimum to cover the supported tools and features mentioned in this release:

'dimod'
'Ocean tools'
'BQM' ?
'shore' ?
'virtual graph tools' -- Tools that simplify the process of minor-embedding.
'flux biases' -- Offset values with which to calibrate a chain.

Also the glossary should have an entry for "sampler", saying that it's equivalent to a solver, since both terms are used more or less interchangably

VirtualGraphComposite: non-standard format for apply_flux_bias_offsets

Someone might expect "u'apply_flux_bias_offsets': []," (uniform format throughout the list). Nice to have.

sampler.parameters # doctest: +SKIP
{u'anneal_offsets': ['parameters'],
u'anneal_schedule': ['parameters'],
u'annealing_time': ['parameters'],
u'answer_mode': ['parameters'],
'apply_flux_bias_offsets': [],
u'auto_scale': ['parameters'],

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.