Add precompile workload for Dual and SubArray broadcast operations#858
Merged
ChrisRackauckas merged 2 commits intoSciML:masterfrom Mar 1, 2026
Conversation
Add a `PrecompileTools.@compile_workload` block to
`NonlinearSolveBaseForwardDiffExt` that exercises common scalar, array,
and SubArray operations on ForwardDiff Dual numbers. This mirrors the
approach from DiffEqBase.jl PR #1291.
The extension already handled Dual number operations for sensitivity
analysis but had no precompilation, causing broadcast compilation
overhead at runtime for nonlinear functions using views.
What's precompiled:
- Scalar Dual operations: arithmetic, math functions, comparisons
- Vector{Dual} operations: broadcast, reductions, LinearAlgebra
- SubArray broadcast patterns: common nonlinear residual function
patterns using views
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
NewtonRaphson on the Generalized Rosenbrock function (problem 1) was marked as @test_broken but now passes on all platforms and Julia versions. Remove it from the broken_tests list. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PrecompileTools.@compile_workloadblock toNonlinearSolveBaseForwardDiffExtthat exercises common scalar, array, and SubArray operations on ForwardDiffDualnumbersPrecompileToolsas a dependency ofNonlinearSolveBaseThe extension already handled Dual number operations for sensitivity analysis (implicit differentiation via
nonlinearsolve_∂f_∂p/nonlinearsolve_∂f_∂u) but had no precompilation workload, causing broadcast compilation overhead at runtime for nonlinear functions using views.What's precompiled:
+,-,*,/,^, negation,abs), math functions (exp,log,sin,cos,tan,sqrt,cbrt,asin,acos,atan,sinh,cosh,tanh), comparisons/predicates,min/max, conversion (zero,one,float,ForwardDiff.value,ForwardDiff.partials).+,.-,.*,./,.^), in-place broadcast, reductions (sum,sum(abs2, ...),maximum(abs, ...)), LinearAlgebra (dot,norm),copy,fill!Test plan
Pkg.test("NonlinearSolveBase")passes (all 16 tests)🤖 Generated with Claude Code