torch_pso
torch_pso copied to clipboard
Parallelize particle steps
Is your feature request related to a problem? Please describe. This algorithm is linear in the number of particles in a swarm. For large swarms, this makes it very slow.
Describe the solution you'd like Each particle step is currently implemented in a way so that is completely independent of other particles. This could be easily parallelized using multiprocessing to provide some speed up.
Describe alternatives you've considered The fastest solution would be to reimplement the algorithm so that each particle isn't a separate python object, but instead the swarm instead stores batches of parameters as tensors with one expanded dimension. This will allow vectorization/parallelization at the hardware level, and will provide the biggest gains in speed. This however, will require significant reworking of the structure of the implementation.