stan-dev / stan-dev/math

Functions in prim/mat/fun that could use custom reverse mode autodiff implementations

Open
#989 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature good first issue
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

The functions listed here currently do not have custom reverse mode autodiff implementations.

Some of these functions would be easy and some would be hard. I'll be piecemeal working on sections of this pull in the coming weeks, so you should post a message here if you want to work on any of these so we'll stay coordinated.

The main reason many functions are included in this list is that they create a lot of varis on the chaining stack.

A lot of not-included functions (rep_matrix, sort_asc, fill, etc.) were not included because they didn't have large computational components

  • csr_matrix_times_vector -- Check discourse (at least https://discourse.mc-stan.org/t/sparse-matrix-roadmap/5493) before trying
  • csr_to_dense_matrix -- Edit: Looking at this (April 2020), I don't think this is a good target. Regular autodiff probably fast enough
  • cumulative_sum
  • diag_pre_multiply
  • diag_post_multiply
  • gp_dot_prod_cov
  • gp_exp_quad_cov
  • gp_matern52_cov
  • gp_periodic_cov
  • inverse
  • log_softmax
  • make_nu
  • mdivide_right
  • mdivide_right_ldlt
  • mdivide_right_spd
  • mdivide_right_tri
  • quad_form_diag
  • cholesky_corr_constrain
  • cholesky_factor_constrain
  • corr_matrix_constrain
  • cov_matrix_constrain
  • cov_matrix_constrain_lkj

Based on this test (https://discourse.mc-stan.org/t/adj-jac-apply/5163/6), I'm not sure these would be sped up with custom autodiff, but they don't have it implemented:

  • add
  • add_diag
  • divide
  • elt_multiply
  • elt_divide
  • minus
  • subtract

There are a couple other functions that could have custom autodiff but the math would not be easy mathematically:

  • eigenvalues_sym
  • eigenvectors_sym
  • singular_values

Current Math Version

v2.18.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 in prim/mat/fun and choose one unchecked function from the list; for csr_matrix_times_vector, review the linked sparse-matrix roadmap discussion first. Compare the target with the functions already marked complete and finish when the selected function has a custom reverse-mode autodiff implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.