Client
This section describes the Ising machine clients.
Client Class Overview
The client class provides an interface for getting and setting hardware parameters of each Ising machine, as well as for executing it.
The typical use of the client class is to give the client class object as a driver to the solver class Solver
, so that the solver class can solve logical models using the corresponding Ising machine.
See Solver or execution example of each client for more details and examples.
Note
Although the client class can also be used as a solver for the physical model (see physical model solver for more information), it is recommended to use the solver class.
There are two types of parameters that the client class can set:
Settings of access information and execution of the Ising machines
These are provided as the attributes of the client class. It sets configurations such as the URL of the access point and API token. Some clients have settings related to data compression and data transmission methods.
Execution parameters of the Ising machines
It sets the execution parameters according to the API specifications of the machines. It is provided by the attribute
parameters
of the client class.
See also
Please refer to Client for more information on the client classes and their related classes.
Fixstars
Amplify AE Client Class
Please refer to Fixstars client reference for more information.
Name |
Fixstars Amplify Annealing Engine |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
262144 or greater |
Number of logical bits (Fully connected coupling) |
131072 |
API endpoint (default) |
Attributes of Amplify AE Client Class
Name |
Description |
---|---|
Get the maximum number of executable variables. |
|
Get the execution parameters |
|
Get the version string of the Amplify Annealing Engine. |
|
Get or set the API URL. |
|
Get or set the proxy server address. |
|
Get or set the API token. |
|
Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. |
|
Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. |
|
Specify whether to compress the transmitted data. Defaults to |
Example of Amplify AE Client
from amplify import BinarySymbolGenerator, Solver
from amplify.client import FixstarsClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = FixstarsClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.timeout = 1000 # Timeout is 1 second
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
D-Wave
Note
To use D-Wave Sampler and Leap Hybrid Solver, dwave-system package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows:
$ pip install amplify[extra]
D-Wave Client Classes
Please refer to D-Wave client reference for more information.
Name |
D-Wave Sampler (Ocean SDK) |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Zephyr graph (Advantage2_prototype1.1), Pegasus graph (Advantage_system4.1, Advantage_system6.3) |
Number of physical bits |
563 (Advantage2_prototype1.1), 5627 (Advantage_system4.1), 5614 (Advantage_system6.3) |
Number of logical bits (Fully connected coupling) |
52 (Advantage2_prototype1.1), 177 (Advantage_system4.1), 175 (Advantage_system6.1) |
API endpoint (default) |
Name |
Leap Hybrid Solver (Ocean SDK) |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
1000000 |
Number of logical bits (Fully connected coupling) |
1000000 |
API endpoint (default) |
Attributes of D-Wave Client
Name |
Description |
---|---|
|
Get the maximum number of executable variables.
|
|
Get the execution parameters.
|
|
Get or set the proxy server address. |
|
Get or set the name of the solver to be executed.
|
|
Get the list of available solver names. |
|
Get or set the API token. |
|
Get or set the API URL. |
|
Get the solver name with its version string. |
Example of D-Wave Client
D-Wave Sampler Client
from amplify import BinarySymbolGenerator, Solver
from amplify.client.ocean import DWaveSamplerClient
client = DWaveSamplerClient()
client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Specify the solver (the available solver names can be obtained by `solver_names`)
client.solver = "Advantage_system4.1"
client.parameters.num_reads = 100 # Number of executions
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
By setting token
, the list of the available solver names related to the token can be obtained as follows:
>>> client.solver_names
['Advantage_system4.1', 'Advantage_system6.3', 'Advantage2_prototype1.1']
D-Wave Leap Hybrid Solver Client
from amplify import BinarySymbolGenerator, Solver
from amplify.client.ocean import LeapHybridSamplerClient
client = LeapHybridSamplerClient()
client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Specify the solver (the available solver names can be obtained by `solver_names`)
client.solver = "hybrid_binary_quadratic_model_version2"
client.parameters.time_limit = 3 # Time limit is 3 seconds
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
Similar to DwaveSamplerClient
, the available solver names can be obtained as follows:
>>> client.solver_names
['hybrid_binary_quadratic_model_version2']
Fujitsu
Fujitsu Client Classes
Please refer to Fujitsu client reference for more information.
Name |
FujitsuDASolver |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
1024 |
Number of logical bits (Fully connected coupling) |
1024 |
API endpoint (default) |
Name |
FujitsuDASolver (Expert Mode) |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
1024 |
Number of logical bits (Fully connected coupling) |
1024 |
API endpoint (default) |
Name |
FujitsuDAPTSolver |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
1024 |
Number of logical bits (Fully connected coupling) |
1024 |
API endpoint (default) |
Name |
FujitsuDAMixedModeSolver |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
1024 |
Number of logical bits (Fully connected coupling) |
1024 |
API endpoint (default) |
Name |
FujitsuDA2Solver |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
8192 |
Number of logical bits (Fully connected coupling) |
8192 |
API endpoint (default) |
Name |
FujitsuDA2Solver (Expert Mode) |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
8192 |
Number of logical bits (Fully connected coupling) |
8192 |
API endpoint (default) |
Name |
FujitsuDA2PTSolver |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
8192 |
Number of logical bits (Fully connected coupling) |
8192 |
API endpoint (default) |
Name |
FujitsuDA2MixedModeSolver |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
8192 |
Number of logical bits (Fully connected coupling) |
8192 |
API endpoint (default) |
Name |
FujitsuDA3SolverClient |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
100000 |
Number of logical bits (Fully connected coupling) |
100000 |
API endpoint (default) |
Name |
FujitsuDA4SolverClient |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
100000 |
Number of logical bits (Fully connected coupling) |
100000 |
API endpoint (default) |
Attributes of Fujitsu Client
Name |
Description |
---|---|
|
Get the maximum number of executable variables. |
|
Get the execution parameters.
|
|
Get or set the API URL. |
|
Get or set the proxy server address. |
|
Get or set the API token. |
|
Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. |
|
Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. |
|
Get the API version string of the Fujitsu Digital Annealer. |
Specify whether to use penalty quadratic polynomial for |
|
Specify whether to use one-dimensional one-hot constraint information for |
|
Specify whether to use two-dimensional one-hot constraint information for |
|
Specify whether to use linear inequality constraints for |
Example of Fujitsu Client
FujitsuDA2PTSolverClient
from amplify import BinarySymbolGenerator, Solver
from amplify.client import FujitsuDA2PTSolverClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = FujitsuDA2PTSolverClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.number_iterations = 1000
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
Note
Please refer to the corresponding parts of the Schemes of Digital Annealer API reference (QUBO API V2) for details on the parameters of FujitsuDA and FujitsuDA2 clients.
FujitsuDA3SolverClient
from amplify import BinarySymbolGenerator, Solver
from amplify.client import FujitsuDA3SolverClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = FujitsuDA3SolverClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.time_limit_sec = 1 # Time limit is 1 second
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]',
'energy = 0.0, q = [1. 0. 0.]',
'energy = 0.0, q = [0. 1. 1.]',
'energy = 1.0, q = [0. 0. 0.]']
Note
Please refer to FujitsuDA3Solver Schemas of Digital Annealer API reference (QUBO API V3) for details of FujitsuDA3SolverClient
parameters.
FujitsuDA4SolverClient
from amplify import BinarySymbolGenerator, Solver
from amplify.client import FujitsuDA4SolverClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = FujitsuDA4SolverClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.time_limit_sec = 1 # Time limit is 1 second
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]',
'energy = 0.0, q = [1. 0. 0.]',
'energy = 0.0, q = [0. 1. 1.]',
'energy = 1.0, q = [0. 0. 0.]']
Note
Please refer to FujitsuDA4Solver Schemas of Digital Annealer API reference (QUBO API V4) for details of FujitsuDA4SolverClient
parameters.
Toshiba
Toshiba Client Class
Please refer to Toshiba client reference for more information.
Name |
Toshiba SQBM+ |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
100000 |
Number of logical bits (Fully connected coupling) |
100000 |
API endpoint (default) |
N/A |
Name |
Toshiba SQBM+ (version 2.0.0 ~) |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
100000 |
Number of logical bits (Fully connected coupling) |
100000 |
API endpoint (default) |
N/A |
Attributes of Toshiba Client
Name |
Description |
---|---|
Get the maximum number of executable variables. |
|
Get the execution parameters. |
|
Get or set the API URL. |
|
Get or set the proxy server address. |
|
Get or set the API token. |
|
Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. |
|
Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. |
|
Get the API version string of the Toshiba SBM/SQBM+. |
Attributes of ToshibaSQBM2Client
Attributes that are only available in ToshibaSQBM2Client are as follows.
Name |
Description |
---|---|
Get or set the request data format. Two types of data types are supported. |
Example of Toshiba Client
ToshibaClient
from amplify import BinarySymbolGenerator, Solver
from amplify.client import ToshibaClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = ToshibaClient()
client.url = "http://xxx.xxx.xxx.xxx:xxxx/"
client.parameters.loops = 0 # not specify the number of loops (only timeout will be used)
client.parameters.timeout = 1 # Timeout is 1 second
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
Note
Please refer to Simulated Bifurcation Machine (SBM) User Manual for details of Toshiba SBM.
ToshibaSQBM2Client
from amplify import BinarySymbolGenerator, Solver
from amplify.client import ToshibaSQBM2Client
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = ToshibaSQBM2Client()
client.url = "http://xxx.xxx.xxx.xxx:xxxx/"
client.parameters.loops = 0 # not specify the number of loops (only timeout will be used)
client.parameters.timeout = 1 # timeout 1 second
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
Hitachi
Hitachi Client Class
Please refer to Hitachi client reference for more information.
Name |
Hitachi CMOS annealing machine (type 4: GPU) |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
King Graph |
Number of physical bits |
262144 (512x512) |
Number of logical bits (Fully connected coupling) |
512 |
API endpoint (default) |
https://annealing−cloud.com/api/v2/ |
Attributes of Hitachi Client
Name |
Description |
---|---|
Get the maximum number of executable variables. |
|
Get the execution parameters |
|
Get or set the API URL. |
|
Get or set the proxy server address. |
|
Get or set the API token. |
|
Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. |
|
Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. |
|
Get the API version string of the Hitachi CMOS annealing machine. |
Example of Hitachi Client
HitachiClient
from amplify import BinaryPoly, gen_symbols, Solver
from amplify.client import HitachiClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = HitachiClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.temperature_num_steps = 10
client.parameters.temperature_step_length = 100
client.parameters.temperature_initial = 100.0
client.parameters.temperature_target = 0.02
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
Note
Please refer to API reference V2 for details of Hitachi CMOS annealing machine.
Hiroshima Univ. / NTT DATA
ABS Client Class
Please refer to ABS client reference for details.
Name |
ABS QUBO Solver |
---|---|
Client Class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
32768 |
Number of logical bits (Fully connected coupling) |
32768 |
API URL (default) |
Attributes of ABS Client
Name |
Description |
---|---|
Get the maximum number of executable variables. |
|
Get the execution parameters |
|
Get or set the API URL |
|
Get or set the proxy server address. |
|
Get or set the user ID |
|
Get or set the password |
|
Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. |
|
Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. |
|
Get the version string of the ABS QUBO solver client. |
Example of ABS Client
ABSClient
from amplify import BinaryPoly, gen_symbols, Solver
from amplify.client import ABSClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = ABSClient()
client.user_name = "xxxx"
client.password = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.timeout = 10
client.parameters.word_size = 16
client.parameters.arithmetic_precision = 32
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
Note
Please refer to https://qubo.cs.hiroshima-u.ac.jp/solver-trial for details of ABS QUBO Solver.
Gurobi
Note
To make use of Gurobi Client, the software and the license of Gurobi must be installed properly on your computer.
Gurobi Client Class
Please refer to gurobi client reference for details.
Name |
Gurobi Optimizer |
---|---|
Client Class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
Attributes of Gurobi Client
Name |
Description |
---|---|
Get the maximum number of executable variables. |
|
Get the execution parameters |
|
Get or set the path to the dynamic library of Gurobi. |
|
Get or set the filepath where to save the model data input to Gurobi. Defaults to an empty string and the model data will not be saved. The valid file extensions are |
|
Get or set the filepath where to save the solution output by Gurobi. Defaults to an empty string and the model data will not be saved. The valid file extensions are |
|
Get the version string of the Gurobi dynamic library. |
Example of Gurobi Client
GurobiClient
from amplify import BinaryPoly, gen_symbols, Solver
from amplify.client import GurobiClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = GurobiClient()
client.parameters.time_limit = 10
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
Note
Please refer to documents for details of Gurobi Optimizer.
IBM Qiskit
Run QAOA with IBM Quantum or its simulator using Qiskit.
Note
To use an actual quantum computer with Qiskit Client, make sure to obtain API token of IBM Quantum in advance.
Note
To use the Qiskit client, amplify.qaoa package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows:
$ pip install amplify[extra]
Qiskit Client Class
Please refer to qiskit client reference for details.
Name |
Qiskit Classes |
---|---|
Client Class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
Attributes of Qiskit Client
Name |
Description |
---|---|
Get the maximum number of executable variables. |
|
Get or set the environment (“CPU”, “GPU”, “QPU”) in which QAOA will run. |
|
Get or set the API token to connect to IBM Quantum. |
|
Get or set the machine name (or simulation method name) on which QAOA will run |
|
Get the QAOA execution parameters |
|
Get the version string of the ampllify.qaoa library. |
Note
To run a simulation using a GPU, the qiskit-aer
package needs to be uninstalled and replaced with the qiskit-aer-gpu
package, as follows:
$ pip uninstall qiskit-aer
$ pip install qiskit-aer-gpu
Example of QiskitClient
Real quantum devices
from amplify import BinarySymbolGenerator, Solver
from amplify.client import QiskitClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = QiskitClient()
client.device = "QPU" # Set "QPU" to use a real quantum device
client.token = "xxxxxxxx" # API token is required to use a real quantum device
# Set the machine name: If not specified, a "least busy" machine that
# satisfies the required number of bits for execution is automatically selected.
client.backend = "ibmq_bogota"
# Settings of QAOA parameters
client.parameters.reps = 10 # Depth of the circuit
client.parameters.shots = 1024 # Number of samples
client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result]
['energy = -1.0, q = [1. 0. 1.], frequency = 216', 'energy = 0.0, q = [0. 0. 1.], frequency = 56', 'energy = 0.0, q = [0. 1. 1.], frequency = 188', 'energy = 0.0, q = [1. 0. 0.], frequency = 235', 'energy = 1.0, q = [0. 1. 0.], frequency = 199', 'energy = 1.0, q = [1. 1. 1.], frequency = 41', 'energy = 1.0, q = [0. 0. 0.], frequency = 62', 'energy = 2.0, q = [1. 1. 0.], frequency = 27']
Note
Please refer to QiskitClientParameters
for QAOA parameters in details.
Ideal quantum circuit simulators
from amplify import BinaryPoly, BinarySymbolGenerator, Solver
from amplify.client import QiskitClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = QiskitClient()
client.device = "CPU" # Set "CPU" or "GPU" for simulations
client.backend = "statevector" # Set the simulation method
# Settings of QAOA parameters
client.parameters.reps = 10 # Depth of the circuit
client.parameters.shots = 1024 # Number of samples
client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result]
['energy = -1.0, q = [1. 0. 1.], frequency = 250', 'energy = 0.0, q = [0. 1. 1.], frequency = 246', 'energy = 0.0, q = [1. 0. 0.], frequency = 250', 'energy = 1.0, q = [0. 1. 0.], frequency = 278']
Note
Please refer to Qiskit document for simulator method names.
Simulators that mimic real machines
from amplify import BinaryPoly, BinarySymbolGenerator, Solver
from amplify.client import QiskitClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = QiskitClient()
client.device = "CPU" # Set "CPU" or "GPU" for simulations
client.token = "xxxxxxxx" # API token is required to use a real quantum device
# Set the machine name: If not specified, a "least busy" machine that
# satisfies the required number of bits for execution is automatically selected.
client.backend = "ibmq_bogota"
# Settings of QAOA parameters
client.parameters.reps = 10 # Depth of the circuit
client.parameters.shots = 1024 # Number of samples
client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result]
['energy = -1.0, q = [1. 0. 1.], frequency = 250', 'energy = 0.0, q = [0. 1. 1.], frequency = 246', 'energy = 0.0, q = [1. 0. 0.], frequency = 250', 'energy = 1.0, q = [0. 1. 0.], frequency = 278']
Qulacs
Run QAOA with quantum simulator Qulacs.
Note
To use the Qulacs client, amplify.qaoa package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows:
$ pip install amplify[extra]
Qulacs Client Class
Please refer to qulacs client reference for details.
Name |
Qulacs Classes |
---|---|
Client Class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
Attributes of Qulacs Client
Name |
Description |
---|---|
Get the maximum number of executable variables. |
|
Get the QAOA execution parameters |
|
Get the version string of the ampllify.qaoa library. |
Example of QulacsClient
QulacsClient
from amplify import BinarySymbolGenerator, Solver
from amplify.client import QulacsClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = QulacsClient()
# Settings of QAOA parameters
client.parameters.reps = 10 # Depth of the circuit
client.parameters.shots = 1024 # Number of samples
client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result]
['energy = -1.0, q = [1. 0. 1.], frequency = 0', 'energy = 0.0, q = [0. 0. 1.], frequency = 0', 'energy = 0.0, q = [0. 1. 1.], frequency = 30', 'energy = 0.0, q = [1. 0. 0.], frequency = 0', 'energy = 1.0, q = [0. 0. 0.], frequency = 2', 'energy = 1.0, q = [0. 1. 0.], frequency = 988', 'energy = 1.0, q = [1. 1. 1.], frequency = 0', 'energy = 2.0, q = [1. 1. 0.], frequency = 2']
NEC
NEC Client Class
Please refer to the user manual of the NEC Vector Annealing Service for more information.
Name |
NEC Vector Annealing Service |
---|---|
Client class |
|
Execution parameter class |
|
Execution result class |
|
Execution time class |
|
Physical graph |
Fully connected coupling |
Number of physical bits |
300000 |
Number of logical bits (Fully connected coupling) |
300000 |
Attributes of NEC Client Class
Name |
Description |
---|---|
Get the maximum number of executable variables. |
|
Get the execution parameters |
|
Get the version string of the NEC Vector Annealing Service. |
|
Get or set the proxy server address. |
|
Get or set the API token. |
|
Specifies whether to set the onhot constraint parameter of VA. Defaults to |
|
Specifies whether to set the andzero constraint parameter of VA. Defaults to |
|
Specifies whether to set the orone constraint parameter of VA. Defaults to |
|
Specifies whether to set the maxone constraint parameter of VA. Defaults to |
|
Specifies whether to set the minmaxone constraint parameter of VA. Defaults to |
|
Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved. |
|
Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved. |
Example of NEC Client
from amplify import BinarySymbolGenerator, Solver
from amplify.client import NECClient
gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1
client = NECClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.num_sweeps = 500
solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']
Physical Model Solver
It is recommended to use a client class as the driver of the solver class for typical usage, but the client class can also be used as a solver for the physical model.
Note
This function is intended for direct operation of each machine or for debugging purposes.
All clients have solve()
method. The followings are possible inputs. For matrix object input, the second argument corresponds to the constant term.
solve(
BinaryPoly
)solve(
IsingPoly
)solve(
BinaryIntPoly
)solve(
IsingIntPoly
)solve(
BinaryMatrix
,float
=0.0
)solve(
IsingMatrix
,int
=0.0
)solve(
BinaryIntMatrix
float
=0
)solve(
IsingIntMatrix
,int
=0
)
Possible input polynomials must be quadratic, and variable indices and interactions must match the specifications of each machine. The model needs to be a physical model, and the interactions between variables need to be consistent with the graph based on the hardware specifications. Depending on the graph, there may be restrictions on the interactions between variables.
Note
Please refer to D-Wave System Documentation D-Wave machine’s QPU topology.
Note
Although Hitachi CMOS annealing machine is specified by two-dimensional indices, Amplify SDK uses one-dimensional indices. Regarding to the coordinates of the King’s graph \(x\), \(y\), note that one-dimensional variable index \(i = L x + y\) is given. Here, \(L = 512\) represents the length of one side of the King’s graph.
solve()
method returns ClientResult
class object, which is specific to the client in use.
ClientResult
class has the following common attributes. optional
is provided only for some clients.
execution_parameters
(optional) : Get the execution parameters.timing
: Get the execution time object.solutions
: Get the list of the execution results. Each element has the following attributes: