D-Wave Problem Inspector tool
Project description
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:
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)
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)
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.
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(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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dwave_inspector-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ad95d670d0a24aeb10266e0267d65a9a9a5902b1568778245cf33565ae6f56a |
|
MD5 | 0e2e06a00abe99d97874fd639fd6c9f9 |
|
BLAKE2b-256 | ee7d0097e3253965165867ec7e74e4849364237afad73a638ed0f843e5f7faec |