pyro-ppl / pyro

Deep universal probabilistic programming with Python and PyTorch
http://pyro.ai
Apache License 2.0
8.55k stars 987 forks source link

Supporting independent optimization problems via tensor DSL #1330

Open neerajprad opened 6 years ago

neerajprad commented 6 years ago

Closely related, more specific use case: #1213.

Can we use our tensor DSL to support the use case of solving a batch of independent optimization problems? The proposed solution is to use broadcasting to optimize a batch of parameters independently on the same model and guide. This has been brought up in multiple contexts - batched second order optimizers (#1213), experimenting with population based algorithms such as genetic algorithms, and OED (@martinjankowiak).

One possible solution, as suggested by @eb8680 in #1213, would be to introduce an iparam messenger (which may additionally broadcast param statements by the size specified and reshape all sample statements appropriately).

Things to think about:

Feel free to edit or add other solutions / use cases / design considerations.

eb8680 commented 6 years ago

pyro.module will have to be modified to support independent neural network weights / biases

Related: #503

jpchen commented 6 years ago

should we restrict to one flat iparam dim?

i think that should be fine, like pytorch's batch operations eg (bmm) only allow one dimension of batching

pyro.module will have to be modified to support independent neural network weights

i may be overthinking it, but this seems tricky to incorporate in the iparam construct since neural networks are a collection of connected weights/params represented as multiple tensors. so it may be difficult to broadcast tensor operations per iparam messenger correctly. my original implementation of vec_random_module stipulated that a user must pass in a "batch nn" (a nn with all batch operations), so the independence within a batch was guaranteed by the user.