Skip to content

Fix SimpleNonlinearSolve keyword override flags and parameterless GPU solves - #1240

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:codex/fix-simple-nonlinear-override-flags
Sep 13, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:codex/fix-simple-nonlinear-override-flags

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Supplying both u0 and p to a SimpleNonlinearSolve solve currently ignores both overrides because the u0_changed/p_changed flags are inverted. Correct the two predicates so supplied overrides trigger remake, while calls without overrides avoid it. The latter also restores parameterless immutable nonlinear solves inside OpenCL kernels, which previously compiled through an unnecessary remake and failed with invalid GPU IR.

Added all four keyword combinations for mutable and immutable problems to the existing Core kwargs tests, plus a parameterless kernel regression to the existing CUDA group. No dependencies or public signatures change.

Ignore this PR until reviewed by @ChrisRackauckas.

Failing before / passing after

On unmodified owner master 0dccd34d125638394c2f3e5e53be3b5e272896a0, running the exact new Core testset with Julia 1.12.7 produced:

Test Summary:                         | Pass  Fail  Total  Time
Initial state and parameter overrides |    6     2      8  2.9s

Both failures are simultaneous keyword overrides. The identical testset after the fix:

Test Summary:                         | Pass  Total  Time
Initial state and parameter overrides |    8      8  0.6s

Command: julia +1.12 --project=scratch/nonlinear-owner-fix-env scratch/nonlinear_override_regression.jl (the script imports SimpleNonlinearSolve/SciMLBase/Test and contains the new testset verbatim).

An independent owner-level reproduction uses OpenCL 0.10.11 / GPUCompiler 2.5.4 / POCL and imports no DiffEqGPU:

using SimpleNonlinearSolve, SciMLBase, StaticArrays, KernelAbstractions
using OpenCL, pocl_jll, Test
f(u, p) = u .- 1f0
prob = convert(SciMLBase.ImmutableNonlinearProblem,
    NonlinearProblem{false}(f, SVector(0f0)))
@kernel function nonlinear_kernel!(out, prob)
    i = @index(Global)
    sol = solve(prob, SimpleNewtonRaphson())
    out[i] = sol.u[1]
end
backend = OpenCL.OpenCLBackend()
out = KernelAbstractions.zeros(backend, Float32, 3)
nonlinear_kernel!(backend)(out, prob; ndrange = 3)
KernelAbstractions.synchronize(backend)
@test Array(out) ≈ fill(1f0, 3)

Before: InvalidIRError, including unsupported julia.new_gc_frame and typejoin calls through remake. After: exit 0 with the output assertion passing. The same environment with clean DiffEqGPU master and its initialization-preprocessing test changes from InvalidIR to:

Test Summary:                          | Pass  Total   Time
Initialization preprocessing runs once |    2      2  49.5s

Source-history tracing finds the inverted predicates introduced in cc61d5a . This is source provenance; no historical 2024 dependency-environment runtime bisect is claimed.

Validation

Commands:

GROUP=Core julia +1.12 --project=lib/SimpleNonlinearSolve -e 'using Pkg; Pkg.test()'
GROUP=QA julia +1.12 --project=lib/SimpleNonlinearSolve -e 'using Pkg; Pkg.test()'

Core completed with 35,620 passing assertions and four pre-existing broken assertions; no tests were skipped, disabled, or altered to suppress failure. Tail:

Test Summary:      | Pass  Total  Time
Kwargs Propagation |    9      9  1.8s
     Testing SimpleNonlinearSolve tests passed

QA:

Test Summary: | Pass  Total     Time
QA            |   20     20  1m09.4s
     Testing SimpleNonlinearSolve tests passed

Runic, typos over the changed files, and git diff --check pass. No docs/public API additions; docs build not run. CUDA hardware tests, adjoint tests, and the full monorepo suite were not run. The new CUDA regression uses the same problem/solve/output operation exercised locally through OpenCL/POCL, but CUDA compilation itself remains unverified.

🤖 Generated with Codex (harness version: unknown; exact model ID: unknown). Local session ID: 01a07fcc-1c4f-7ee3-9a1e-51eaab7df293; no shareable conversation URL exposed.

Honor simultaneous u0/p overrides and avoid remaking unchanged immutable
problems inside GPU kernels. Cover keyword combinations and parameterless
CUDA kernel solves.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex (version unknown)
Agent-Model: unknown
Agent-Session: local session ID 01a07fcc-1c4f-7ee3-9a1e-51eaab7df293
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Additional Julia 1.13 validation while investigating the OpenCL CI failure in SciML/DiffEqGPU.jl#532:

I reran the owner-level parameterless OpenCL kernel reproducer already included in this PR body. It imports SimpleNonlinearSolve, SciMLBase, StaticArrays, KernelAbstractions, OpenCL, pocl_jll, and Test; it does not import DiffEqGPU or Enzyme.

With registered SimpleNonlinearSolve 2.14.3, the process exits 1:

InvalidIRError: compiling MethodInstance for gpu_nonlinear_kernel! ... resulted in invalid LLVM IR
Reason: unsupported call to a lazy-initialized function (call to jl_genericmemory_copyto)
Reason: unsupported call to a lazy-initialized function (call to ijl_type_unionall)

The stack traces go through remake from simplenonlinearsolve_solve_up. With this PR checkout at aa98f37 developed in a copy of that environment, the identical script exits 0:

Test Summary:                           | Pass  Total  Time
Parameterless nonlinear solve in OpenCL |    1      1  1.0s

Both runs use SciMLBase 3.53.3, OpenCL 0.10.11, GPUCompiler 2.6.0, KernelAbstractions 0.9.42, and pocl_jll 7.1.3+9. The developed checkout declares SimpleNonlinearSolve 2.14.2. Commands from the workspace root:

julia +1.13.0 --project=scratch/ci-investigation/master-check-env scratch/ci-investigation/owner-init-minimal.jl
julia +1.13.0 --project=scratch/ci-investigation/owner-init-fix-env scratch/ci-investigation/owner-init-minimal.jl

versioninfo():

Julia Version 1.13.0
Commit d1c37793dd2 (2026-09-09 19:00 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 128 × AMD EPYC 7502 32-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.8 (ORCJIT, znver2)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 128 virtual cores)
Environment:
  JULIA_LOAD_PATH = @:@stdlib

This independently reproduces the dependency failure on the official Julia 1.13 release. The existing Julia 1.12 reproduction in the PR body shows it is not exclusive to Julia 1.13. Source-history tracing still points to cc61d5a for introduction of the inverted predicates; no historical dependency-environment runtime bisect is claimed.

🤖 Written with Codex CLI 0.153.4 (model: gpt-6-astra). Local session ID: 01a07fcc-1c4f-7ee3-9a1e-51eaab7df293; no shareable conversation URL exposed.

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review September 13, 2026 08:06
@ChrisRackauckas
ChrisRackauckas merged commit 5fadf92 into SciML:master Sep 13, 2026
78 of 79 checks passed
ChrisRackauckas added a commit that referenced this pull request Sep 13, 2026
- Fix SimpleNonlinearSolve keyword override flags and parameterless GPU solves (#1240)



Agent-Harness: Claude Code
Agent-Model: claude-opus-5[1m]
Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R

Co-authored-by: Claude Opus 5 (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.

2 participants