Skip to content

Use A42 instead of ITP in find_alpha#482

Merged
yebai merged 6 commits into
mainfrom
fix-find-alpha-roots-3.0.2
Jul 9, 2026
Merged

Use A42 instead of ITP in find_alpha#482
yebai merged 6 commits into
mainfrom
fix-find-alpha-roots-3.0.2

Conversation

@yebai

@yebai yebai commented Jul 8, 2026

Copy link
Copy Markdown
Member

Roots 3.0.2 made find_zero return NaN (→ ConvergenceFailed) when a bracketing method stops in a :not_converged state instead of returning the best endpoint. ITP hits this by stalling short of the unreachable eps^3 x-tolerance, breaking find_alpha.

A42 is superlinear like ITP but narrows to adjacent floats and converges via the exact-x path, working on both old and new Roots. The analytic AD rules remain unchanged (they depend only on the returned value being a root).

Roots 3.0.2 changed `decide_convergence` for bracketing methods to return
`NaN` (raising `ConvergenceFailed`) when the algorithm terminates in a
`:not_converged` state, instead of returning the best endpoint. `Roots.ITP`
can stall a few floats short of the (unreachable, `eps^3`) x-tolerance and
hits exactly this path, so `find_alpha` errored for many inputs.

`Roots.A42()` (Alefeld-Potra-Shi) is superlinear like ITP but narrows the
bracket down to adjacent floats and converges via the exact-x path, so it
works identically on both old and new Roots. The analytic AD rules are
unchanged: they depend only on the returned value being a root of the same
equation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
yebai and others added 2 commits July 8, 2026 22:39
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Bijectors.jl documentation for PR #482 is available at:
https://TuringLang.github.io/Bijectors.jl/previews/PR482/

@yebai

yebai commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@devmotion, can you help review this PR?

Distributions 0.25.129's bounded kernel-density samplers (Biweight, Cosine, …)
can return NaN, which propagated into the transform/logpdf/AD comparisons and
failed the `Biweight` interface test. Draw via a `randfinite` helper that
resamples until finite so the tests exercise Bijectors, not the upstream bug.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread test/interface.jl
using Bijectors
Random.seed!(123)

# Distributions 0.25.129's bounded kernel-density samplers (Biweight, Cosine, …) can

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a separate, unrelated test-fragility fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yebai yebai force-pushed the fix-find-alpha-roots-3.0.2 branch from d1f406a to 1ad685c Compare July 8, 2026 22:39
Comment thread src/vector/test_utils.jl Outdated
return "joint order statistic $(_name(d.dist)) with length $(length(d))"
end

# Some Distributions kernel-density samplers (Biweight, Cosine, …) return NaN in recent

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, a separate, unrelated test-fragility fix.

Recent Distributions releases break some samplers: the bounded kernel-density
distributions (Biweight, Triweight, Epanechnikov) return NaN, and Cosine's
quantile-based sampler throws `Roots.ConvergenceFailed` under Roots 3. Both
propagated into `test_all` (roundtrip, logjac, …) and failed the Vector and
ReverseDiff suites. Draw samples via a `randfinite` helper that resamples until
finite (retrying on NaN and on a thrown sampler error), matching the
`randfinite` approach used in the univariate interface tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yebai

yebai commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

I'm merging this as it (1) is fairly low risk, (2) it currently breaks other TuringLang tests.

@yebai yebai merged commit e0b11f8 into main Jul 9, 2026
19 of 21 checks passed
@yebai yebai deleted the fix-find-alpha-roots-3.0.2 branch July 9, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant