Skip to content

Conversation

oschulz
Copy link
Contributor

@oschulz oschulz commented Sep 12, 2025

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

Add any other context about the problem here.

@oschulz
Copy link
Contributor Author

oschulz commented Sep 12, 2025

Closes #121

@oschulz
Copy link
Contributor Author

oschulz commented Sep 12, 2025

With this PR, we get

julia> DifferentiationInterface.gradient(sum, NoAutoDiff(), rand(5))
ERROR: NoAutoDiffAvailable("Automatic differentiation can not be used with NoAutoDiff()")
Stacktrace:
 [1] mode(::NoAutoDiff)
   @ ADTypes /user/.julia/dev/ADTypes/src/dense.jl:543
 [2] pullback_performance(backend::NoAutoDiff)
   @ DifferentiationInterface /user/.julia/dev/DifferentiationInterface/DifferentiationInterface/src/utils/traits.jl:102
[...]

@oscardssmith oscardssmith requested a review from gdalle September 12, 2025 16:11
@gdalle gdalle merged commit 1f78b26 into SciML:main Sep 13, 2025
8 checks passed
@oschulz
Copy link
Contributor Author

oschulz commented Sep 13, 2025

@gdalle I was using

struct NoAutoDiffSelectedError <: Exception
    msg::AbstractString
end

instead of msg::String because Base.ArgumentError, Base.ErrorException and similar are defined like that. I don't know if that's to avoid memory allocation due to string conversion when an exception object is created?

@gdalle
Copy link
Collaborator

gdalle commented Sep 13, 2025

No clue. I guess we can leave it like this but if it turns out to be a problem we'll switch back

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