-
Notifications
You must be signed in to change notification settings - Fork 65
Sampler behavior changes in 1.0.0
Between versions 0.9.x
and 1.x.x
, the samplers in dwave.system.samplers.*
slightly modified their solver selection behavior.
The changes are introduced in the specialized samplers PR and supported by instance-level Client
config defaults (released as part of dwave-cloud-client==0.8.0
).
-
client
set to"qpu"
, can be overridden by explicit keyword argument. -
solver
preference set as client-instance default (solver hint). Can be overridden by config file, environment variable, explicit keyword argument.
- In a clean environment (default, first time install):
sampler = DWaveSampler()
selects a QPU with the highest number of qubits, i.e. an Advantage QPU.
- If the user already has a config file or environment variable selecting a QPU as the default
solver
, the default instantiation:
sampler = DWaveSampler()
will select exactly that QPU the user externally set.
- If the user already has a config file or environment variable selecting a hybrid or software solver as the default
solver
, the default instantiation:
sampler = DWaveSampler()
will fail with:
SolverNotFoundError: Solver with the requested features not available
That's because DWaveSampler
tries to use a QPU client for an externally/user-set non-QPU solver. dwave.cloud.qpu.Client
filters out non-QPU solvers.
There are two main resolutions in this scenario:
i) Modify user preference for solver by modifying solver
in config file or the DWAVE_API_SOLVER
environment variable. When running a program from the command-line, a simple override is possible with: DWAVE_API_SOLVER= python program.py
. That sets the process environment variable DWAVE_API_SOLVER
to an empty string.
ii) Explicitly set solver
when calling DWaveSampler
. For example:
sampler = DWaveSampler(solver=dict(qpu=True))
# or
sampler = DWaveSampler(solver='<solver-name>')
- When solver is specified explicitly in the constructor (as some code examples and docs snippets do):
sampler = DWaveSampler(solver=dict(qpu=True))
the solver hint to use an Advantage system is overridden, and the behavior is identical to the one from 0.9.x
. For the code above, a QPU solver with the least average load is selected (D-Wave 2000Q or Advantage).
Users registered after 2020-09-23 will not have DWAVE_API_SOLVER
environment variable set in their profile. With Ocean SDK 3.0.0 pre-installed since 2020-09-25, the behavior falls under (1) or (4) above.
Existing users have their DWAVE_API_SOLVER
(re-)set to '{"qpu": true}'
, resulting in a behavior described in (2) above.
Minor changes.
TODO: give more details.