CLI#
As part of the installation of the dwave-ocean-sdk a dwave executable is installed; for example, in a virtual environment it might be installed as <virtual_environment>\Scripts\dwave.exe. Running this file from your system’s console opens an interactive command line interface (CLI) that can help you set up and configure your development environment, communicate with D-Wave compute resources, interact with your Leap account, and other useful actions.
Run dwave --help
for information on all the CLI options.[1] For
SDK version 6.7.0 the CLI provided the following commands and options
(see the output in your installation for the latest):
$ dwave
Usage: dwave [OPTIONS] COMMAND [ARGS]...
D-Wave Cloud Client interactive configuration tool.
Options:
--version Show the version and exit.
--debug Enable debug logging.
--trace Enable trace-level debug logging.
--log LEVEL Set custom numeric or symbolic log level.
--platform Show the platform tags and exit.
--help Show this message and exit.
Commands:
auth Authorize Leap access and fetch Leap/Solver API tokens.
config Create, update or inspect cloud client configuration file(s).
install Install optional non-open-source Ocean packages.
leap Interact with Leap API.
ping Ping the QPU by submitting a single-qubit problem.
sample Submit Ising-formulated problem and return samples.
setup Setup optional Ocean packages and configuration file(s).
solvers Get solver details.
upload Multipart problem upload with cold restart support.
Note
If you work in a Bash shell and want command completion for dwave, add
eval "$(_DWAVE_COMPLETE=source <path>/dwave)"
to your shell’s .bashrc configuration file, where <path> is the absolute path to the installed dwave executable, for example /home/Mary/my-quantum-app/env/bin.
Below are shown example sessions for some of the commands:
Leap#
The dwave auth
and dwave leap
commands enable Ocean to access
and interact with your Leap account.
For example, in your developer environment (e.g., a Python virtual environment or a GitHub Codespaces codespace), you can authorize Ocean’s access to your Leap account, using the secure OAuth 2.0 code exchange, by running one of the following Ocean CLI commands from your terminal.
In an environment such as an IDE installed on your system, where you can access localhost addresses from your browser, initiate the OAuth redirect flow:
dwave auth login
In an environment such as a cloud IDE, where access to localhost addresses from your browser might be blocked, you can initiate the alternative OAuth out-of-band flow:
dwave auth login --oob
With Ocean now authorized to access your Leap account, you can create a dwave-cloud-client configuration file to manage your Solver API (SAPI) access with the SAPI token retrieved from your account as shown in the Configure command.
Setup#
The dwave setup
command optionally installs non-open-source packages
and configures your environment.
The output shown below includes the interactive prompts and placeholder replies
for a full setup. The --auth
authorizes Ocean to
access your Leap account to fetch your SPI token.
$ dwave setup --auth
Optionally install non-open-source packages and configure your environment.
Do you want to select non-open-source packages to install (y/n)? [y]: ↵
D-Wave Drivers
These drivers enable some automated performance-tuning features.
This package is available under the 'D-Wave EULA' license.
The terms of the license are available online: https://docs.ocean.dwavesys.com/eula
Install (y/n)? [y]: ↵
Installing: D-Wave Drivers
Successfully installed D-Wave Drivers.
D-Wave Problem Inspector
This tool visualizes problems submitted to the quantum computer and the results returned.
This package is available under the 'D-Wave EULA' license.
The terms of the license are available online: https://docs.ocean.dwavesys.com/eula
Install (y/n)? [y]: ↵
Installing: D-Wave Problem Inspector
Successfully installed D-Wave Problem Inspector.
Authorizing Leap access.
Creating the D-Wave configuration file.
Using the simplified configuration flow.
Try 'dwave config create --full' for more options.
Creating new configuration file: /home/jane/.config/dwave/dwave.conf
Updating existing profile: defaults
Fetched SAPI token for project 'My-Proj' (ABC) from Leap API.
Configuration saved.
Configure#
The dwave config
command configures your environment.
The output shown below is for a development environment where the user has first enabled Ocean’s Leap access.
$ dwave config create --auto-token
Using the simplified configuration flow.
Try 'dwave config create --full' for more options.
Creating new configuration file: /home/jane/.config/dwave/dwave.conf
Updating existing profile: defaults
Access token expired (or expires soon), refreshing it.
Fetched SAPI token for project 'ABC' (ABC) from Leap API.
Configuration saved.
Ping#
The dwave ping
command tests communications with the quantum computer
configured using the dwave setup
or dwave config
commands.
The example below, for a Bash Unix shell, pings only QPU solvers.
$ dwave ping --client qpu
Using endpoint: https://cloud.dwavesys.com/sapi
Using solver: DW_2000Q_6
Submitted problem ID: 34f773f7-77dc-7fa5-a7d5-7e397d90fc4a
Wall clock time:
* Solver definition fetch: 1888.499 ms
* Problem submit and results fetch: 1038.042 ms
* Total: 2926.541 ms
QPU timing:
* post_processing_overhead_time = 307.0 us
* qpu_access_overhead_time = 1185.96 us
* qpu_access_time = 10995.04 us
* qpu_anneal_time_per_sample = 20.0 us
* qpu_delay_time_per_sample = 20.54 us
* qpu_programming_time = 10756.1 us
* qpu_readout_time_per_sample = 198.4 us
* qpu_sampling_time = 238.94 us
* total_post_processing_time = 307.0 us
Solvers#
The dwave solvers
command queries which D-Wave compute resources are
currently available to your account.
$ dwave solvers --list --all
DW_2000Q_6
hybrid_binary_quadratic_model_version2
hybrid_discrete_quadratic_model_version1
Advantage_system4.1
The example below lists which D-Wave compute resources are currently available to your account in a particular region (Europe).
$ dwave solvers --region eu-central-1 --list --all
Advantage_system5.1