Open ConnorStoneAstro opened 1 year ago
I think making a subclass BlockMassMatrix to return the desire configuration makes sense. Then you can set:
nuts_kernel.mass_matrix_adapter = ThatSubclass()
I guess we can also expose inverse_mass_matrix
to the kernel construction, like what we have in numpyro.
Subclassing BlockMassMatrix
is more elegant than what I did, but it still has the issue that I have to do it myself and so any updates to Pyro could break something. Having it exposed to the user at construction would be great!
Issue Description
I would like to be able to interact with the mass matrix in the NUTS and HMC samplers. In many cases I have access to the covariance matrix at the MAP, so being able to set the mass matrix exactly would provide a large speedup. Also, it would be nice to be able to access the mass matrix. This could be used for other purposes since it approximates the covariance matrix of the data.
This isn't a bug, just a feature I would like to have access to.
I was able to "hack" a way to get access, but it is not a long term solution since it involves overwritting functions:
Then later, once I had the mass matrix I could call:
nuts_kernel.mass_matrix_adapter.inverse_mass_matrix = {("x",): inv_mass}
I could probably make the change myself, but I imagine there is a more elegant way to do this.