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.


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:


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=

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

pip install dwave-inspector --extra-index=

or from source:

pip install git+ssh://

Alternatively, clone and build from source:

git clone
cd dwave-inspector
pip install -r requirements.txt
python install

Usage and Examples

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

[1]Importing the problem inspector activates for the session the capture of data such as problems sent to the QPU and returned responses, relevant details of minor-embedding, and warnings. The recommended workflow is to import it at the start of your coding session as is typical for Python packages (it is also possible, but less convenient, to specify in the submission that data such as embedding be returned with the response).

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)})
>>> J = {(0, 4): 1, (0, 5): 1, (1, 4): 1, (1, 5): -1}
>>> # Sample
>>> response = sampler.sample_ising(h, J, num_reads=100)
>>> # Inspect

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

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.

[2]For problems submitted in the active session (i.e., once the problem inspector has been imported).

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('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(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.


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.

Files for dwave-inspector, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size dwave_inspector-0.1.3-py2.py3-none-any.whl (25.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size dwave-inspector-0.1.3.tar.gz (20.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page