Multiprocessing

Multiprocessing pool for parallel likelihood evaluation.

class socca.pool.mp.PoolFunctionTag[source]

Bases: object

Picklable proxy that invokes the pre-loaded likelihood.

Analogous to FunctionTag for MPI. Each worker process pre-loads the likelihood via the pool initializer; this lightweight tag simply forwards calls to that pre-loaded function, avoiding re-serialization of the full fitter state at runtime.

class socca.pool.mp.MultiPool(processes, likelihood)[source]

Bases: object

Process pool for parallel likelihood evaluation.

Uses loky for robust process management with cloudpickle serialization. Workers do not re-import __main__, so no if __name__ == "__main__": guard is needed in user scripts.

The likelihood is pre-loaded in each worker via the pool initializer for fast repeated evaluation. Other functions (e.g. nautilus neural network training) are serialized with cloudpickle transparently by loky.

Parameters:
  • processes (int) – Number of worker processes.

  • likelihood (callable) – Likelihood function to evaluate in parallel.

property size

Return the number of worker processes.

property likelihood

Return a picklable proxy for the pre-loaded likelihood.

map(func, iterable)[source]

Map a function over an iterable in parallel.

close()[source]

Shut down the worker pool.