-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SparseConnectivityTracer.jl #230
Conversation
Can you try it with the branch from adrhill/SparseConnectivityTracer.jl#75 ? |
Hi @amontoison @gdalle ! Thanks for adding this new feature. Can you make it that we don't remove the Symbolics-way of computing the sparse matrices? I am fine having both ways. |
@tmigot What do you want to keep Symbolics.jl? |
Why not? I don't think that the debate is 100% clear that the SparseConnectivityTracer is better than Symbolics, and it doesn't cost us a lot to maintain Symbolics for now. |
If you want to switch easily between both, I'd suggest using the ADTypes interface for sparsity detection. SparseConnectivityTracer supports it natively, and Symbolics will once JuliaSymbolics/Symbolics.jl#1134 is merged. Then it will be as easy as switching the "detector" object https://sciml.github.io/ADTypes.jl/stable/#Sparsity-detector |
@gdalle Do you have functions to perform |
@gdalle It seems that this case is not supported in ADTypes: https://github.com/amontoison/ADNLPModels.jl/blob/SCT/src/sparsity_pattern.jl#L9-L13 |
What do you mean by that? The result of a matrix-vector product is dense in general, why would you want its sparsity pattern? |
You need to use the function from ADTypes with the detector function compute_jacobian_sparsity(c, x0)
detector = SparseConnectivityTracer.TracerSparsityDetector() # replaceable
S = ADTypes.jacobian_sparsity(c, x0, detector)
return S
end |
My bad, I did the typo... |
These functions are not connected to the sparsity pattern. The right way to perform them is with DifferentiationInterface |
@gdalle Can you review the PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me!
Hi guys! Thanks @gdalle and @amontoison for this. |
There are several reasons, which @amontoison summed up here: control-toolbox/CTDirect.jl#88 (comment). We didn't benchmark specifically against Symbolics on optimization problems. However we did run other benchmarks:
Finally, note that SparseConnectivityTracer is only a default choice, not an eternal commitment. Thanks to the new ADTypes sparsity detection API, going back to Symbolics is basically as easy as replacing the detector object in the code below with ADNLPModels.jl/src/sparsity_pattern.jl Lines 9 to 16 in 29b1d2d
I don't think this detector configuration is accessible to the user yet, because it is still in the low-level functions, but it would be good to pass this object down all the way from the top level API |
Ok, but it is not a real constraint, it was just a versioning mistake that is being resolved.
Agreed. I am in general very in favor of what you guys did here. My point was mainly that it is strange to do everything in the same PR especially if we don't benchmark this package. The correct strategy should have been:
Could you open an issue to remember us to make the detector configuration accessible to users? Thanks! |
I agree with the temporary aspect of the SymbolicUtils kerfuffle. However, Julia 1.6 support was dropped some time ago by Symbolics and it isn't coming back. So that's a real limitation if you want to continue supporting 1.6, at least until 1.10 is declared as the new LTS. I agree that big changes all at once are not ideal. |
I opened an issue to keep track of the detector configuration, and I'll add benchmarks against Symbolics to my SCT/JuMP comparison in adrhill/SparseConnectivityTracer.jl#118 |
I wanted to have sparse AD by default here.
I wanted to drop Symbolics.jl and SparsityPatternDetection.jl and it was the best strategy for me.
It's already available as a keyword argument for the sparse AD backends ( |
fix #232
@gdalle