--- sd_hide_title: true --- # D-Wave Systems (clients-DWaveSamplerClient)= ## D-Wave Sampler [D-Wave Systems](https://www.dwavesys.com/) offers a quantum annealing machine (quantum processing unit; QPU) that allows you to input QUBO or a combinatorial optimization problem expressed as a quadratic polynomial in Ising variables. ```{tip} You can [register as a Fixstars Amplify user](https://amplify.fixstars.com/register) to get a free trial API token for D-Wave Systems, or get an API token with your D-Wave Systems account. ``` :**Solver specification**: ```{list-table} :width: 100% :widths: 1 2 * - Client class - {py:class}`amplify.DWaveSamplerClient` * - [Execution parameters](amplify.DWaveSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [Execution results](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [Execution time](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["timing"]["qpu_access_time"]` * - API method - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - Execution parameter reference - [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,Binary variable,Ising variable,Integer variable,real variable Objective function,2nd{sup}`*`,2nd{sup}`*`,\-,\- Equality constraint,\-,\-,\-,\- Inequality constraint,\-,\-,\-,\- ``` \*: Problems involving both binary and Ising variables at the same time are not handled. :**Client class**: In addition to [the common interface](#client-common-interface), the client class has the following attributes. ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - Attribute - Data type - Details * - {py:attr}`~amplify.DWaveSamplerClient.solver` - {py:class}`str` - Get and set the name of the D-Wave Sampler to use * - {py:attr}`~amplify.DWaveSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - Get a list of D-Wave Sampler names that can be specified with the set token. * - {py:attr}`~amplify.DWaveSamplerClient.properties` - {py:class}`dict` - Get the solver properties to use (returns the same as {py:attr}`dwave.system.samplers.DWaveSampler.properties`) ``` :**Configuration example**: ```{testcode} from amplify import DWaveSamplerClient client = DWaveSamplerClient() # Set API token client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Specify the solver to use # (Specify one of the client.solver_names) client.solver = "Advantage_system4.1" # Set the number of runs to 1000 client.parameters.num_reads = 1000 ``` ````{seealso} For the attribute you can set in {py:attr}`amplify.DWaveSamplerClient.parameters`, refer to [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html). You can also get them from {py:attr}`~amplify.DWaveSamplerClient.properties` (the output will vary depending on the {py:attr}`~amplify.DWaveSamplerClient.solver`) as follows. ```python >>> client.properties["parameters"] {'anneal_offsets': 'Anneal offsets for each working qubit, formatted as a list, with NaN specified for unused qubits.', 'anneal_schedule': "Annealing schedule formatted as a piecewise linear list of floating-point pairs of 't' and 's'.", 'annealing_time': 'Quantum annealing duration, in microseconds, as a positive floating point number.', ...} ``` ```` :**Execution example**: ```python from amplify import Model, VariableGenerator, solve # Create decision variables and the objective function g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # Create a model model = Model(f) # Run the solver result = solve(model, client) ``` Obtain the solver to use (if not specified, it will be determined automatically): ```python >>> client.solver 'Advantage_system4.1' ``` Obtain the list of solvers currently available: ```python >>> client.solver_names ['Advantage_system6.4', 'Advantage2_prototype2.5', 'Advantage_system4.1'] ``` Obtain detailed execution time: ```python >>> result.client_result.info {'timing': {'qpu_sampling_time': 66040.0, 'qpu_anneal_time_per_sample': 20.0, 'qpu_readout_time_per_sample': 25.46, 'qpu_access_time': 81799.16, 'qpu_access_overhead_time': 621.84, 'qpu_programming_time': 15759.16, 'qpu_delay_time_per_sample': 20.58, 'total_post_processing_time': 1.0, 'post_processing_overhead_time': 1.0}, 'problem_id': '14eaa606-9eed-4c72-83f1-d563bb0e1956'} ``` (clients-LeapHybridSamplerClient)= ## Leap's Hybrid BQM Sampler This is a hybrid solver from [D-Wave Systems](https://www.dwavesys.com/) that works with quantum annealing machines (QPUs) and classical algorithms, allowing input of combinatorial optimization problems expressed as QUBOs or quadratic polynomials in Ising variables, and supporting input of larger problems than [D-Wave Sampler](#DWaveSamplerClient). ```{tip} You can [register as a Fixstars Amplify user](https://amplify.fixstars.com/register) to get a free trial API token for D-Wave Systems, or get an API token with your D-Wave Systems account. ``` :**Solver specification**: ```{list-table} :width: 100% :widths: 1 2 * - Client class - {py:class}`amplify.LeapHybridSamplerClient` * - [Execution parameters](amplify.LeapHybridSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [Execution result](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [Execution time](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["run_time"]` * - API method - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - Execution parameter reference - [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,Binary variable,Ising variable,Integer variable,Real variable Objective function,2nd,2nd,\-,\- Equality constraint,\-,\-,\-,\- Inequality constraint,\-,\-,\-,\- ``` :**Client class**: In addition to [the common interface](#client-common-interface), the client class has the following attributes. ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - Attribute - Data type - Details * - {py:attr}`~amplify.LeapHybridSamplerClient.solver` - {py:class}`str` - Get and set the name of Leap's Hybrid BQM Sampler. * - {py:attr}`~amplify.LeapHybridSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - Get a list of Leap's Hybrid BQM sampler names that can be specified with the set token. * - {py:attr}`~amplify.LeapHybridSamplerClient.properties` - {py:class}`dict` - Get the properties of the solver to use (returns the same result as {py:attr}`dwave.system.samplers.LeapHybridSampler.properties`) ``` :**Configuration example**: ```{testcode} from amplify import LeapHybridSamplerClient client = LeapHybridSamplerClient() # Set API token client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Get the solver to use # (if not specified, it will be determined automatically) # print(client.solver) # Get a list of available solvers # print(client.solver_names) # Specify which solver ro use # (Specify one of the names in client.solver_names) client.solver = "hybrid_binary_quadratic_model_version2" # Set the execution time limit to 5 seconds client.parameters.time_limit = 5 ``` ````{seealso} Dor attributes you can set in {py:attr}`amplify.LeapHybridSamplerClient.parameters`, refer to [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html). You can also get them from {py:attr}`~amplify.LeapHybridSamplerClient.properties` as follows (the output will vary depending on the {py:attr}`~amplify.LeapHybridSamplerClient.solver`) ```python >>> client.properties["parameters"] {'time_limit': 'Maximum requested runtime in seconds.'} ``` ```` :**Execution example**: ```python from amplify import Model, VariableGenerator, solve # Create decision variables and the objective function g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # Create a model model = Model(f) # Run the solver result = solve(model, client) ``` Obtain the solver to use (if not specified, it will be determined automatically): ```python >>> client.solver 'hybrid_binary_quadratic_model_version2' ``` Obtain the list of currently available solvers:: ```python >>> client.solver_names ['hybrid_binary_quadratic_model_version2'] ``` Obtain detailed execution time: ```python >>> result.client_result.info {'qpu_access_time': 47632, 'charge_time': 2989001, 'run_time': 2989001, 'problem_id': '745910bb-2e3b-4f3e-90fc-eb5734c637f3'} ``` (clients-LeapHybridCQMSamplerClient)= ## Leap's Hybrid CQM Sampler This is a hybrid solver from [D-Wave Systems](https://www.dwavesys.com/) that uses quantum annealing machines (QPUs) and classical algorithms to solve combinatorial optimization problems with QUBO or Ising, integer or real variable objective functions, and one or more constraints. ```{tip} You can [register as a Fixstars Amplify user](https://amplify.fixstars.com/register) to get a free trial API token for D-Wave Systems, or get an API token with your D-Wave Systems account. ``` :**Solver specification**: ```{list-table} :width: 100% :widths: 1 2 * - Client class - {py:class}`amplify.LeapHybridCQMSamplerClient` * - [Execution parameters](amplify.LeapHybridCQMSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [Execution result](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [Execution time](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["run_time"]` * - API method - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - Execution parameter reference - [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,Binary variable,Ising variable,Integer variable,Real variable Objective function,2nd,2nd,2nd,1st Equality constraint,2nd,2nd,2nd,1st Inequality constraint,2nd,2nd,2nd,1st ``` :**Client class**: In addition to [the common interface](#client-common-interface), the client class has the following attributes. ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - Attribute - Data type - Details * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver` - {py:class}`str` - Get and set the name of Leap's Hybrid BQM Sampler. * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - Get the list of Leap's Hybrid BQM Sampler names you can use with the set token. * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.properties` - {py:class}`dict` - Get the properties of the solver to use (returns the same result as {py:attr}`dwave.system.samplers.LeapHybridCQMSampler.properties`) ``` :**Configuration example**: ```{testcode} from amplify import LeapHybridCQMSamplerClient client = LeapHybridCQMSamplerClient() # Set an API token client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Specify the solver to use # (Specify a name from client.solver_names) client.solver = "hybrid_constrained_quadratic_model_version1p" # Set an execution time limit to 3 seconds client.parameters.time_limit = 3 ``` ````{seealso} For attributes you can set in {py:attr}`amplify.LeapHybridCQMSamplerClient.parameters`, refer to [{bdg-info}`📖 Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html). You can also get them from {py:attr}`~amplify.LeapHybridCQMSamplerClient.properties` as follows (the output will vary depending on the {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver`) ```python >>> client.properties["parameters"] {'time_limit': 'Maximum requested runtime in seconds.'} ``` ```` :**Execution example**: ```python from amplify import Model, VariableGenerator, solve # Create decision variables and the objective function g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # Create a model model = Model(f) # Run the solver result = solve(model, client) ``` Obtain the solver (if not specified it will be automatically set): ```python >>> client.solver 'hybrid_constrained_quadratic_model_version1p' ``` Obtain the list of the solvers currently available: ```python >>> client.solver_names ['hybrid_constrained_quadratic_model_version1p'] ``` Obtain the solver version: ```python >>> client.version '1.12' ``` Obtain detailed execution time: ```python >>> result.client_result.info {'constraint_labels': [], 'qpu_access_time': 15846, 'charge_time': 4305380, 'run_time': 4305380, 'problem_id': '47db4ee7-2e60-4c99-99ae-b596914d4907'} ```