Skip to content

Use a noncapturing CQUAD callback and fix GSL test registration (follow-up to #213) - #392

Draft
pankgeorg wants to merge 9 commits into
SciML:masterfrom
pankgeorg:gsl-cquad-callback
Draft

pankgeorg wants to merge 9 commits into
SciML:masterfrom
pankgeorg:gsl-cquad-callback

Conversation

@pankgeorg

Copy link
Copy Markdown

Companion to #213, built on its head.
Addresses #213 (comment): noncapturing C callback with preserved context (works on aarch64), GSLIntegration registration in interface tests, ascending native bounds with sign correction for reversed intervals.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HN2L2XPLDPd4CbKH6dtEJJ

lxvm and others added 9 commits December 29, 2023 07:59
Co-Authored-By: Codex gpt-6.2-sol (session 01a226c3-47bc-7d03-aac5-983c4cf9a457) <noreply@openai.com>
Preserve the Julia callable and GSL workspace during integration. Register the same CQUAD factory in the interface test list and capability map.

Co-Authored-By: Codex gpt-6.2-sol (session 01a226c3-47bc-7d03-aac5-983c4cf9a457) <noreply@openai.com>
Co-Authored-By: Codex gpt-6.2-sol (session 01a226c3-47bc-7d03-aac5-983c4cf9a457) <noreply@openai.com>
Handle native failures before reading cached outputs, check the error estimate, and retain vector points in both callback forms. Validate the CQUAD routine and workspace at construction, and reject maxiters at initialization.

Co-Authored-By: Codex gpt-6.2-sol (session 01a226c3-47bc-7d03-aac5-983c4cf9a457) <noreply@openai.com>
Exercise the GSL handler defaults for invalid tolerances and retain a divergent-native-status cache cycle.

Co-Authored-By: Codex gpt-6.2-sol (session 01a226c3-47bc-7d03-aac5-983c4cf9a457) <noreply@openai.com>
Reject intervals that CQUAD cannot represent in Float64 and validate tolerances before native integration. Reject non-nothing maxiters at the backend, including problem options.

Co-Authored-By: Codex gpt-6.2-sol (session 01a226c3-47bc-7d03-aac5-983c4cf9a457) <noreply@openai.com>
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #392

Reviewed head: d50ef05
Raw SHA-256: 7527eb5e655f4526f1c0f829bba66b249943758fb6ecfda0254bdb57f672a8db
Source SHA-256: dcc2cc18806b81ca7f60acf51fdc570b01803d061c9fc45f93b420094addcc29
Source: operator-attested-codex-v1 (runner attested by pankgeorg)
Reviewer session: 01a22734-5cc0-70e2-ad8d-8149ee1af9a1
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H3)
  • Verdict: CHANGES
  • Reviewed head: d50ef05

Review report

VERDICT: CHANGES
PR: #392
Head: d50ef05
Base: 1320d5b
Reviewer: codex-cli 0.172.0 / gpt-6.2-sol
Session: 01a22734-5cc0-70e2-ad8d-8149ee1af9a1

Risk

high (H3: The optional CQUAD backend introduces GPL-3.0-or-later GSL.jl and its native GSL dependency.)

Blocking findings

  • P1 — ext/IntegralsGSLExt.jl:130. With wssize=100 and default tolerances, integrating (x, p) -> 1e200 * (1 + x * 1e200) over (0.0, 1e-200) stayed inside native CQUAD until a 10-second timeout. The exact answer is 1.5. Rescale the interval and apply the Jacobian in the callback before passing values to GSL. The target’s existing ChangeOfVariables path returned 1.5 in a scratch port.
  • P2 — ext/IntegralsGSLExt.jl:140. Integrating the constant nextfloat(0.0) over (0.0, 1e307) with abstol=0.0 and reltol=1e-8 returned zero, zero estimated error, and Success. The expected value is approximately 4.9406564584124654e-17. Apply the same rescaling before CQUAD sees the callback values and add a regression that checks the result against nextfloat(0.0) * 1e307. The scratch target port passed this check.
  • P2 — test/interface_tests.jl:70 and test/interface_tests.jl:150. The patch does not apply to the current target. In a scratch port, seven historical bound-rejection assertions failed because the target transforms the bounds before backend dispatch. The direct backend call at line 150 also errored because it bypassed the target’s wrapped cache. Port the GSL registration, constructor, native workspace and callback, and CQUAD tests into the target’s extension and Core test layout. Update the bound tests for the public transformation contract, exercise keyword forwarding through solve and solve!, and retire the Arblib matrix edit because the target already tests Arblib.

Nonblocking findings

  • docs/src/solvers/IntegralSolvers.md:3. The solver catalog omits GSLIntegration, so readers browsing supported algorithms cannot discover it there. Add the solver and link its docstring, including the using GSL requirement and scalar, one-dimensional scope.

What I ran

  • git apply --check --directory=before changes.diff passed. Applying the patch to a scratch copy and running diff -qr reproduced head/. git apply --check --directory=target changes.diff failed in four files.
  • On Linux ARM64 with Julia 1.10.14, GSL.jl 1.0.1, and GSL_jll 2.8.2+0, I ran both interface files with include. Head passed 386 assertions, including all 67 dedicated CQUAD assertions. The merge base passed 279 and had no GSLIntegration API. Both extension load orders passed. The new numerical assertions use analytical references, and the patch retains the existing checks.
  • julia +lts --startup-file=no --project=.review/focused .review/repros.jl reproduced the false success. Running the same script with the timeout argument under timeout -k 2s 10s exited 124 inside gsl_integration_cquad. Both cases passed in the scratch target port. Running the historical CQUAD assertions there produced the seven failures and one error cited above.
  • Pkg.instantiate(); Pkg.test() on a head copy passed QA and interface tests, then errored at test/derivative_tests.jl:94. Running that test on the merge base with matching SciMLBase, Zygote, ForwardDiff, and FiniteDiff versions reproduced the llvmcall error while differentiating the legacy constructor. Running the five subsequent head suites separately passed all 69 assertions.

What I did not verify

  • The full suite for a finished target port, other Julia versions, or other CPU architectures. GPU execution was unavailable on this ARM host, and the diff adds a CPU-only backend.
  • ci.json lists zero head checks. Its target check results supply no CQUAD execution evidence. The patch makes no performance claim, and I found no before/after benchmark for the new backend.

Head link: d50ef05


🤖 Posted by an AI agent — harness: codex-cli 0.172.0 · model: gpt-6.2-sol
Conversation: local session 01a22734-5cc0-70e2-ad8d-8149ee1af9a1 (no session URL)

@lxvm

lxvm commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

IIRC safe handling of GSL functions was fixed upstream years ago in JuliaMath/GSL.jl#132 but has not been released yet. Not sure if it makes more sense to collaborate at the GSL.jl repository so that a more simple and safe api can be used by Integrals.jl

This branch has not been deployed

No deployments
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.

4 participants