Skip to content

Cache inner LinearCache in DualLinearCache in direct dual path#1065

Merged
ChrisRackauckas merged 4 commits into
SciML:mainfrom
hersle:forwarddiff_direct_dual_cache
Jun 29, 2026
Merged

Cache inner LinearCache in DualLinearCache in direct dual path#1065
ChrisRackauckas merged 4 commits into
SciML:mainfrom
hersle:forwarddiff_direct_dual_cache

Conversation

@hersle

@hersle hersle commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

A suggested fix to #1064. This is largely generated with Claude. I admittedly don't understand the internals well enough to know whether this is the right fix to make. Any help is appreciated :)

It fixes the original example in #1064 (comment), which now gives:

@time ForwardDiff.derivative(usumend_klu, 1.0) # 0.000808 seconds (1.98 k allocations: 300.891 KiB, 0.09% compilation time: 100% of which was recompilation)
@time ForwardDiff.derivative(usumend_pureklu, 1.0) # 0.000636 seconds (1.93 k allocations: 315.426 KiB, 0.05% compilation time: 100% of which was recompilation)

Now PureKLU is faster than KLU (as it should be?).

@hersle hersle force-pushed the forwarddiff_direct_dual_cache branch 2 times, most recently from 54f1480 to 9b21824 Compare June 28, 2026 16:56
@hersle

hersle commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

This is my best attempt for now. I think the problem was that A was being refactored at every single solve! even when A is unchanged between the solves. Is this PR a reasonable way to fix that, or is there a better way that achieves the same?

The changes here make PureKLU keep using the direct AD path and makes it faster than KLU. #1066 instead moves PureKLU to the split AD path, which makes it only as fast as KLU.

@ChrisRackauckas ChrisRackauckas merged commit b2e1de7 into SciML:main Jun 29, 2026
53 of 56 checks passed
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