openjij.sampler.chimera_gpu package

Submodules

openjij.sampler.chimera_gpu.base_gpu_chimera module

class openjij.sampler.chimera_gpu.base_gpu_chimera.BaseGPUChimeraSampler[source]

Bases: dimod.core.structured.Structured

Abstract GPUChimera Sampler

property edgelist

Edges/interactions allowed by the sampler in the form [(u, v), …].

Type

list

property nodelist

Nodes/variables allowed by the sampler.

Type

list

property parameters

openjij.sampler.chimera_gpu.gpu_sa_sampler module

class openjij.sampler.chimera_gpu.gpu_sa_sampler.GPUChimeraSASampler(beta_min=None, beta_max=None, num_sweeps=1000, schedule=None, num_reads=1, unit_num_L=None)[source]

Bases: openjij.sampler.sa_sampler.SASampler, openjij.sampler.chimera_gpu.base_gpu_chimera.BaseGPUChimeraSampler

Sampler with Simulated Annealing (SA) on GPU.

Inherits from openjij.sampler.sampler.BaseSampler.

Parameters
  • beta_min (float) – Minimum inverse temperature.

  • beta_max (float) – Maximum inverse temperature.

  • num_sweeps (int) – Length of Monte Carlo step.

  • schedule_info (dict) – Information about a annealing schedule.

  • num_reads (int) – Number of iterations.

  • unit_num_L (int) – Length of one side of two-dimensional lattice in which chimera unit cells are arranged.

Raises
  • ValueError – If variables violate as below.

  • - trotter number is odd.

  • - no input "unit_num_L" to an argument or this constructor.

  • - given problem graph is incompatible with chimera graph.

  • AttributeError – If GPU doesn’t work.

sample_ising(h, J, beta_min=None, beta_max=None, num_sweeps=None, num_reads=1, schedule=None, initial_state=None, updater='single spin flip', reinitialize_state=True, seed=None, unit_num_L=None)[source]

sample with Ising model.

Parameters
  • h (dict) – linear biases

  • J (dict) – quadratic biases

  • beta_min (float) – minimal value of inverse temperature

  • beta_max (float) – maximum value of inverse temperature

  • num_sweeps (int) – number of sweeps

  • num_reads (int) – number of reads

  • schedule (list) – list of inverse temperature

  • initial_state (dict) – initial state

  • updater (str) – updater algorithm

  • reinitialize_state (bool) – if true reinitialize state for each run

  • seed (int) – seed for Monte Carlo algorithm

  • unit_num_L (int) – number of chimera units

Returns

results

Return type

openjij.sampler.response.Response

Examples:

>>> sampler = oj.GPUChimeraSASampler(unit_num_L=2)
>>> h = {0: -1, 1: -1, 2: 1, 3: 1},
>>> J = {(0, 4): -1, (2, 5): -1}
>>> res = sampler.sample_ising(h, J)

openjij.sampler.chimera_gpu.gpu_sqa_sampler module

class openjij.sampler.chimera_gpu.gpu_sqa_sampler.GPUChimeraSQASampler(beta=10.0, gamma=1.0, trotter=4, num_sweeps=100, schedule=None, num_reads=1, unit_num_L=None)[source]

Bases: openjij.sampler.sqa_sampler.SQASampler, openjij.sampler.chimera_gpu.base_gpu_chimera.BaseGPUChimeraSampler

Sampler with Simulated Quantum Annealing (SQA) on GPU.

Inherits from openjij.sampler.sqa_sampler.SQASampler.

Parameters
  • beta (float) – Inverse temperature.

  • gamma (float) – Amplitude of quantum fluctuation.

  • trotter (int) – Trotter number.

  • num_sweeps (int) – number of sweeps

  • schedule_info (dict) – Information about a annealing schedule.

  • num_reads (int) – Number of iterations.

  • unit_num_L (int) – Length of one side of two-dimensional lattice in which chimera unit cells are arranged.

Raises
  • ValueError – If variables violate as below.

  • - trotter number is odd.

  • - no input "unit_num_L" to an argument or this constructor.

  • - given problem graph is incompatible with chimera graph.

  • AttributeError – If GPU doesn’t work.

sample_ising(h, J, beta=None, gamma=None, num_sweeps=None, schedule=None, num_reads=1, unit_num_L=None, initial_state=None, updater='single spin flip', reinitialize_state=True, seed=None)[source]

Sampling from the Ising model

Parameters
  • h (dict) – Linear term of the target Ising model.

  • J (dict) – Quadratic term of the target Ising model.

  • beta (float, optional) – inverse tempareture.

  • gamma (float, optional) – strangth of transverse field. Defaults to None.

  • num_sweeps (int, optional) – number of sweeps. Defaults to None.

  • schedule (list[list[float, int]], optional) – List of annealing parameter. Defaults to None.

  • num_reads (int, optional) – number of sampling. Defaults to 1.

  • initial_state (list[int], optional) – Initial state. Defaults to None.

  • updater (str, optional) – update method. Defaults to ‘single spin flip’.

  • reinitialize_state (bool, optional) – Re-initilization at each sampling. Defaults to True.

  • seed (int, optional) – Sampling seed. Defaults to None.

Returns

results

Return type

openjij.sampler.response.Response

Examples:

>>> sampler = oj.GPUChimeraSQASampler(unit_num_L=2)
>>> h = {0: -1, 1: -1, 2: 1, 3: 1},
>>> J = {(0, 4): -1, (2, 5): -1}
>>> res = sampler.sample_ising(h, J)

Module contents