MAX_KERNEL_NUM_VARIABLES
module-attribute
MAX_KERNEL_NUM_VARIABLES = 64
BruteforceGPUSampler
Bases: Sampler
parameters
property
parameters: Dict[str, Any]
properties
property
properties: Dict[str, Any]
sample
sample(bqm, num_states, suffix_size, grid_size, block_size, num_steps_per_kernel=16, partial_diff_buffer_depth=1, dtype=np.float32)
Solve Binary Quadratic Model using exhaustive (bruteforce) search on the GPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bqm
|
Binary Quadratic Model instance to solve. |
required | |
num_states
|
number of lowest energy states to compute. |
required | |
suffix_size
|
exponent l such that 2 ** l is the number of configurations kept in the GPU working set at a time; the search sweeps 2 ** (N - l) such chunks, where N is the number of variables of bqm. |
required | |
grid_size
|
number of blocks for the custom kernels. Note that this parameter does not affect the grid on which the Thrust kernels are launched. |
required | |
block_size
|
number of threads per block for custom kernels. Note that this parameter does not affect the grid on which the Thrust kernels are launched. |
required | |
num_steps_per_kernel
|
number of chunks processed by a single kernel launch. |
16
|
|
partial_diff_buffer_depth
|
depth of the incremental energy difference buffers. |
1
|
|
dtype
|
datatype to use, either np.float32 or np.float64, or one of the names
accepted by :func: |
float32
|
Returns:
| Type | Description |
|---|---|
|
sample set containing num_states samples. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if dtype is not a supported precision, or if the problem size and
suffix_size are not enumerable by the kernels (see
:func: |
normalize_dtype
normalize_dtype(dtype) -> type
Resolve a user-supplied dtype specification to np.float32 or np.float64.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
either one of |
required |
Returns:
| Type | Description |
|---|---|
type
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if the specification does not denote a supported precision. |
validate_kernel_problem_size
validate_kernel_problem_size(num_variables: int, suffix_size: int) -> None
Check that a problem of given size can be enumerated by the CUDA kernels.
The kernels keep each configuration in a single 64-bit word and iterate over
2 ** (num_variables - suffix_size) chunks of 2 ** suffix_size configurations,
so both bounds have to hold before any kernel is launched. Violating them would
otherwise produce silently truncated or wrong results rather than an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_variables
|
int
|
number of variables handed to the kernel. |
required |
suffix_size
|
int
|
number of variables forming the resident enumeration chunk. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the problem is too wide, or the suffix does not fit in it. |