Skip to content

DEFAULT_MERGE_BATCH_SIZE module-attribute

DEFAULT_MERGE_BATCH_SIZE = 8

MERGE_TREE_THRESHOLD module-attribute

MERGE_TREE_THRESHOLD = 64

DistributedBruteforceGPUSampler

Bases: Sampler

parameters property

parameters: Dict[str, Any]

properties property

properties: Dict[str, Any]

sample

sample(bqm, num_states, num_fixed_vars, suffix_size, grid_size, block_size, num_steps_per_kernel=1, partial_diff_buffer_depth=1, dtype=np.float32, merge_batch_size=None)

Solve Binary Quadratic Model by distributing an exhaustive search over Ray workers.

The search is split by fixing num_fixed_vars variables to all of their 2 ** num_fixed_vars possible assignments. Each assignment defines an independent subproblem over the remaining variables, which is dispatched as a Ray task and solved by the GPU kernel on one worker. There is no communication between workers during the search; the partial results are combined afterwards by a hierarchy of merge tasks.

Parameters:

Name Type Description Default
bqm

Binary Quadratic Model instance to solve.

required
num_states

number of lowest energy states to compute.

required
num_fixed_vars

number k of variables to fix, giving 2 ** k independent subproblems over bqm.num_variables - k variables each.

required
suffix_size

exponent l such that 2 ** l configurations are kept in the GPU working set at a time (see :meth:BruteforceGPUSampler.sample).

required
grid_size

number of blocks for the custom kernels.

required
block_size

number of threads per block for the custom kernels.

required
num_steps_per_kernel

number of chunks processed by a single kernel launch.

1
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:normalize_dtype. Forwarded unchanged to the workers.

float32
merge_batch_size

None (the default) picks a merge strategy from the number of subproblems, using :data:MERGE_TREE_THRESHOLD: at or below the threshold every partial result is collected on the controller and concatenated in one go, above it they are reduced by a hierarchy of Ray tasks combining :data:DEFAULT_MERGE_BATCH_SIZE of them at a time. An integer forces the hierarchy with that batch size, which also bounds the memory the controller needs; a value of at least 2 ** num_fixed_vars reproduces the single-shot merge of release 0.0.5.

None

Returns:

Type Description

sample set containing num_states samples. Its info dictionary reports, in seconds, dispatch_time_in_seconds (submitting all subproblems), solve_time_in_seconds (dispatch plus completion of every subproblem search), merge_time_in_seconds (combining the partial results and fetching the final one) and total_time_in_seconds (the sum of the latter two), together with num_subproblems, num_merge_rounds and merge_strategy.

Raises:

Type Description
ValueError

if num_fixed_vars or merge_batch_size is out of range, if the resulting subproblems cannot be enumerated by the kernels, or if dtype is not a supported precision.