Release of CmdStan 2.33

We are very happy to announce that the 2.33.0 release of CmdStan is now available on GitHub! As usual, the release of CmdStan is accompanied by new releases of Stan Math, core Stan, and Stanc3. A PyStan update will follow shortly.

This new release brings two new exciting features that have been in the making for more than a year: a new Stan language type – tuples and a new algorithm – Pathfinder. The release also features some new functions – mostly related to tuples, and other minor improvements.

There are also a number of long-deprecated language features that have now become errors with this version.

Contributors, sponsors and donators

We would like to thank everyone who contributed to this release with their bug reports, feature or bug fix discussions, and code or code reviews. We would also like to thank all of our sponsors and donators who have supported us during this last release cycle and in years past. Thanks to the Flatiron Institute for providing us with the computing resources to run unit tests and build scripts for our repositories.

You can support Stan via NumFocus or the GitHub sponsorship program.

We would like to especially thank everyone who contributed to the Tuples and Pathfinder features that have been in the making for a long time (in alphabetical order):

Ryan Bernstein, Steve Bronder, Bob Carpenter, Andrew Gelman, Niko Huure, Mitzi Morris, Aki Vehtari, Brian Ward and Lu Zhang!

Release highlights

Tuples

The Stan language gained a new type: tuples!

For any sequence of types, Stan provides a tuple data type. For example,

tuple(real, array[5] int) xi;

declares xi to be a tuple holding two values, the first of which is of type type real and the second of which is a 5-dimensional array of type int. Tuples can be of arbitrary size. The values in a tuple can be of arbitrary type, but the component types must be declared along with the declaration of the tuple. Tuples can be manipulated as a whole, or their elements may be accessed and set individually.

Please see the tuples sections in the User’s Guide and Reference Manual for more details.

Pathfinder

A new Variational Inference algorithm is now available via CmdStan – Pathfinder!

Pathfinder is a variational method for approximately sampling from differentiable log densities. Starting from a random initialization, Pathfinder locates normal approximations to the target density along a quasi-Newton optimization path, with local covariance estimated using the inverse Hessian estimates produced by the L-BFGS optimizer. Pathfinder returns draws from the Gaussian approximation with the lowest estimated Kullback-Leibler (KL) divergence to the true posterior.

For more information see the Stan Reference Manual, the Pathfinder paper and Bob Carpenter’s tutorial.

The pathfinder algorithm is currently not available in the cmdstanpy/r interfaces. The developers are working on adding that support shortly (hopefully in the next days).

New functions and function signatures

The new functions are all more efficient tuple-using versions of existing functions:

eigendecompose(A) is equivalent to (eigenvectors(A), eigenvalues(A))

eigendecompose_sym(A) is equivalent to (eigenvectors_sym(A), eigenvalues_sym(A))

qr_thin(A) is equivalent to (qr_thin_Q(A), qr_thin_R(A))

qr(A) is equivalent to (qr_Q(A), qr_R(A))

svd(A) is equivalent to (svd_U(A), singular_values(A), svd_V(A))

csr_extract(A) is equivalent to (csr_extract_w(a), csr_extract_v(a), csr_extract_u(a))

These functions all return tuples and have a lower computational cost due to the shared work to produce multiple results. See Functions reference for more.

– added vectorized signatures for log_sum_exp

The function now supports all arguments that are typically supported in fully vectorized functions.

Deprecations

The following deprecations have been turned into errors:

– The old array syntax, e.g. int arr[5];. Use array[5] int arr; instead.

– Distribution functions ending in _log. Use either _lpdf or _lpmf.

– The functions binomial_coefficient_log, multiply_log, and cov_exp_quad. Use lchoose, lmultiply, and gp_exp_quad_cov respectively.

– The if_else function. Use the ternary operator cond ? true_value : false_value

– Use of CDFs with a , between the first and second argument. Use |.

– Comments beginning with #. Use //.

– Use of <- for assignment. Use =.

– The increment_log_prob function. Use the target += statement.

– The get_lp() function. Use target().

– The use of nested multi-indices on the left-hand side of an assignment statement.

For this version, these can all be automatically updated with the --canonicalize=deprecations argument to the auto-formatter. This is not guaranteed to work for versions following this one.

Additionally, the following identifiers are now reserved words: array, offset, multiplier, lower, and upper.

Other miscellaneous features

– The num_chains argument for running multiple chains with a single executable is now available to all HMC variants other than the static engine

– Improved accuracy of matrix_exp_multiply

– using the RDump input files now shows a warning – the RDump input files will not support tuples and are unlikely to support the other new types in the future. Please switch to using JSON files for inputs.

– Return statements now follow the same type of promotion rules as assignment and function argument passing.

How to install the new release?

Download the tar.gz file here, extract it, and use it the way you use any Cmdstan release. We also have an online Cmdstan guide available at https://mc-stan.org/docs/cmdstan-guide.

If you are using cmdstanpy you can install using

cmdstanpy.install_cmdstan()

With CmdStanR you can install using

cmdstanr::install_cmdstan()

One thought on “Release of CmdStan 2.33

  1. The Bob Carpenter Pathfinder video is on Youtube as “for kids”, which means I can’t save it to my “Watch Later”. I didn’t realize variational algorithms were “for kids”!

    Like

Leave a comment