I am relatively new to PyTorch and its ecosystem. I have been porting previous code over to this framework and so far I have been using GPyTorch for Bayesian Optimization. At some point, I get a callable that is differentiable and represents an unnormalized pdf from which I wish to sample. I figured that I could use the Pyro MCMC samplers to tackle this problem.
The Pyro samplers require the specification of a callable containing Pyro primitives (Pyro model) and it was not obvious how to do such thing. I was able to solve this issue using the hacks suggested here.
Regarding reproducibility, I would like to be able to obtain the same traces upon specification of an initial seed and an initial sample (MAP estimate). After inspecting the code for pyro.infer.mcmc.mcmc, I see that I have to redefine the init method of _Worker so as to replace torch.initial_seed(). This would work for the _ParallelSampler. How about the _SingleSampler? I guess I would have to include pyro.set_rng_seed(my_seed) somewhere, possibly in the _traces method? Regarding my initial sample (initial trace), after initializing the kernel (hmc or nuts), I think I only need to set the property initial_trace in kernel. Any tips?