Skip to content

Instantly share code, notes, and snippets.

@SteveBronder
Last active October 15, 2020 14:47
Show Gist options
  • Save SteveBronder/0f6f39e27b954d6002004768b4234e7a to your computer and use it in GitHub Desktop.
Save SteveBronder/0f6f39e27b954d6002004768b4234e7a to your computer and use it in GitHub Desktop.

Stan 2.15 Release Notes

This release cycle is dedicated to some nice "slice of life" features for Stan users and developers.

First, for users we've started adding vectorized binary functions to the language. This means that users can now right code such as

 matrix[17, 93] u[12];
 matrix[17, 93] z[12];
 z = pow(u, 2.0);

which provides the same results as calling

for (i in 1:17) {
  for (j in 1:93) {
    for (k in 1:12) {
      z[i, j, k] = pow(u[i, j k], 2.0);
    }
  }
}

The official docs are not updated from 2.24 until the full release of 2.25 so until then you can find the list of binary vectorized functions here.

Other noticable user facing changes in the language functions include allong C0 in gaussian_dlm_obs_lpdf and gaussian_dlp_obs_rng to now be a positive semidefinite matrix and making binomial_lpmf work more reliably when the probability parameter is 0.0 or 1.0

For folks who have wanted to try out Stan's OpenCL GLM functions, we've rewritten them to accept parameters or data for any of their input arguments. Users will most likely have the easiest time accessing these through the cmdstan backend when working with brms generated models.

For cmdstan users we've added an option to control the significant figures for values when working with stansummary. Users can also now download specific stanc3 version and we fixed a little bug when building some boost related thing son MacOS.

An appropriate segue into the stan math changes, because of some things that changed in the backend users who utilize the ODE solvers in Stan may see a small performance decrease. To fix that you can add the STAN_COMPILER_OPTIMS flag to the make/local to turn on link time optimization for Stan which should remove any performance issues (turning this on can actually speed up some other Stan models).

The Stan math backend is undergoing a lot of changes at the moment (we've had 99 PRs since the lease release!). You can check them out in more detail in the individual notes below, but we've re-worked some major parts of Stan so that we can be wayy more efficient at matrix algebra. A lot of changes were focused around getting this to work while making sure there was not a serious performance hit to current stan programs and the fast stuff we are writing now gives the same numeric answers from our current methods.

@t4c1 figured out a wonderfully nice pattern for writing reverse mode autodiff functions which we call reverse_pass_callback(). reverse_pass_callback() breaks up the fact that reverse mode autodiff is

  1. Running the regular function
  2. Saving the data
  3. Adding a callback to a stack to calculate the adjoints in the reverse pass.

The pattern leads to some rather pretty code. It also leads to 15% speedup or so in some cases which is nice.

We've had to considerably beef up our test suite in order to handle all of the above, and we added sanitizers to all the tests as well now to make sure things are sque ̢͛e ͙̑ä͔͓́͞ķ̘̃͞y̲̥̑́ ̨̅c̨̲̝̟̞̓̾̀́̉l̜̞̘͈̔̋̓̓̆͝ͅͅ ͔̤̝̦̞̙͐͐̀́̕͡e̲͎͉͓͎͓̿͊̌̅͡͡ ͙̩̜̞͚̬͛̃̒̅͠͝ã͔̼͈͒̋̿̔̿͟ͅͅ ̧͚͉̱͉̻̈́̊͐̄̊̎ṅ̛̫̦͎͖̅͛̉͟͡ͅn͕̪͈̠͚̊͂̒̃̋͜͠n͖̖͇̺͇̯̎̈͛̓̇̕n̨̲͙͚͉̅́͒̀̕͡ͅ (̵͔͝s̵̢̑ê̷̳q̶̠͆ ̵͔̽f̷̣̿a̷̞̅u̷̺͠l̷̯͂ ̴̟́c̷̈́ͅo̸͖̊r̴̢̕e̷̩̓ ̷͔͑ḑ̷̒u̸̯̚m̴̌ͅp̵̪͊)̴̠̅

Bad jokes aside it's a lot of testing so seg faults and the like should have a much lower chance of getting near users.

These are a few of the highlights, but please check out the full release notes below for more details

@rok-cesnovar
Copy link

Please do. It should also include a oink to the release candidate I guess.

You can also copy the How to install section from my last post if you want: https://discourse.mc-stan.org/t/cmdstan-2-24-release-candidate-now-available/16818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment