In the latest version of the Ocean™ SDK, Ocean 3.0, the DWaveSampler and DWaveCliqueSampler handle selecting a solver differently than they have in previous versions. Depending on how your local system is set up and on how you instantiate the samplers you will see a range of behavior. The following sections explain how to get these Ocean samplers to select a QPU solver based on certain criteria.
1. The solver with the highest number of qubits
If you have a fresh install of the Ocean SDK and have not added any default configurations to your local dwave.conf file or environment variables, these samplers will look for the QPU solver that has the highest number of qubits when they are instantiated without parameters. This is overridden whenever defaults are available on your system or when a solver is specified in the constructor.
The examples below use the default constructors without parameters:
#Examples of using the default constructors
sampler = DWaveSampler()
clique_sampler = DWaveCliqueSampler()
The following examples are not guaranteed to select a solver with the highest number of qubits.
#Examples of specifying a solver programmatically
sampler_2000Q = DWaveSampler(solver='DW_2000Q_6')
sampler_lowest_load = DWaveSampler(solver={'qpu': True})
2. The default solver in your config file or environment variables
If you have a default QPU solver specified in your configuration file or environment variables it will be selected when you instantiate DWaveSampler or DWaveCliqueSampler with empty constructors. For example, if the first entry in your configuration file is
[advantage]
endpoint = https://cloud.dwavesys.com/sapi/
token = *******************
solver=Advantage_solver1.1
The Advantage_solver1.1 will be selected when you call DWaveSampler() or DWaveCliqueSampler().
Removing the 'solver=' line in your configuration file will allow the Ocean SDK to select the solver for you (based on option 1 above) when you do not specify it programmatically.
3. The solver with the least average load
When the DWaveSampler or DWaveCliqueSampler is instantiated with the instruction to select any QPU solver, it will choose the solver that has the least average load. If both D-Wave 2000Q™ and Advantage™ solvers are online, the solver with the least amount of traffic, or queued jobs, will be selected. The following code snippet will result in this behavior.
sampler = DWaveSampler(solver={'qpu': True})
4. The most performant solver based on the parameter you specify
The preferred selection criteria is customizable when using the DWaveSampler or DWaveCliqueSampler. For example, if there was more than one QPU solver online and you wanted to select the one with the highest number of anneal schedule points, you could do so with
sampler = DWaveSampler(solver=dict(order_by='-properties.max_anneal_schedule_points'))
These samplers use the cloud-client to gain access to and select a solver. The 'order_by' option in the example above is provided by the cloud-client. For more information see here.
Common pitfalls
If you try to instantiate a specific solver without having the correct setup you will see an error. For example, if your dwave.conf file looks like this:
[defaults]
endpoint = https://cloud.dwavesys.com/sapi/
token = *******************
solver=hybrid_binary_quadratic_model_version2
and you try to instantiate the DWaveSampler, you will see an error. This happens because the first profile in your configuration file specifies a hybrid solver, yet you tried to instantiate a QPU solver. The solution to this problem is to delete the solver field in your [defaults] profile, so that the [defaults] profile only contains entries for the endpoint and token. That allows the Ocean SDK to programmatically select a solver. If you have multiple profiles you can still specify a solver in the subsequent profiles. For example,
[defaults]
endpoint = https://cloud.dwavesys.com/sapi/
token = *******************
[advantage]
endpoint = https://cloud.dwavesys.com/sapi/
token = *******************
solver=Advantage_solver1.1
For troubleshooting tips or more information on solver selection, check out the dwave-system wiki here.
Comments
Please sign in to leave a comment.