Skip to content

Batched, GPU-capable rational quadratic spline - #485

Draft
shravanngoswamii wants to merge 11 commits into
mainfrom
sg/batched-gpu-rqs
Draft

Batched, GPU-capable rational quadratic spline#485
shravanngoswamii wants to merge 11 commits into
mainfrom
sg/batched-gpu-rqs

Conversation

@shravanngoswamii

@shravanngoswamii shravanngoswamii commented Jul 18, 2026

Copy link
Copy Markdown
Member

Draft. Adds a batched, GPU-capable rational quadratic spline that works with any AD backend, no hand-written derivative rules. Goal is for NormalizingFlows nsf to use it instead of MonotonicSplines.

Built as plain array operations (reduction bin-search, differentiable gather, fused broadcast) so it runs on Array and CuArray from one code path and every backend differentiates it directly.

Progress:

  • parameter constraints + raw-NN builder
  • batched forward (value + log-det)
  • batched inverse
  • BatchedRQS bijector type + interface
  • AD equivalence: ForwardDiff, ReverseDiff, Mooncake, Enzyme (batched RQS cases added to the integration suites); Zygote verified through the nsf consumer
  • GPU test suite under test/gpu, run on the buildkite cuda queue
  • NormalizingFlows nsf drop-in: Use the Bijectors batched RQS for nsf and drop MonotonicSplines NormalizingFlows.jl#63

CPU tests pass locally (1125 value checks over Float32/Float64, plus the AD suites). GPU tests run on CI.

shravanngoswamii and others added 3 commits July 18, 2026 23:10
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

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

shravanngoswamii and others added 6 commits July 19, 2026 01:42
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…uild it

ReverseDiff returns the constrained parameter arrays as different tracked types, which
a single shared type parameter rejected.

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

The linear index is now fused into one broadcast with the bin array, instead of adding a
host offset array to a device index, which would fail under CUDA.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Checks device execution without scalar indexing, host/device agreement, and that the
Zygote gradient on the GPU matches the CPU.

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

The unit and zero endpoint rows were created with fill!, which Zygote rejects. They are now
built by broadcasting, keeping the array type and every AD backend working.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
shravanngoswamii and others added 2 commits July 19, 2026 03:20
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Row and column indices came from reshaped host ranges, which cannot broadcast against a GPU
array. They are now built from the bin array with cumsum, keeping the whole gather on device.

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