Repository navigation
Reverse-mode grad_reg_inc_beta (part 2 of #3409) - #3489
Draft
SteveBronder wants to merge 1 commit into
Draft
SteveBronder wants to merge 1 commit into
SteveBronder wants to merge 1 commit into
Conversation
…pass Add the rev specialization of grad_reg_inc_beta and use it in rev inc_beta. The prim GRAD_RIB overload now excludes var arguments, which go to the rev overload. Add the rev and mix tests.
This was referenced Oct 26, 2026
Draft
SteveBronder
added a commit
that referenced
this pull request
Oct 26, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of 3 of the split of #3409. Stacked on #3409 (base
stable-inc-beta). Part 3, #3490, is stacked on this one.Summary
Adds a reverse-mode
grad_reg_inc_beta. Forvararguments the values are computed indoubleby the prim overload. The reverse pass computes theaandbadjoints directly asH v, whereHis the Hessian ofI_z(a, b)in(a, b), from the power series or the continued fraction, instead of taping through the loop. Thezadjoint is closed form. A one-sided request computes onlyH_aaorH_bbunless the cross term is needed.rev/fun/inc_beta.hppis rewritten withmake_callback_var. TheGRAD_RIBoverload of primgrad_reg_inc_betanow excludesvararguments, which go to the new rev overload. In #3409 alone it accepts every scalar type.The algorithm, the accuracy study and the benchmarks are in the description of #3409.
Files
stan/math/rev/fun/grad_reg_inc_beta.hpp(new)stan/math/rev/fun/inc_beta.hppstan/math/rev/fun.hppstan/math/prim/fun/grad_reg_inc_beta.hpp: therequire_all_not_var_ton theGRAD_RIBoverloadtest/unit/math/rev/fun/inc_beta_test.cpp(new): shape gradients ofinc_betawithvararguments at the defect points of More stable incomplete beta gradient roots #3409.test/unit/math/mix/fun/grad_reg_inc_beta_test.cpp,test/unit/math/mix/fun/inc_beta_test.cpp: mix tests, with the upper-bound test started from an empty autodiff stack.Release notes
See #3409.
Checklist
Copyright holder: Aalto University
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested