mixle.enumeration.quantization.parallel module¶
Parallel quantization and distributed enumeration for the count-semiring index.
Two capabilities, both built on the existing resource/chunking layer
(mixle.utils.parallel.planner Resources and _split_range):
Parallel quantization (
ConvolutionExecutor): the count-DP’s cost is dominated by big-integer convolutions of count histograms (sequence power chains, composite suffix convolutions). Those are pure-data and embarrassingly parallel over the output bucket range, so a worker pool computes disjoint output slices and the result is concatenated. Outputout[k] = sum_i a[i]*b[k-i]is independent of the chunk boundaries, so the parallel result equals the serial one exactly. Attach an executor to aQuantizerand the DP routes its convolutions through it (seemixle.enumeration.quantization.Quantizer.convolve()).Distributed unranking (
distributed_unrank()): unranking a contiguous rank range is embarrassingly parallel. The structural unrankers are closures (not picklable), so each worker rebuilds the index from the (picklable) distribution and unranks only its assigned rank sub-range; the per-worker rebuild is duplicated but the unranking is parallelized. Works on a local process pool and on a Spark context.
Use parallel quantization when histograms are large (deep budgets / high oversample); for small problems the serial path is used automatically to avoid pickling overhead.
- resolve_workers(num_workers=None)[source]
Resolve a worker count from an explicit request, Resources, or the CPU count.
- class ConvolutionExecutor(num_workers=None, min_parallel_width=2048)[source]
Bases:
objectProcess-pool executor for big-integer histogram convolutions (parallel quantization).
A context manager holding a reusable pool.
convolve(a, b, max_fine_bucket)returns amixle.enumeration.quantization.CountHistogramequal to the serial convolution. Falls back to serial when the output is small or only one worker is available.- close()[source]
- Return type:
None
- distributed_unrank(dist, budget_bits, start=0, count=None, bin_width_bits=1.0, oversample=8, num_workers=None, backend='local', spark_context=None)[source]
Unrank the rank range [start, start+count) in parallel, returning items in rank order.
Each worker rebuilds the index from
dist(picklable) and unranks its assigned sub-range.count=Noneunranks to the end of the index.backendis'local'(process pool) or'spark'(requiresspark_context). The result equals the serial enumeration order.