I recently got access to the D‑Wave Leap™ Quantum Application Environment (QAE). Leap is the first cloud-based QAE providing real-time access to a live quantum computer. The QAE features 2038 qubits and has a typical operating qubit temperature of 14.5±1 mK. D-Wave allows developers to develop software that will run on the D-Wave system using their D-Wave Ocean SDK for Python. D-Wave recommends that we work in a virtual environment when developing software to run on the QAE.
Before we can start coding and submitting our jobs to D-Wave’s systems, we need to install and configure D-Wave’s Ocean tools. Ocean tools allow us to run our jobs on a D-Wave system (Quantum Processing Unit) or locally (Central Processing Unit/Graphical Processing Unit).
The following operating systems support Ocean software:
- Windows (tested on 64-bit Windows 8, 10)
- Mac (tested on macOS 10.13)
Ocean software requires a Python environment. Supported Python versions are:
- 3.5 and higher
For reference: I’m using a MacBook Pro running macOS 10.14 and Python 3.6.5.
Installing the Ocean SDK
To install and use Ocean, ensure you have the virtualenv tool for creating isolated Python environments on your local machine. For Unix-based systems, installing virtualenv is typically done with the following command:
Create a virtual environment for your Ocean work. On Unix systems you might do:
On Windows operating system, activating a virtual environment might be done with the
Scripts\activate command instead. Your machine is now ready to install Ocean software.
The simplest way to start is to install
dwave-ocean-sdk for the full suite of Ocean tools. We can use pip to install the SDK inside our newly created virtual environment.
Alternatively, you can clone the
dwave-ocean-sdk repo and install the SDK to your virtual environment.
Ocean requires that you configure a solver on your system, which might be a D-Wave system or a classical sampler that runs on your local CPU. We’ll configure our system to solve problems on a D-Wave system instead of our local CPU/GPU.
Using a D-Wave System
To use a D-Wave system as our solver (the compute resource for solving problems), we access it through the D-Wave Solver API (SAPI). SAPI is an application layer built to provide resource discovery, permissions, and scheduling for quantum annealing resources at D-Wave. The requisite information for problem submission through SAPI includes:
- API endpoint URL - A URL to the remote D-Wave system.
- API Token - An authentication token the D-Wave system uses to authenticate the client session.
- Solver - Name of the D-Wave resource to be used to solve your submitted problems.
You can find all the above information when you log in to your D-Wave account.
You save your SAPI configuration (URL, API token, etc) in a D-Wave Cloud Client configuration file that Ocean tools use unless overridden explicitly or with environment variables. Your configuration file can include one or more solvers.
Configuring a D-Wave System as a Solver
To configure a D-Wave system as our solver, we use the
dwave-cloud-client interactive CLI, which is installed as part of the
dwave-ocean-sdk (or D-Wave Cloud Client tool installation).
In the virtual environment you created as part of Installing Ocean Tools, run the
dwave config create command (the output shown below includes the interactive prompts and placeholder replies).
Enter the SAPI information (API URL and token) found when you log in to your D-Wave account. You can accept the command’s defaults and in the future update the file if needed. Alternatively, you can create and edit a D-Wave Cloud Client configuration file manually or set the solver, API token, and URL directly in your code or as local environment variables. For more information, see the examples in this document or D-Wave Cloud Client.
Verifying Your Solver Configuration
You can test that your solver is configured correctly and that you have access to a D-Wave solver with the same
dwave-cloud-client interactive CLI installed as part of the SDK or D-Wave Cloud Client tool installation.
In your virtual environment, run the
dwave ping command.
The output of the command should look similar to that of the image below.
We can run the
dwave sample --random-problem command to submit a random problem to our configured solver. The output of the command should look similar to the one shown below.
To list the available solvers, their parameters, and properties, we run the dwave solvers command. The output of the command should look similar to the one shown below.
Congratulations! You’ve learned to use a quantum computer (sort of)!