TuringLang / ParetoSmooth.jl

An implementation of PSIS algorithms in Julia.
http://turinglang.org/ParetoSmooth.jl/
MIT License
19 stars 12 forks source link

Avoid computing ess and sup_ess in `psis` #51

Open sethaxen opened 2 years ago

sethaxen commented 2 years ago

This PR makes ess and sup_ess properties of Psis instead of fields, so that they are lazily computed only if necessary instead of in each psis call. It also fixes some potential issues where variables of one type are then aliased to have a different type, which may cause issues with type inference (it did in older Julia versions at least) and also makes the code more complicated.

sethaxen commented 2 years ago

Note that the test suite doesn't currently pass because due to some bugs on main. I fixed one in this PR, but not the other.

ParadaCarleton commented 2 years ago

(I merged my own PR that lets users skip ESS computations since I wanted to merge a handful of related changes in that PR, but I'm still open to switching to this implementation if we find a way to avoid duplicate computations.)