Configuring Access to Leap’s Solvers

D-Wave’s Solver API (SAPI) provides access to the solvers—compute resources for solving problems, such as a D-Wave quantum computers and quantum-classical hybrid solvers—hosted in the Leap quantum cloud.1

1

SAPI is used similarly for on-premises systems. Differences for such systems are noted below.

This page provides the following information:

Interacting with SAPI

SAPI is an application layer that provides resource discovery, permissions, and scheduling for D-Wave solvers. Problem submission through SAPI requires the following information, typically provided by your work environment from either Ocean’s default values or your configuration.

  • API Token (required2)

    An authentication token used to authenticate the client session when you connect to the remote environment.

    2

    D-Wave’s Leap integrated development environment (IDE) automatically reads your API token from your account. You can use the configuration options of the Using your API Token table to substitute an alternative token, for example, if you belong to multiple projects.

  • Solver (default: feature-based selection)

    A D-Wave resource to be used to solve your submitted problems; for example, a quantum-classical hybrid solver or an Advantage quantum computer.

  • Region/Endpoint (default: North American URL)

    A URL for a region’s remote resources.

    By default, Ocean connects to North American (region na-west-1) Leap quantum cloud resources at URL https://na-west-1.cloud.dwavesys.com/sapi/v2/.

    For information about using solvers in alternative geographical regions, see the Accessing Solvers in Multiple Regions section below.

Create a Configuration File

The simplest way to configure solver access is to use the interactive CLI, which is installed as part of the dwave-ocean-sdk installation.

If you did not already do so with the dwave setup command in the Set Up Your Environment section, or want to make changes at a later time, you can use the dwave config command.

$ dwave config --help
Usage: dwave config [OPTIONS] COMMAND [ARGS]...

Create, update or inspect cloud client configuration file(s).

Options:
  --help  Show this message and exit.

Commands:
  create   Create and/or update cloud client configuration file.
  inspect  Inspect existing configuration/profile.
  ls       List configuration files detected (and/or examined paths).

Creating a configuration file using the dwave config is done as follows (the dwave setup command of the Set Up Your Environment section runs these same configuration steps):

  1. 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).

$ dwave config create
Using the simplified configuration flow.
Try 'dwave config create --full' for more options.

Creating new configuration file: /home/jane/.config/dwave/dwave.conf
Profile [defaults]: ↵
Updating existing profile: defaults
Authentication token [skip]: ABC-1234567890abcdef1234567890abcdef ↵
Configuration saved.
  1. Enter the SAPI information (e.g. your API token) found as described in the Interacting with SAPI section above. To get started, create a minimum configuration by accepting the command’s defaults (pressing Enter) for all prompts except the API token3. You can in the future update the file if needed.

3

Users of on-premises systems should also enter the SAPI endpoint. Users interested in using solvers hosted outside their default region can also configure the SAPI endpoint (see the Accessing Solvers in Multiple Regions section for the recommended way of configuring such access).

Alternatively, you can create and edit a D-Wave Cloud Client configuration file manually.

You can always set or override your configurations in your code or with environment variables. For more information, see the examples in this document or D-Wave Cloud Client.

Verify Your Configuration

You can test that your solver access is configured correctly with the interactive CLI.

  1. In your virtual environment, run the dwave ping command (the output shown below is illustrative only).

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
  1. Optionally, run the dwave sample --random-problem command to submit a random problem to a remote solver (the output shown below is illustrative only).

$ dwave sample --random-problem
Using endpoint: https://my.dwavesys.url/
Using solver: My_DWAVE_2000Q
Using qubit biases: {0: -1.0345257941434953, 1: -0.5795618633919246, 2: 0.9721956399428491, 3: 1....
Using qubit couplings: {(1634, 1638): 0.721736584181423, (587, 590): 0.9611623181258304, (642, 64...
Number of samples: 1
Samples: [[1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1,...
Occurrences: [1]
Energies: [-2882.197791239335]

Accessing Solvers in Multiple Regions

Leap quantum cloud service is distributed across multiple geographic regions. You can see the supported regions and the solvers available in each for your account in your Leap dashboard. Ocean’s dwave-cloud-client enables you to select solvers from a particular region using one or more of the following options:

  • Select a default region in your dwave-cloud-client configuration file. You can run the dwave config CLI command with the --full option or edit an existing configuration file to set a preferred region.

  • Set the appropriate environment variable (for example, export DWAVE_API_REGION=eu-central-1 in a Unix shell) for your current terminal or working session to select solvers from a preferred region.

  • Explicitly select the region in your code. For example, the region parameter in the code line sampler = DWaveSampler(region="na-west-1") selects a D-Wave quantum computer located in North America.

Note

Keep in mind the relative priorities of configurations set at various levels (in the above bullets, the configuration file, environment variables, and explicit parameters in your code), as described in the dwave-cloud-client documentation. For example, while the setting of both an endpoint and region on the same level (either two lines in the configuration file or two environment variables or two explicit parameters) results in selection based on the endpoint, setting a region explicitly overrides an endpoint configured using an environment variable or in the configuration file.

Example: Viewing a Region’s Solvers

You can use interactive CLI to query solvers in a particular region.

$ dwave solvers --list --region eu-central-1
Advantage_system5.1

Example: Using Configuration-File Profiles for Multiple Regions

You can set up your configuration file with profiles for multiple regions, as shown below.

[defaults]
token = ABC-123456789123456789123456789

[europe]
region = eu-central-1

You can then set the profile when instantiating a sampler, as below.

>>> from dwave.system import DWaveSampler, EmbeddingComposite
>>> sampler = EmbeddingComposite(DWaveSampler(profile="europe"))