Access D-Wave system from IBM Qiskit via MinimumEigensolver interface.

# D-Wave Ocean plugin for IBM Qiskit

Enables Qiskit users to obtain ground state(s) of Ising Hamiltonians using D-Wave's QPU available via Leap.

The package provides an implementation of Qiskit's MinimumEigensolver interface (available as DWaveMinimumEigensolver) which can be used directly on qubit operators, or via qikist.optimization's MinimumEigenOptimizer.

## Examples

Solve a QuadraticProgram with MinimumEigenOptimizer (see Qiskit's tutorial) using DWaveMinimumEigensolver:

>>> from qiskit.optimization import QuadraticProgram
>>> from qiskit.optimization.algorithms import MinimumEigenOptimizer
>>> from dwave.plugins.qiskit import DWaveMinimumEigensolver
...
>>> # Construct a simple quadratic program
>>> qp.binary_var('x')
>>> qp.binary_var('y')
...
>>> # Solve using Qiskit's MinimumEigenOptimizer on D-Wave QPU as a minimum eigen solver
>>> dwave_mes = DWaveMinimumEigensolver()
>>> optimizer = MinimumEigenOptimizer(dwave_mes)
>>> result = optimizer.solve(qp)
...
>>> print(result)
optimal function value: 0.0
optimal value: [0. 1.]
status: SUCCESS
>>> result.samples
[('01', 0.0, 0.39), ('00', 0.0, 0.25), ('10', 0.0, 0.36)]


Solve a 6-city TSP (or some other Ising model).

>>> from qiskit.optimization.applications.ising import tsp
>>> from qiskit.optimization.applications.ising.common import sample_most_likely
>>> from dwave.plugins.qiskit import DWaveMinimumEigensolver
...
>>> six_cities_tsp = tsp.random_tsp(6, seed=123)
>>> operator, offset = tsp.get_operator(six_cities_tsp)
...
>>> print(operator.print_details())
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIZ	(-400141.5+0j)
IIIIIIIIIIIIIIIIIIIIIIIIIIIIZIIIIIII	(-400152.5+0j)
IIIIIIIIIIIIIIIIIIIIIIIIIIIIZIIIIIIZ	(12+0j)
# snipped for brevity
>>> print(operator.num_qubits)
36
...
>>> result = dwave_mes.compute_minimum_eigenvalue(operator)
...
>>> x = sample_most_likely(result.eigenstate)
>>> tsp.tsp_feasible(x)
True
>>> tsp.get_tsp_solution(x)
[2, 3, 5, 1, 4, 0]


For comparison, trying this on NumPyMinimumEigensolver produces:

>>> from qiskit.aqua.algorithms import NumPyMinimumEigensolver
>>> result = NumPyMinimumEigensolver().compute_minimum_eigenvalue(operator)
# snipped for brevity
MemoryError: Unable to allocate 512. GiB for an array with shape (68719476737,) and data type uint64


and trying with QAOA backed with "qasm_simulator" produces:

>>> from qiskit import BasicAer
>>> from qiskit.aqua import QuantumInstance
>>> from qiskit.aqua.algorithms import QAOA

>>> quantum_instance = QuantumInstance(BasicAer.get_backend('qasm_simulator'))
>>> qaoa_mes = QAOA(quantum_instance=quantum_instance, initial_point=[0., 0.])
>>> result = qaoa_mes.compute_minimum_eigenvalue(operator)
# snipped for brevity
BasicAerError: 'Number of qubits 36 is greater than maximum (24) for "qasm_simulator".'


## Installation

Compatible with Python 3.6+, Qiskit 0.23.0+, and Ocean 3.1.0+.

pip install dwave-qiskit-plugin


To install from source:

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


Test requirements are in tests/requirements.txt.

## Project details

Uploaded source
Uploaded py3