Skip to content

Use the Bijectors batched RQS for nsf and drop MonotonicSplines#63

Draft
shravanngoswamii wants to merge 7 commits into
mainfrom
sg/nsf-bijectors-rqs
Draft

Use the Bijectors batched RQS for nsf and drop MonotonicSplines#63
shravanngoswamii wants to merge 7 commits into
mainfrom
sg/nsf-bijectors-rqs

Conversation

@shravanngoswamii

Copy link
Copy Markdown
Member

nsf now builds its rational quadratic splines with the batched RQS in Bijectors (rqs_params_from_raw, rqs_forward, rqs_inverse) instead of MonotonicSplines. That code is written with whole-array operations, so nsf trains under every supported AD backend and runs on the GPU. The Zygote-only restriction is gone, and MonotonicSplines is removed from the dependencies.

The NSF ELBO AD test now covers Zygote, ReverseDiff, Enzyme, and Mooncake (Float32 and Float64), all passing locally.

Depends on TuringLang/Bijectors.jl#485. Until that is released, Bijectors is pinned to the branch via [sources] in Project.toml. This resolves on Julia 1.11 and later; on 1.10 [sources] is ignored, so this stays draft until the Bijectors release is tagged and the compat is pinned to it.

The neural spline coupling now calls Bijectors.rqs_params_from_raw, rqs_forward, and
rqs_inverse, which are written with whole-array operations. nsf now trains under every
supported AD backend and runs on the GPU, so the Zygote-only restriction is gone.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	Project.toml
#	test/Project.toml
@github-actions

Copy link
Copy Markdown
Contributor

NormalizingFlows.jl documentation for PR #63 is available at:
https://TuringLang.github.io/NormalizingFlows.jl/previews/PR63/

shravanngoswamii and others added 5 commits July 19, 2026 11:20
The neural spline demo needs the batched RQS, which is not yet released, so the example
environment needs the same source pin as the main project.

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

Julia 1.10 ignores the [sources] pin, so the batched RQS was missing there. Enzyme
0.13.189 fails with an LLVM canonicalization error on 1.10; 0.13.188 is fine.

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

@leaf MvNormal now runs once in runtests.jl instead of inside every testset loop, and the
base distributions use an identity covariance instead of the deprecated vector-of-sigmas
form.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Enzyme 0.13.188 fails LLVM function verification when differentiating the batched RQS on
Julia 1.10 (Float64 only); the other backends pass there and Enzyme passes on 1.11+.

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

MvNormal(mu, I) builds an IsoNormal, and Enzyme crashes differentiating destructure over
that type. Diagonal(ones(T, 2)) keeps the exact DiagNormal the deprecated form produced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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