Skip to content

Fix SimpleNonlinearSolve GPU compat: replace isinplace() with isa checks#865

Closed
AdityaPandeyCN wants to merge 13 commits intoSciML:masterfrom
AdityaPandeyCN:gpu/patch
Closed

Fix SimpleNonlinearSolve GPU compat: replace isinplace() with isa checks#865
AdityaPandeyCN wants to merge 13 commits intoSciML:masterfrom
AdityaPandeyCN:gpu/patch

Conversation

@AdityaPandeyCN
Copy link
Copy Markdown
Contributor

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

SciMLBase.isinplace() returns a type parameter value that GPUs cannot branch on as GPU masked execution runs both sides of an if, so the dead in-place branch hits similar() or mismatched call signatures and throws. The fix replaces all isinplace() checks in the GPU code path with prob.f isa NonlinearFunction{true} which returns a proper Bool, calls f.f() directly to avoid varargs splatting, and adds GPU-safe fast paths for incompatible_backend_and_problem for AutoForwardDiff/AutoFiniteDiff/AutoEnzyme whose DI.check_available/DI.check_inplace do method table lookups that GPU kernels cannot handle.

I have built the PR on #854

utkarsh530 and others added 13 commits February 26, 2026 11:08
Removed 'src' from the coverage directories in the pipeline configuration.
SciMLBase.isinplace extracts a type parameter and returns a compile-time
constant (true/false). The compiler constant-folds it, so @generated
functions are unnecessary for eliminating dead branches. Regular functions
with if SciMLBase.isinplace(prob) infer identically.

Reverted: incompatible_backend_and_problem, evaluate_f!!, evaluate_f,
should_cache_fx, and prepare_jacobian back to regular functions.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: AdityaPandeyCN <adityapand3y666@gmail.com>
@ChrisRackauckas
Copy link
Copy Markdown
Member

SciMLBase.isinplace should just return the parameter value. Just fix it there.

@AdityaPandeyCN
Copy link
Copy Markdown
Contributor Author

After we know that iip is already a bool and still using that is throwing error, should we give this pr a retry? @ChrisRackauckas

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.

3 participants