# 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.

## Fixstars¶

### Amplify AE Client Class¶

Name

Fixstars Amplify Annealing Engine

Client class

FixstarsClient

Execution parameter class

FixstarsClientParameters

Execution result class

FixstarsClientResult

Execution time class

FixstarsClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

65536～

Number of logical bits (Fully connected coupling)

65536～

API endpoint (default)

https://optigan.fixstars.com/

### Attributes of Amplify AE Client Class¶

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the execution parameters FixstarsClientParameters.

version

Get the version string of the Amplify Annealing Engine.

url

Get or set the API URL.

proxy

Get or set the proxy server address.

token

Get or set the API token.

write_request_data

Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved.

write_response_data

Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved.

compression

Specify whether to compress the transmitted data. Defaults to True.

### 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:



### Qiskit Client Class¶

Please refer to qiskit client reference for details.

Name

Qiskit Classes

Client Class

QiskitClient

Execution parameter class

QiskitClientParameters

Execution result class

QiskitClientResult

Execution time class

QiskitClientResultTiming

### Attributes of Qiskit Client¶

Name

Description

num_bits

Get the maximum number of executable variables.

device

Get or set the environment (“CPU”, “GPU”, “QPU”) in which QAOA will run.

token

Get or set the API token to connect to IBM Quantum.

backend

Get or set the machine name (or simulation method name) on which QAOA will run

parameters

Get the QAOA execution parameters QiskitClientParameters

version

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

QulacsClient

Execution parameter class

QulacsClientParameters

Execution result class

QulacsClientResult

Execution time class

QulacsClientResultTiming

### Attributes of Qulacs Client¶

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the QAOA execution parameters QulacsClientParameters

version

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']


## 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.

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.