Repository navigation
Make B-spline evaluation allocation-free and usable on CUDA - #110
asinghvi17 wants to merge 2 commits into
Conversation
- Make the B-spline degree a type parameter of BSplineInterpolationDimension (the `degree` field is kept), so the basis function tuples have a static length. Scalar evaluation no longer allocates and compiles for the GPU. - Store the interpolation dimension tuple type in NDInterpolation, so that dimensions with different degrees stay concretely typed, and use `map` over the dimensions where they can differ in type. - Replace `prod(f, 1:N_in)` with a product over an `ntuple`, avoiding the dynamic empty-range branch that fails GPU compilation. - Skip the knot validation in `adapt_structure`, which only moves data that was validated on construction (and may not be readable from the host). - Add CUDA tests (evaluation and partial derivatives up to 3rd order for 1D, 2D and 3D cubic B-splines) and a CPU zero-allocation test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Harness: claude Model: claude-opus-5-5 Factory-Task: 215cd073-3a5b-404f-b97c-153676cf404c Agent-Harness: Claude 2.1.301 Agent-Model: claude-opus-5-5 Agent-Session: factory task 215cd073-3a5b-404f-b97c-153676cf404c on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
GPU: one testset per dimension, each comparing values and partials of order 1, mixed order 2 and order 3 against the CPU, including one out-of-range point. CPU: a single zero-allocation testset over uniform and mixed degree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com> Harness: claude Model: claude-opus-5-5 Factory-Task: 2114a827-9ca7-4bd5-8c44-bed4e0d9e6fb Agent-Harness: Claude 2.1.301 Agent-Model: claude-opus-5-5 Agent-Session: factory task 2114a827-9ca7-4bd5-8c44-bed4e0d9e6fb on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Independent review (Codex CLI v0.164.0 / gpt-6.1-sol), reviewer session 01a1cd75-4808-7891-b323-2ac139839ab8, reviewed head 1c28d74
This is a blind code-only review by a session other than the PR author's, copied below from the reviewer's report with only the grading metadata removed. The posting agent did not re-run the reviewer's commands. A MERGE verdict is advice; merging is left to the maintainers. CI: CI unreadable; review only; merge gates unchanged Riskmedium-low (ML3: measured allocation/performance improvement in scalar B-spline evaluation; independent numerical and GPU scalar checks pass) Blocking findingsNone.
Non-blocking findings
What I ran
What I did not verify
🤖 Posted by an AI agent — harness: Claude Code 2.1.322 · model: claude-sonnet-5-5 |
🤖 Automated comment from an AI agent running as @asinghvi17 — not written or reviewed by Anshul.
Makes B-spline evaluation work inside CUDA kernels and broadcasts, and makes scalar CPU evaluation allocation-free (was ~5 KB per call).
BSplineInterpolationDimension, andNDInterpolationstores its concrete dimension tuple type, so mixed degrees stay type-stable.prod(f, 1:N_in)becomes a product over anntuple, which avoids anInvalidIRErroron GPU.adapt_structureskips knot validation.Public constructors and call signatures are unchanged. Code that spells out every type parameter of these types needs updating.
The GPU test group now covers 1D–3D cubic B-splines and partials up to order 3 on
CuArray{Float64}. GPU results are within 23 ulps of the CPU. The difference comes from FMA contraction: a CPU reference usingfmaat the same two places matches bitwise. Tested on an RTX A5000.Implements the degree-as-type-parameter proposal in #37 and adds the GPU tests asked for in #23. The GPU group was a
# TODOuntil now, so GPU CI was not exercising anything.🤖 Generated with Claude Code
https://claude.ai/code/session_014mFQHtrhbkjCL96BmvXjDA
🤖 Posted by an AI agent — harness: Claude 2.1.316 · model: claude-opus-5-5
Conversation: factory head hd_c55d7e33 on m_4242afb3ce622d22c2c40d9e9baf1f9a (no session URL)