-
-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Summary:
Expose Pathfinder: stan-dev/stan#3123 stan-dev/cmdstan#1155
This issue is to sketch out a design and for coordinating with the CmdStanR team (@jgabry)
Description:
Pathfinder is useful for standalone VI and for initializing MCMC, so we should cater to both usages.
New method on CmdStanModel: pathfinder.
Signature:
def pathfinder(
self,
data: Union[Mapping[str, Any], str, os.PathLike, None] = None,
*,
init_alpha: Optional[float] = None,
tol_obj: Optional[float] = None,
tol_rel_obj: Optional[float] = None,
tol_grad: Optional[float] = None,
tol_rel_grad: Optional[float] = None,
tol_param: Optional[float] = None,
history_size: Optional[int] = None,
draws: Optional[int] = None, # controls size of actual output
num_single_draws: Optional[int] = None, # corresponds to the num_draws argument on cmdline
num_paths: Optional[int] = None,
max_lbfgs_iters: Optional[int] = None,
num_elbo_draws: Optional[int] = None,
# arguments standard to all methods
seed: Optional[int] = None,
inits: Union[Dict[str, float], float, str, os.PathLike, None] = None,
output_dir: OptionalPath = None,
sig_figs: Optional[int] = None,
save_profile: bool = False,
show_console: bool = False,
refresh: Optional[int] = None,
time_fmt: str = "%Y%m%d%H%M%S",
timeout: Optional[float] = None,
) -> CmdStanPathfinder:This is probably more-or-less what you would expect going off of the CmdStan implementation. One notable thing is - at the moment - I am not providing a way to save individual pathfinder runs (the save_single_paths arg). If things from the diagnostic files produced by this argument end up being important to initializing MCMC, we can add support then, but I don't think it is valuable in the first implementation
New Class CmdStanPathfinder
This will look broadly similar to CmdStanLaplace, with the main methods being those that let you access the draws: stan_variable, draws_pd, etc
For supporting the initialization of MCMC, I think it is important to also have a method like
create_inits(self, seed = None, num_chains = 4)
This will return a list of dictionaries of 4 random draws from the pathfinder outputs in the format required for the inits argument to other methods. We can also consider adding CmdStanPathfinder as an option for the inits argument directly, in which case this method would just be called.