Skip to main content

D-Wave Problem Inspector tool

Project description

Linux/Mac build status

D-Wave Inspector

A tool for visualizing problems submitted to, and answers received from, a D-Wave structured solver such as a D-Wave 2000Q quantum computer.

Overview

dwave-inspector provides a graphic interface for examining D-Wave quantum computers’ problems and answers. As described in the Ocean documentation’s Getting Started, the D-Wave system solves problems formulated as binary quadratic models (BQM) that are mapped to its qubits in a process called minor-embedding. Because the way you choose to minor-embed a problem (the mapping and related parameters) affects solution quality, it can be helpful to see it.

For example, embedding a K3 fully-connected graph, such as the Boolean AND gate example into a D-Wave 2000Q, with its Chimera topology, requires representing one of the three variables with a “chain” of two physical qubits:

docs/_images/and_gate.png

The AND gate’s original BQM is represented on the left; its embedded representation, on the right, shows a two-qubit chain of qubits 1195 and 1199 for one variable.

The problem inspector shows you your chains at a glance: you see lengths, any breakages, and physical layout.

Installation or Building

Install the closed-source dependencies:

pip install dwave-inspectorapp --extra-index=https://pypi.dwavesys.com/simple

Then, install from package on D-Wave’s PyPI:

pip install dwave-inspector --extra-index=https://pypi.dwavesys.com/simple

or from source:

pip install git+ssh://git@github.com/dwavesystems/dwave-inspector.git

Alternatively, clone and build from source:

git clone https://github.com/dwavesystems/dwave-inspector.git
cd dwave-inspector
pip install -r requirements.txt
python setup.py install

Usage and Examples

Import the problem inspector to enable it[1] to hook into your problem submissions.

Use the show() method to visualize the embedded problem, and optionally the logical problem, in your default browser.

Inspecting an Embedded Problem

This example shows the canonical usage: samples representing physical qubits on a quantum processing unit (QPU).

>>> from dwave.system import DWaveSampler
>>> import dwave.inspector
...
>>> # Get solver
>>> sampler = DWaveSampler(solver = {'qpu': True})
...
>>> # Define a problem (actual qubits depend on the selected QPU's working graph)
>>> h = {}
>>> all (edge in sampler.edgelist for edge in {(0, 4), (0, 5), (1, 4), (1, 5)})
True
>>> J = {(0, 4): 1, (0, 5): 1, (1, 4): 1, (1, 5): -1}
...
>>> # Sample
>>> response = sampler.sample_ising(h, J, num_reads=100)
...
>>> # Inspect
>>> dwave.inspector.show(response)
docs/_images/physical_qubits.png

Edge values between qubits 0, 1, 4, 5, and the selected solution, are shown by color on the left; a histogram, on the right, shows the energies of returned samples.

Inspecting a Logical Problem

This example visualizes a problem specified logically and then automatically minor-embedded by Ocean’s EmbeddingComposite. For illustrative purposes it sets a weak chain_strength to show broken chains.

import dimod
import dwave.inspector
from dwave.system import DWaveSampler, EmbeddingComposite

# Define problem
bqm = dimod.BQM.from_ising({}, {'ab': 1, 'bc': 1, 'ca': 1})

# Get sampler
sampler = EmbeddingComposite(DWaveSampler(solver=dict(qpu=True)))

# Sample with low chain strength
sampleset = sampler.sample(bqm, num_reads=1000, chain_strength=0.1)

# Inspect
dwave.inspector.show(sampleset)
docs/_images/logical_problem.png

The logical problem, on the left, shows that the value for variable b is based on a broken chain; the embedded problem, on the right, highlights the broken chain (its two qubits have different values) in bold red.

show() Method

The show() method requires the SampleSet returned from the quantum computer or the SAPI problem ID[2]; other problem inputs—the binary quadratic model in BQM, Ising, or QUBO formats, and an emebedding—are optional. However, to visualize a logical problem if dimod’s EmbeddingComposite or derived classes are not used, you must supply the embedding.

Below are some options for providing problem data to the show() method, where response was returned for a problem defined directly on physical qubits and sampleset returned from a problem submitted using EmbeddingComposite:

show(response)
show('69ace80c-d3b1-448a-a028-b51b94f4a49d')   # Using a SAPI problem ID
show((h, J), response)
show(Q, response)
show((h, J), response, dict(embedding=embedding, chain_strength=5))

show(sampleset)
show(bqm, sampleset)

The show() method supports flow control for scripts with the block parameter. For example, the default setting of once (dwave.inspector.Block.ONCE) blocks until your problem is loaded from the inspector web server and forever blocks until you terminate with a CNTL-C/SIGTERM.

License

Released under the Apache License 2.0. See LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dwave-inspector-0.1.3.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dwave_inspector-0.1.3-py2.py3-none-any.whl (25.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file dwave-inspector-0.1.3.tar.gz.

File metadata

  • Download URL: dwave-inspector-0.1.3.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for dwave-inspector-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8c57bd3e047a2eb9223e3be8ad2b876a5166fe68853100ceadd471fdd80a4678
MD5 3c860c8d980882dad233aab22e1efaa4
BLAKE2b-256 075f6ddd1409b2e26af4d1cd4959e29b92d9dc7a701e816dcdf35e03cc41ac5a

See more details on using hashes here.

File details

Details for the file dwave_inspector-0.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: dwave_inspector-0.1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for dwave_inspector-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0ad95d670d0a24aeb10266e0267d65a9a9a5902b1568778245cf33565ae6f56a
MD5 0e2e06a00abe99d97874fd639fd6c9f9
BLAKE2b-256 ee7d0097e3253965165867ec7e74e4849364237afad73a638ed0f843e5f7faec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page