Skip to content

[WIP] Embedded Laplace Approximation #3097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 291 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
291 commits
Select commit Hold shift + click to select a range
0d29780
Temporary signature in agreement with parser.
charlesm93 Apr 9, 2021
d110e18
Fix bugs to run function from Stan.
charlesm93 Apr 16, 2021
0966258
prototype linesearch step.
charlesm93 Apr 21, 2021
ab69c98
prototype line search.
charlesm93 Apr 21, 2021
5c4b2e4
Update convergence criterion for linesearch.
charlesm93 Apr 21, 2021
8d45513
simplify the linesearch.
charlesm93 Apr 21, 2021
fcbf075
linesearch: check for non-finite values.
charlesm93 Apr 21, 2021
150f713
prototype Jarnos newton solver.
charlesm93 Apr 22, 2021
be9f880
prototype treatment of diagonal covariance.
charlesm93 Apr 28, 2021
47e2827
attempt at debug diagonal K case...
charlesm93 Apr 28, 2021
6bf438f
return int term.
charlesm93 Apr 28, 2021
9d9cffe
Merge remote-tracking branch 'origin/develop' into try-laplace_student
SteveBronder Sep 27, 2021
3985450
move some files around and cleanup tests. Comment out tests that do n…
SteveBronder Sep 28, 2021
77ad12a
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Oct 1, 2021
c1cf1b9
cleanup more of neg_binomial_2 tests
SteveBronder Oct 1, 2021
3f310e7
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Oct 1, 2021
36efe15
remove laplace vari to instead use reverse pass callback
SteveBronder Oct 4, 2021
bac6b0d
update poisson likelihood
SteveBronder Oct 4, 2021
769450f
update laplace ints
SteveBronder Oct 4, 2021
103c200
make
SteveBronder Oct 21, 2021
c2b2ae7
revert vari for laplace_density_vari
SteveBronder Dec 2, 2021
92e031f
Merge branch 'experimental/laplace' of https://github.com/stan-dev/ma…
charlesm93 Dec 2, 2021
805ae7f
formalize unit test for laplacr_marginal_poisson_log_pmf
charlesm93 Dec 2, 2021
2bcd90b
clean unit test for laplace_marginal_bernoulli_logit_lpmf.
charlesm93 Dec 3, 2021
d1d328f
start building unit test for laplace_marginal_lpdf_test.cpp
charlesm93 Dec 3, 2021
f73aec2
Add bernoulli_logit test for laplace_marginal_lpmf.
charlesm93 Dec 4, 2021
1592328
Add (incomplete) motorcycle GP test for laplacr_marginal_lpdf.
charlesm93 Dec 4, 2021
bc74943
rewrite laplace_marginal_poisson_log_lpmf to use the general likeliho…
charlesm93 Dec 5, 2021
6bf8246
(This time for real) Make laplace_marginal_log_lpmf use general likel…
charlesm93 Dec 5, 2021
b2e4b2f
make laplace_marginal_bernoulli_logit_lpmf use general likelihood fun…
charlesm93 Dec 6, 2021
031a81b
Delete research tests which are / will not be unit tests.
charlesm93 Dec 6, 2021
ae138fe
refactor rng test for laplace_poisson_log.
charlesm93 Jan 13, 2022
5231604
Benchmark laplace_poisson_log_rng against multi_normal_rng.
charlesm93 Jan 16, 2022
9e3f9ae
refactor rng poisson log to use full autodiff and add tests for expos…
charlesm93 Jan 16, 2022
f218ba0
Merge remote-tracking branch 'origin/develop' into experimental/laplace
SteveBronder Jan 27, 2022
0fc47f5
update tolerance for nearness tests
SteveBronder Jan 27, 2022
7a40142
update tolerance for nearness tests
SteveBronder Jan 27, 2022
a35ff32
cleanup laplace but failing address sanitizer
SteveBronder Jan 28, 2022
cfd2199
update off by one error
SteveBronder Jan 28, 2022
269b9af
Merge branch 'experimental/laplace' of https://github.com/stan-dev/ma…
charlesm93 Jan 28, 2022
d7e507f
clang format
SteveBronder Jan 28, 2022
c78c7d1
Merge branch 'experimental/laplace' of https://github.com/stan-dev/ma…
charlesm93 Jan 28, 2022
b1d8312
update to remove some extra functions and just call them inline
SteveBronder Jan 28, 2022
ce75b03
Merge branch 'experimental/laplace' of https://github.com/stan-dev/ma…
charlesm93 Jan 28, 2022
c7499b3
local changes for rng tests.
charlesm93 Jan 28, 2022
396278c
remove extra functions and have hessian_times_vector return a vector …
SteveBronder Jan 28, 2022
ef7d2a4
Merge branch 'experimental/laplace' of github.com:stan-dev/math into …
SteveBronder Jan 28, 2022
c6f222a
cleanup
SteveBronder Jan 29, 2022
fdcf8ca
clang format
SteveBronder Jan 29, 2022
a009b8f
remove the in/out parameters from hessian_block_diag and diff
SteveBronder Feb 3, 2022
ae6511e
removes in/out parameters from laplace_marginal_density_est
SteveBronder Feb 3, 2022
41a3d23
small fix in laplace_marginal eta adjoint
SteveBronder Feb 3, 2022
1f6199a
small cleanup
SteveBronder Feb 3, 2022
adcddca
swap x and phi to covariance functor
SteveBronder Feb 3, 2022
3b60f23
start working on variadic version of laplace
SteveBronder Feb 4, 2022
26c6a14
update laplace so it takes in variadic arguments for known likelihoods
SteveBronder Feb 5, 2022
03dd6e0
clang format
SteveBronder Feb 5, 2022
265991c
update tests
SteveBronder Feb 7, 2022
6b97f1f
Removes diagonal_covariance option and code. Also removes do_line_search
SteveBronder Feb 18, 2022
9c5e5ee
Merge remote-tracking branch 'origin/develop' into experimental/laplace
SteveBronder Mar 7, 2022
de38e18
add _tol_ versions of functions for laplace
SteveBronder Mar 9, 2022
31ab267
update with forwards
SteveBronder Mar 9, 2022
25e3ae8
update templates
SteveBronder Mar 9, 2022
c5d814c
update tol params
SteveBronder Mar 9, 2022
efb4662
default value for propto
SteveBronder Mar 9, 2022
f1a05d9
update
SteveBronder Mar 10, 2022
edb2e0d
update
SteveBronder Mar 10, 2022
8900bdb
update names for poisson_log with extra term
SteveBronder Apr 20, 2022
5d685b8
Merge remote-tracking branch 'origin/develop' into experimental/laplace
SteveBronder Apr 29, 2022
ea0e9be
Merge branch 'experimental/laplace' of https://github.com/stan-dev/ma…
charlesm93 May 18, 2022
cfa518a
update signature for rng test.
charlesm93 May 18, 2022
90d50cc
Make minimum hessian_block_size = 1, and treat this as the special di…
charlesm93 May 18, 2022
7bafe13
change TRUE to true and FALSE to false
SteveBronder May 20, 2022
04b17c5
update to develop
SteveBronder May 31, 2024
e76c980
Merge remote-tracking branch 'origin/develop' into experimental/laplace
SteveBronder Jul 22, 2024
6ed072f
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Jul 22, 2024
a33aba4
move laplace files around. Get expect ad to work for laplace
SteveBronder Jul 22, 2024
902cfff
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Jul 22, 2024
ae91da6
update
SteveBronder Jul 25, 2024
051c389
fix header includes
SteveBronder Jul 25, 2024
74d2ea2
update
SteveBronder Jul 25, 2024
4c0c815
update laplace_likelihood
SteveBronder Jul 26, 2024
a8a8257
update
SteveBronder Jul 26, 2024
e21b654
adds variadic args to laplace_likelihood member functions
SteveBronder Jul 26, 2024
784de61
remove laplace_likelihood struct and now just use a namespace
SteveBronder Jul 29, 2024
fa1dad8
cleanup
SteveBronder Jul 30, 2024
1ea25be
cleanup
SteveBronder Jul 30, 2024
51106c3
update
SteveBronder Jul 30, 2024
0e3eb28
clang-format
SteveBronder Jul 30, 2024
d8f95ba
update docs
SteveBronder Aug 5, 2024
f4048ea
Merge commit 'f120c5e8e86c473f64ab222613e173acfa2648de' into HEAD
yashikno Aug 6, 2024
1f05474
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Aug 6, 2024
a78d42c
test headers and cpplint
SteveBronder Aug 6, 2024
6301e37
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Aug 6, 2024
a8be255
update
SteveBronder Aug 6, 2024
846cbbc
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Aug 6, 2024
dceaf5b
update test names
SteveBronder Aug 6, 2024
4dc95e9
update docs
SteveBronder Aug 6, 2024
c2b9ed2
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Aug 6, 2024
0b1cec2
force c++17
SteveBronder Aug 6, 2024
4bb62ea
remove double fvar grad in compute_s2
SteveBronder Aug 15, 2024
746a6f2
remove double fvar grad in compute_s2
SteveBronder Aug 15, 2024
9b1311b
begin work on doxygen doc for integrated Laplace.
charlesm93 Nov 21, 2024
3aebc38
fixes
SteveBronder Nov 22, 2024
a4f19b8
update so that diff for laplace returns seperate vectors for theta an…
SteveBronder Nov 25, 2024
9661cfd
correct argument order for laplace_marginal_est functions
SteveBronder Nov 26, 2024
cb3ee75
update laplace api functions to move msgs to the end of functions
SteveBronder Nov 26, 2024
5bfb544
fix merge conflicts
SteveBronder Nov 26, 2024
1033438
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Nov 26, 2024
3902c8a
update to remove most of eta var. Need to remove vector squash of 'et…
SteveBronder Dec 3, 2024
c1f314e
tests pass with eta in ll_args
SteveBronder Dec 4, 2024
fa53ee0
error on clang for tuple_cat
SteveBronder Dec 5, 2024
0a61a69
all tests pass
SteveBronder Dec 6, 2024
17d0250
all tests pass
SteveBronder Dec 6, 2024
ce26807
Add custom tuple_concat to avoid apple std lib compiler bug
SteveBronder Dec 6, 2024
d281f56
Fix tests with one error at the end giving a nan
SteveBronder Dec 9, 2024
071c22c
shows bug for normal approx
SteveBronder Dec 11, 2024
00e1dd2
shows bug for normal approx
SteveBronder Dec 11, 2024
b61d4bc
normal lpdf example is blowing up
SteveBronder Dec 11, 2024
7c90697
normal lpdf example is blowing up
SteveBronder Dec 11, 2024
828df03
normal lpdf example is blowing up
SteveBronder Dec 11, 2024
0ad0580
update so tests that should fail do. Need to catch bad conditions
SteveBronder Jan 15, 2025
abc910d
add catches for places we have known errors in estimation
SteveBronder Feb 5, 2025
4d9fb11
Merge remote-tracking branch 'origin/develop' into laplace/remove-eta…
SteveBronder Mar 14, 2025
b6c6646
update tests
SteveBronder Mar 17, 2025
d76b4e4
start building unit test for negative binomial likelihood.
charlesm93 Mar 21, 2025
edfbd7f
fixes promotion in diff_eta_implicit
SteveBronder Mar 21, 2025
9d14329
Merge branch 'fixme_negbinomial' of https://github.com/stan-dev/math …
charlesm93 Mar 21, 2025
bed18c2
tests for neg_binomial_lpmf.
charlesm93 Mar 21, 2025
f11c8cb
unit tests for laplace marginal with neg binomial.
charlesm93 Mar 24, 2025
0260141
update laplace_marginal_poisson signature and unit tests.
charlesm93 Mar 24, 2025
394776b
unit test for laplace_marginal_poisson signature.
charlesm93 Mar 24, 2025
ef12921
unit test for laplace marginal with poisson likelihood.
charlesm93 Mar 24, 2025
506076a
wrap unit tests for poisson likelihood rng.
charlesm93 Mar 24, 2025
8424eef
add laplce_neg_binomial rng and unit test.
charlesm93 Mar 25, 2025
39272d6
clean doxygen doc for laplace functions.
charlesm93 Mar 25, 2025
020b985
update tests
SteveBronder Mar 25, 2025
07fa51e
update
SteveBronder Mar 25, 2025
f8f9afb
update
SteveBronder Mar 25, 2025
ca798e6
Merge commit '59c00146f918ea5ee4702d8980d93a7871364da2' into HEAD
yashikno Mar 25, 2025
4e81eb8
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Mar 25, 2025
126fd65
fix cpplint issues
SteveBronder Mar 26, 2025
29889cb
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Mar 26, 2025
6148791
fix cpplint issues
SteveBronder Mar 26, 2025
f97a138
Merge remote-tracking branch 'refs/remotes/origin/experimental/laplac…
SteveBronder Mar 26, 2025
1b541fb
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Mar 26, 2025
2c0fbea
add test for filter_tuple. vectorize neg_binomial_2 for laplace
SteveBronder Mar 26, 2025
b570348
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Mar 26, 2025
d307ef8
update tests with tolerances
SteveBronder Mar 28, 2025
41870b5
Merge commit 'bc4b4bc37ff87ea3466e295bb4edd36bd16d3abf' into HEAD
yashikno Mar 28, 2025
b6a63b6
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Mar 28, 2025
78ce5d2
remove lldb files
SteveBronder Mar 28, 2025
4a7b727
Merge remote-tracking branch 'origin' into experimental/laplace
SteveBronder Mar 28, 2025
5a0b12d
Merge remote-tracking branch 'origin/experimental/laplace' into exper…
SteveBronder Mar 28, 2025
7abfbbf
fix test name
SteveBronder Mar 31, 2025
e187c11
update tests to not print
SteveBronder Mar 31, 2025
8073e3b
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Mar 31, 2025
cfe6799
make arena_tuple_t for tuples holding arena types
SteveBronder Mar 31, 2025
e5e3870
merge to develop
SteveBronder Mar 31, 2025
67f8851
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Mar 31, 2025
9880d4c
adds tuple tests for laplace functions
SteveBronder Apr 1, 2025
10995fc
update
SteveBronder Apr 7, 2025
1a2d41d
update to only make copies at the top level of laplace_marginal_density
SteveBronder Apr 8, 2025
a125b2f
Bug in collect_adjoints type deduction for accumulation of adjoints f…
SteveBronder Apr 9, 2025
4acef97
adds laplace_marginal_neg_binomial_log_summary_lpmf with associated t…
SteveBronder Apr 16, 2025
7c06158
Merge commit '72ec4316bc90ae5dd804808f2fe10e3a2ea109f1' into HEAD
yashikno Apr 16, 2025
a23525a
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 16, 2025
29c14d5
found bugs in gp motorcycle laplace test
SteveBronder Apr 16, 2025
47699f1
update tests
SteveBronder Apr 17, 2025
9a32716
change name of laplace_marginal_lpdf to laplace_marginal
SteveBronder Apr 17, 2025
54e1640
change name of laplace rng funcs
SteveBronder Apr 17, 2025
d16640d
update laplace rng names
SteveBronder Apr 17, 2025
e5bcf48
make changees to rng insides to not support predict
SteveBronder Apr 17, 2025
5bf5269
update
SteveBronder Apr 18, 2025
34ed4a9
Merge commit '50f131363ab1a68f937163221171b4bf53ee6448' into HEAD
yashikno Apr 18, 2025
b34c8ce
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 18, 2025
f2c5521
update with cpplint fixes
SteveBronder Apr 18, 2025
b12a4a8
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 18, 2025
d285bdc
update with cpplint fixes
SteveBronder Apr 18, 2025
3473dd2
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 18, 2025
4f20d1d
update with cpplint fixes
SteveBronder Apr 18, 2025
6a580a2
update
SteveBronder Apr 18, 2025
ec6044d
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 18, 2025
8367267
fixing headers for laplace_likelihood
SteveBronder Apr 21, 2025
77de4c1
fixing headers for laplace_likelihood
SteveBronder Apr 21, 2025
cd40f0c
fixing headers for laplace_likelihood
SteveBronder Apr 21, 2025
8271940
fixing headers for laplace_likelihood
SteveBronder Apr 21, 2025
3494538
fixing headers for laplace_likelihood
SteveBronder Apr 21, 2025
8f176a6
fixing headers for laplace_likelihood
SteveBronder Apr 21, 2025
b85456a
fixing headers for laplace_likelihood
SteveBronder Apr 21, 2025
9da8a4d
fixing headers for laplace_likelihood
SteveBronder Apr 21, 2025
a32e8de
update to_ref test
SteveBronder Apr 24, 2025
0741add
Merge commit '8efa5078fe3b67993f04e5e77029af7c95f827ac' into HEAD
yashikno Apr 24, 2025
79690f7
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 24, 2025
2cdd2bc
for laplace: add eval to solver==1 for s2_tmp
SteveBronder Apr 24, 2025
c338e32
Merge remote-tracking branch 'refs/remotes/origin/experimental/laplac…
SteveBronder Apr 24, 2025
bab31e2
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 24, 2025
a8096f5
remove extra template for nested_rev_autodiff. Cleanup filter_map tes…
SteveBronder Apr 25, 2025
8a9a42a
Merge commit 'c2d742216f67da7c481416c1e786834861696a53' into HEAD
yashikno Apr 25, 2025
4e7afb4
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 25, 2025
7d5db81
update neg_binomial laplace signature for map matrix types
SteveBronder Apr 25, 2025
10b5945
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 25, 2025
cbcffc7
remove conditional nothrow spec
SteveBronder Apr 25, 2025
b71d1d4
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 25, 2025
480e2f3
have laplace_lpdf test for tuples of tuples
SteveBronder Apr 25, 2025
987bc87
Merge remote-tracking branch 'refs/remotes/origin/experimental/laplac…
SteveBronder Apr 25, 2025
8195841
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 25, 2025
b7cd490
update laplace_marginal tests with tuples
SteveBronder Apr 25, 2025
b4136f8
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 25, 2025
c3d0413
remove compile trace file
SteveBronder Apr 25, 2025
8f7a53c
Merge remote-tracking branch 'refs/remotes/origin/experimental/laplac…
SteveBronder Apr 25, 2025
df95f38
add meta function for iterating over elements of multiple tuples
SteveBronder Apr 25, 2025
bbdb5b4
Merge commit '208340f030d6c397af645c378bfed22019ce652c' into HEAD
yashikno Apr 25, 2025
d2ada82
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 25, 2025
acd2e33
simplify value_of and value_of_rec to just be one function with if co…
SteveBronder Apr 28, 2025
15a9a72
simplify value_of and value_of_rec to just be one function with if co…
SteveBronder Apr 28, 2025
4c18336
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 28, 2025
4639bc4
simplify value_of and value_of_rec to just be one function with if co…
SteveBronder Apr 28, 2025
a8429db
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 28, 2025
864fb71
Fix Eigen sparse type trait for arena_matrix
SteveBronder Apr 28, 2025
8090488
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 28, 2025
3af50a6
add base_type for matrix_cl
SteveBronder Apr 28, 2025
defef7e
Merge commit '01fa440c47b8fcb7cde4d358305e755785576571' into HEAD
yashikno Apr 28, 2025
ee1330f
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 28, 2025
5c9d85c
fix value_of and value_of_rec to return the correct value types
SteveBronder Apr 28, 2025
4fb32d3
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 28, 2025
b23b56f
fix value_of and value_of_rec to return the correct value types
SteveBronder Apr 28, 2025
ef592d9
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 28, 2025
7eb7e44
change auto& to auto&& in make_holder function lambdas
SteveBronder Apr 28, 2025
a90b39f
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 28, 2025
107debf
cpplint
SteveBronder Apr 28, 2025
d70501a
update const auto& in binary_op
SteveBronder Apr 28, 2025
fc87a12
fixes for holder.cpp
SteveBronder Apr 29, 2025
15c18f7
move msgs before the variadic arguments in laplace likelihood inner f…
SteveBronder Apr 29, 2025
e94033a
use map for laplace funcs and fix bug in value_of
SteveBronder Apr 29, 2025
12c6259
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 29, 2025
b9f782b
use map for laplace funcs and fix bug in value_of
SteveBronder Apr 29, 2025
a1d867b
fix docs
SteveBronder Apr 29, 2025
eb22a6c
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 29, 2025
98dd99c
fix templates for hessian_times_vector
SteveBronder Apr 29, 2025
4565265
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 29, 2025
176259b
fix hessian_times_vector signature
SteveBronder Apr 30, 2025
37279c4
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 30, 2025
34daf24
update laplace tests to use a functor for iterating over solver params
SteveBronder Apr 30, 2025
aae3402
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot Apr 30, 2025
c14014a
move laplace tests to their own higher level folder for testing on je…
SteveBronder May 1, 2025
5159c28
fix headers
SteveBronder May 1, 2025
0aaed66
cleanup and testing different line searches
SteveBronder May 6, 2025
80e78d8
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot May 6, 2025
3178c6c
update docs
SteveBronder May 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ benchmarks/*.csv
*.o-*
*.exe
*.a
# mac debug folders
*.dSYM/

# Intel template building blocks (TBB)
lib/tbb
Expand Down
25 changes: 25 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,31 @@ pipeline {
}
post { always { retry(3) { deleteDir() } } }
}
stage('Laplace Unit Tests') {
agent {
docker {
image 'stanorg/ci:gpu-cpp17'
label 'linux'
args '--cap-add SYS_PTRACE'
}
}
when {
expression {
!skipRemainingStages
}
}
steps {
unstash 'MathSetup'
sh "echo CXXFLAGS += -fsanitize=address -march=native -mtune=native >> make/local"
script {
if (!(params.optimizeUnitTests || isBranch('develop') || isBranch('master'))) {
sh "echo O=3 >> make/local"
}
runTests("test/unit/math/laplace/*_test.cpp", false)
}
}
post { always { retry(3) { deleteDir() } } }
}
stage('OpenCL GPU tests') {
agent {
docker {
Expand Down
3 changes: 3 additions & 0 deletions stan/math/fwd/meta/is_fvar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ struct is_fvar<T,
std::enable_if_t<internal::is_fvar_impl<std::decay_t<T>>::value>>
: std::true_type {};

template <typename T>
inline constexpr bool is_fvar_v = is_fvar<T>::value;

} // namespace stan
#endif
6 changes: 6 additions & 0 deletions stan/math/mix.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef STAN_MATH_MIX_HPP
#define STAN_MATH_MIX_HPP

#include <stan/math/fwd/fun/Eigen_NumTraits.hpp>
#include <stan/math/rev/core/Eigen_NumTraits.hpp>
#include <stan/math/prim/fun/Eigen.hpp>

#include <stan/math/mix/meta.hpp>
#include <stan/math/mix/fun.hpp>
#include <stan/math/mix/functor.hpp>
Expand All @@ -26,4 +30,6 @@

#include <stan/math/prim.hpp>

#include <stan/math/mix/prob.hpp>

#endif
7 changes: 5 additions & 2 deletions stan/math/mix/functor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
#define STAN_MATH_MIX_FUNCTOR_HPP

#include <stan/math/mix/functor/derivative.hpp>
#include <stan/math/mix/functor/finite_diff_grad_hessian.hpp>
#include <stan/math/mix/functor/finite_diff_grad_hessian_auto.hpp>
#include <stan/math/mix/functor/finite_diff_grad_hessian.hpp>
#include <stan/math/mix/functor/grad_hessian.hpp>
#include <stan/math/mix/functor/grad_tr_mat_times_hessian.hpp>
#include <stan/math/mix/functor/gradient_dot_vector.hpp>
#include <stan/math/mix/functor/hessian.hpp>
#include <stan/math/mix/functor/laplace_base_rng.hpp>
#include <stan/math/mix/functor/laplace_likelihood.hpp>
#include <stan/math/mix/functor/laplace_marginal_density.hpp>
#include <stan/math/mix/functor/hessian_block_diag.hpp>
#include <stan/math/mix/functor/hessian_times_vector.hpp>
#include <stan/math/mix/functor/partial_derivative.hpp>

#endif
4 changes: 2 additions & 2 deletions stan/math/mix/functor/derivative.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef STAN_MATH_MIX_FUNCTOR_DERIVATIVE_HPP
#define STAN_MATH_MIX_FUNCTOR_DERIVATIVE_HPP

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/rev/core.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <vector>

namespace stan {
Expand All @@ -21,7 +21,7 @@ namespace math {
* @param[out] dfx_dx Value of derivative
*/
template <typename T, typename F>
void derivative(const F& f, const T& x, T& fx, T& dfx_dx) {
inline void derivative(const F& f, const T& x, T& fx, T& dfx_dx) {
fvar<T> x_fvar = fvar<T>(x, 1.0);
fvar<T> fx_fvar = f(x_fvar);
fx = fx_fvar.val_;
Expand Down
8 changes: 4 additions & 4 deletions stan/math/mix/functor/finite_diff_grad_hessian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ namespace math {
* @param[in] epsilon perturbation size
*/
template <typename F>
void finite_diff_grad_hessian(const F& f, const Eigen::VectorXd& x, double& fx,
Eigen::MatrixXd& hess,
std::vector<Eigen::MatrixXd>& grad_hess_fx,
double epsilon = 1e-04) {
inline void finite_diff_grad_hessian(const F& f, const Eigen::VectorXd& x,
double& fx, Eigen::MatrixXd& hess,
std::vector<Eigen::MatrixXd>& grad_hess_fx,
double epsilon = 1e-04) {
int d = x.size();
grad_hess_fx.clear();

Expand Down
6 changes: 3 additions & 3 deletions stan/math/mix/functor/finite_diff_grad_hessian_auto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ namespace math {
* @param[out] grad_hess_fx gradient of Hessian of function at argument
*/
template <typename F>
void finite_diff_grad_hessian_auto(const F& f, const Eigen::VectorXd& x,
double& fx, Eigen::MatrixXd& hess,
std::vector<Eigen::MatrixXd>& grad_hess_fx) {
inline void finite_diff_grad_hessian_auto(
const F& f, const Eigen::VectorXd& x, double& fx, Eigen::MatrixXd& hess,
std::vector<Eigen::MatrixXd>& grad_hess_fx) {
int d = x.size();

grad_hess_fx.clear();
Expand Down
4 changes: 2 additions & 2 deletions stan/math/mix/functor/grad_hessian.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef STAN_MATH_MIX_FUNCTOR_GRAD_HESSIAN_HPP
#define STAN_MATH_MIX_FUNCTOR_GRAD_HESSIAN_HPP

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/rev/core.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stdexcept>
#include <vector>

Expand Down Expand Up @@ -39,7 +39,7 @@ namespace math {
* @param[out] grad_H Gradient of the Hessian of function at argument
*/
template <typename F>
void grad_hessian(
inline void grad_hessian(
const F& f, const Eigen::Matrix<double, Eigen::Dynamic, 1>& x, double& fx,
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& H,
std::vector<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> >&
Expand Down
6 changes: 3 additions & 3 deletions stan/math/mix/functor/grad_tr_mat_times_hessian.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#ifndef STAN_MATH_MIX_FUNCTOR_GRAD_TR_MAT_TIMES_HESSIAN_HPP
#define STAN_MATH_MIX_FUNCTOR_GRAD_TR_MAT_TIMES_HESSIAN_HPP

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/mix/functor/gradient_dot_vector.hpp>
#include <stan/math/rev/core.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stdexcept>
#include <vector>

namespace stan {
namespace math {

template <typename F>
void grad_tr_mat_times_hessian(
inline void grad_tr_mat_times_hessian(
const F& f, const Eigen::Matrix<double, Eigen::Dynamic, 1>& x,
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& M,
Eigen::Matrix<double, Eigen::Dynamic, 1>& grad_tr_MH) {
Expand All @@ -26,7 +26,7 @@ void grad_tr_mat_times_hessian(

Matrix<var, Dynamic, 1> x_var(x.size());
for (int i = 0; i < x.size(); ++i) {
x_var(i) = x(i);
x_var.coeffRef(i) = x(i);
}

Matrix<fvar<var>, Dynamic, 1> x_fvar(x.size());
Expand Down
10 changes: 5 additions & 5 deletions stan/math/mix/functor/gradient_dot_vector.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef STAN_MATH_MIX_FUNCTOR_GRADIENT_DOT_VECTOR_HPP
#define STAN_MATH_MIX_FUNCTOR_GRADIENT_DOT_VECTOR_HPP

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/rev/core.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <vector>

namespace stan {
namespace math {

template <typename T1, typename T2, typename F>
void gradient_dot_vector(const F& f,
const Eigen::Matrix<T1, Eigen::Dynamic, 1>& x,
const Eigen::Matrix<T2, Eigen::Dynamic, 1>& v, T1& fx,
T1& grad_fx_dot_v) {
inline void gradient_dot_vector(const F& f,
const Eigen::Matrix<T1, Eigen::Dynamic, 1>& x,
const Eigen::Matrix<T2, Eigen::Dynamic, 1>& v,
T1& fx, T1& grad_fx_dot_v) {
using Eigen::Matrix;
Matrix<fvar<T1>, Eigen::Dynamic, 1> x_fvar(x.size());
for (int i = 0; i < x.size(); ++i) {
Expand Down
9 changes: 5 additions & 4 deletions stan/math/mix/functor/hessian.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef STAN_MATH_MIX_FUNCTOR_HESSIAN_HPP
#define STAN_MATH_MIX_FUNCTOR_HESSIAN_HPP

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/rev/core.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stdexcept>

namespace stan {
Expand Down Expand Up @@ -39,9 +39,10 @@ namespace math {
* @param[out] H Hessian of function at argument
*/
template <typename F>
void hessian(const F& f, const Eigen::Matrix<double, Eigen::Dynamic, 1>& x,
double& fx, Eigen::Matrix<double, Eigen::Dynamic, 1>& grad,
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& H) {
inline void hessian(const F& f,
const Eigen::Matrix<double, Eigen::Dynamic, 1>& x,
double& fx, Eigen::Matrix<double, Eigen::Dynamic, 1>& grad,
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& H) {
H.resize(x.size(), x.size());
grad.resize(x.size());

Expand Down
56 changes: 56 additions & 0 deletions stan/math/mix/functor/hessian_block_diag.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef STAN_MATH_MIX_FUNCTOR_HESSIAN_BLOCK_DIAG_HPP
#define STAN_MATH_MIX_FUNCTOR_HESSIAN_BLOCK_DIAG_HPP

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/mix/functor/hessian_times_vector.hpp>

namespace stan {
namespace math {

/**
* Returns a block diagonal Hessian by computing the relevant directional
* derivatives and storing them in a matrix.
* For m the size of each block, the operations const m calls to
* hessian_times_vector, that is m forward sweeps and m reverse sweeps.
* @tparam F Type of function to differentiate.
* @tparam Eta Type of additional arguments passed to F.
* @tparam Args Type of variadic arguments passed to F.
* @param f Function to differentiate.
* @param x Arguments with respect to which we differentiate.
* @param eta Additional arguments for f.
* @param hessian_block_size
* @param args Additional variadic arguments for f.
*/
template <typename F, typename... Args>
inline Eigen::SparseMatrix<double> hessian_block_diag(
F&& f, const Eigen::VectorXd& x, const Eigen::Index hessian_block_size,
Args&&... args) {
using Eigen::MatrixXd;
using Eigen::VectorXd;

const Eigen::Index x_size = x.size();
Eigen::SparseMatrix<double> H(x_size, x_size);
H.reserve(Eigen::VectorXi::Constant(x_size, hessian_block_size));
VectorXd v(x_size);
Eigen::Index n_blocks = x_size / hessian_block_size;
Eigen::VectorXd Hv = Eigen::VectorXd::Zero(x_size);
for (Eigen::Index i = 0; i < hessian_block_size; ++i) {
v.setZero();
for (Eigen::Index j = i; j < x_size; j += hessian_block_size) {
v.coeffRef(j) = 1;
}
hessian_times_vector(f, Hv, x, v, args...);
for (int j = 0; j < n_blocks; ++j) {
for (int k = 0; k < hessian_block_size; ++k) {
H.insert(k + j * hessian_block_size, i + j * hessian_block_size)
= Hv(k + j * hessian_block_size);
}
}
}
return H;
}

} // namespace math
} // namespace stan

#endif
41 changes: 33 additions & 8 deletions stan/math/mix/functor/hessian_times_vector.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#ifndef STAN_MATH_MIX_FUNCTOR_HESSIAN_TIMES_VECTOR_HPP
#define STAN_MATH_MIX_FUNCTOR_HESSIAN_TIMES_VECTOR_HPP

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/rev/core.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stdexcept>
#include <vector>

namespace stan {
namespace math {

template <typename F>
void hessian_times_vector(const F& f,
const Eigen::Matrix<double, Eigen::Dynamic, 1>& x,
const Eigen::Matrix<double, Eigen::Dynamic, 1>& v,
double& fx,
Eigen::Matrix<double, Eigen::Dynamic, 1>& Hv) {
inline void hessian_times_vector(
const F& f, const Eigen::Matrix<double, Eigen::Dynamic, 1>& x,
const Eigen::Matrix<double, Eigen::Dynamic, 1>& v, double& fx,
Eigen::Matrix<double, Eigen::Dynamic, 1>& Hv) {
using Eigen::Matrix;

// Run nested autodiff in this scope
Expand All @@ -35,10 +34,13 @@ void hessian_times_vector(const F& f,
Hv(i) = x_var(i).adj();
}
}
template <typename T, typename F>

template <typename T, typename F, typename EigVec,
require_eigen_vector_t<EigVec>* = nullptr,
require_stan_scalar_t<T>* = nullptr>
void hessian_times_vector(const F& f,
const Eigen::Matrix<T, Eigen::Dynamic, 1>& x,
const Eigen::Matrix<T, Eigen::Dynamic, 1>& v, T& fx,
const EigVec& v, T& fx,
Eigen::Matrix<T, Eigen::Dynamic, 1>& Hv) {
using Eigen::Matrix;
Matrix<T, Eigen::Dynamic, 1> grad;
Expand All @@ -47,6 +49,29 @@ void hessian_times_vector(const F& f,
Hv = H * v;
}

/**
* Overload Hessian_times_vector function, under stan/math/mix/functor
* to handle functions which take in arguments
* and pstream.
*/
template <typename F, typename XAdj, typename XVec, typename VVec,
typename... Args,
require_all_eigen_vector_t<XAdj, XVec, VVec>* = nullptr>
inline void hessian_times_vector(const F& f, XAdj& x_adj, XVec&& x, VVec&& v,
Args&&... args) {
nested_rev_autodiff nested;
const Eigen::Index x_size = x.size();
Eigen::Matrix<var, Eigen::Dynamic, 1> x_var = std::forward<XVec>(x);
Eigen::Matrix<fvar<var>, Eigen::Dynamic, 1> x_fvar(x_size);
for (Eigen::Index i = 0; i < x_size; i++) {
x_fvar(i) = fvar<var>(x_var(i), v(i));
}
fvar<var> fx_fvar = f(x_fvar, args...);
grad(fx_fvar.d_.vi_);
x_adj = x_var.adj();
}

} // namespace math
} // namespace stan

#endif
Loading