Repository navigation
Restrict BSpline derivative loops to the nonzero basis window - #621
ChrisRackauckas-Claude wants to merge 2 commits into
Conversation
Only m=d basis values are nonzero, so iterating 1:(n-1) or 1:(h-1) was O(n)/O(h) work for an O(degree) update. Windowing preserves values and makes large-n derivatives ~100× faster. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Cursor Agent <noreply@cursor.com> Agent-Harness: Cursor Agent 2026.10.01-14929f9 Agent-Model: unknown (Cursor auto) Agent-Session: local session, transcript /home/crackauc/sandbox/goals/performance/jobs/di/pr-bspline-deriv/log.txt on amdci2
Wall-clock ns < 1000 fails under --code-coverage=user; count knot accesses instead and move the n=10⁴ case to AirspeedVelocity. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Cursor Agent <noreply@cursor.com> Agent-Harness: Cursor Agent CLI Agent-Model: auto
Independent review (Devin CLI 3000.11.3, model fusion-claude-opus-5-5-high-sidekick-swe-2-medium): MERGE, risk low. Full reviewVERDICT: MERGE Blocking findingsNone. The source change is a pure loop-bound tightening. On master each loop runs Non-blocking findings
What I ranAll runs used
What I did not verify
🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (review), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium |
PR: #621 Reviewed head: 0b97484 Risk assessment
Review reportVERDICT: MERGE Riskmedium-low (ML3: restricts peripheral BSplineInterpolation and BSplineApprox _derivative loops to the nonzero basis window; values are bit-for-bit unchanged across all u shapes, orders, and ChainRules t-tangents, with deterministic knot-read checks and AirspeedVelocity benchmarks) Blocking findingsNone. Non-blocking findings
What I ran
What I did not verify
AUTHOR_GRADE: {"task": "perf", "score": 4, "difficulty": 2, "rounds": 1, "author_harness": "Cursor Agent CLI", "author_model": "auto", "note": "Clean 6-line loop-window restriction across all 6 BSpline _derivative methods giving ~30x-220x speedups at n=10^4 with bit-for-bit identical outputs, deterministic knot-read test, and AirspeedVelocity benchmarks; minor deductions for Agent-Session commit trailer hygiene and scalar-only knot-read coverage."} Head link: 0b97484 🤖 Posted by an AI agent — harness: Antigravity CLI 1.5.21 · model: gemini-4-carbon-high |
Summary
BSpline
_derivativemethods forBSplineInterpolationandBSplineApprox(scalar, vector-of-vectors, and arrayu) iterated1:(n-1)/1:(h-1)even though onlym = dbasis values frombspline_nonzero_coefficientsare nonzero. Each loop is now restricted tomax(1, offset):min(n-1, offset+m-1)(or thehequivalent). Values match master exactly (bitwise identical over 1.35M derivative samples in independent review); order-2 paths improve automatically because they autodiff the analytical first derivative.Performance (a CI box, Julia 1.12.4,
JULIA_NUM_THREADS=1 taskset -c 0,@benchmarkminima, n=10⁴, 1000 random probes)BSplineInterpolationd1BSplineInterpolationd2BSplineApproxd1Large-n BSpline derivative cases live in
benchmark/benchmarks.jlfor AirspeedVelocity.Regression test
A.kin aCountingVectorvia the existing inner constructors; assert knot reads< 200and bitwise equality vs the unwrapped object. Master: 10 pass / 6 fail. PR: 16 pass. Observed reads on the PR: 32/31 at n=100 and 39/37 at n=10⁴ (Interp/Approx); on master: 224/89 and 20031/6695.Test-group tails (post review fix)
Core (
GROUP=Core Pkg.test):QA (
GROUP=QA Pkg.test):Also: Runic + typos on touched files clean.
Review response
Replaced the flaky
ns < 1000wall-clock testset (fails under--code-coverage=user, d1 1619–1629 ns) with the reviewer's knot-read counting test. Moved the n=10⁴ timing case tobenchmark/benchmarks.jl. Dropped comments that described the unfixed timing.Please ignore until reviewed by @ChrisRackauckas.
Risk assessment
_derivativeloops ofBSplineInterpolationandBSplineApprox, for scalar, vector-of-vectors and arrayu. No API change. Window is exactly the old1 <= l <= mguard set; summation order unchanged; results bitwise identical.🤖 Generated with Cursor Agent CLI (model: auto); transcript /pr-bspline-deriv/log.txt
Made with Cursor
Independent review: Devin Fusion (fusion-claude-opus-5-5-high-sidekick-swe-2-medium) rated it low, verdict MERGE: #621 (comment)
Risk assessment (independent review, Codex gpt-6.1-sol, head 0b97484)
BSplineInterpolationandBSplineApprox, for scalar, matrix/array, and vector-of-vectors outputs. No public names, signatures, defaults, dependency changes, or SemVer break; no existing assertions were removed, skipped, or loosened. New public-name documentation and dependency-license checks are therefore not applicable.git diff origin/HEAD...HEAD, surrounding implementations, and the entire risk rubric. No linked issue exists.git diff --check origin/HEAD...HEADpassed; the checkout remained clean. Currentorigin/HEADis 898d88ec6630d7bcd2886172ac81fa0fcf3e89e7; itssrc/differs from the head only in these six bounds.python3 <local path>, which sequentially invokes Julia 1.12.4 withtimeout 3600,--compiled-modules=existing, scratch head/base projects, andfinal_validation.jl. Used the requested depot, four Julia threads, and one BLAS thread; only one Julia process ran at a time. Snapshots includesrc/andext/; the two added testsets and their helper were extracted verbatim from the PR.<200. Clean runs contain no extension-loading errors. Logs: head, base.python3 <local path>asserts the two complete bitstring files are identical.BSplineInterpolationd1: 13074.3 → 78.0 ns/call (base → head).BSplineInterpolationd2: 12507.4 → 254.4 ns/call (base → head).BSplineApproxd1: 5726.1 → 74.8 ns/call (base → head).BSplineApproxd2: 4360.8 → 251.2 ns/call (base → head).LinearInterpolationd1: 38.9 → 41.7 ns/call (base → head).gh pr view 621/gh run view 37854493288confirm all 21 checks succeeded on the exact head. Inspected actual logs: Methods derivative file 75,605/75,605; Mooncake 769/769; Zygote 29,470/29,470. No failing CI check requires a default-branch comparison.🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: local headless review run (no public session URL); transcript kept by the fleet master.