stan-dev / stan-dev/stan

Refactor write_iteration* functions

Open
#1,538 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

code cleanup
Dominant language
C++
Stars
2.8k
Forks
388
Avg merge
2d 17h
Merged PRs (30d)
15

Description

write_iteration_csv(...) currently requires specifying the log probability lp. This is unneeded for variational inference, and as a hack currently writes 0.0 there: https://github.com/stan-dev/stan/blob/develop/src/stan/variational/advi.hpp#L315-L317

From stan-dev mailing list:

Let's look into refactoring that into less of a hack.  We shouldn't be requiring
lp__ in anything downstream.   Feel free to bring these things up during
design, and we can look into redoing them as we go so we don't wind up with
a hack release that we want to fix later by getting rid of lp__.

- Bob

Example of printing output.csv with cmdstan's print script:

# stan_version_major = 2
# stan_version_minor = 6
# stan_version_patch = 3
# model = bernoulli_model
# method = experimental
#   experimental
#     variational
#       algorithm = meanfield (Default)
# meanfield
#       iter = 10000 (Default)
#       grad_samples = 1 (Default)
#       elbo_samples = 100 (Default)
#       eta_adagrad = 0.10000000000000001 (Default)
#       tol_rel_obj = 0.01 (Default)
#       eval_elbo = 100 (Default)
#       output_samples = 1000 (Default)
# id = 0 (Default)
# data
#   file = bernoulli.data.R
# init = 2 (Default)
# random
#   seed = 3959575278
# output
#   file = output.csv (Default)
#   diagnostic_file =  (Default)
#   refresh = 100 (Default)
lp,theta
0,0.221171
0,0.166458
0,0.297987
0,...
0,...
0,...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/stan/services/io/write_iteration_csv.hpp and the variational call in src/stan/variational/advi.hpp. Trace the write_iteration* callers and determine how the output path should work without requiring lp. Done means variational output no longer uses a placeholder lp value and the affected callers remain consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.