Skip to content
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

Improve error message when DifferentiationInterface isn't loaded #41

Closed
penelopeysm opened this issue Nov 16, 2024 · 1 comment · Fixed by #42
Closed

Improve error message when DifferentiationInterface isn't loaded #41

penelopeysm opened this issue Nov 16, 2024 · 1 comment · Fixed by #42

Comments

@penelopeysm
Copy link

penelopeysm commented Nov 16, 2024

Since #39 was merged, it's now possible to run e.g. ADgradient(ADTypes.AutoMooncake(),...) using DifferentiationInterface. 🎉

This is documented here:

Passing `x` as a keyword argument means that the gradient operator will be "prepared" for the specific type and size of the array `x`. This can speed up further evaluations on similar inputs, but will likely cause errors if the new inputs have a different type or size. With `AutoReverseDiff`, it can also yield incorrect results if the logdensity contains value-dependent control flow.
If you want to use another backend from [ADTypes.jl](https://github.com/SciML/ADTypes.jl) which is not in the list above, you need to load [DifferentiationInterface.jl](https://github.com/gdalle/DifferentiationInterface.jl) first.
"""
LogDensityProblemsAD.ADgradient(::ADTypes.AbstractADType, ℓ)

but I wonder if one could define a catch-all method, mirroring the one here

function ADgradient(v::Val{kind}, P; kwargs...) where kind
@info "Don't know how to AD with $(kind), consider `import $(kind)` if there is such a package."
throw(MethodError(ADgradient, (v, P)))
end

which could mention that if you're expecting your AD backend to work via DI, then try importing DI?

@penelopeysm
Copy link
Author

penelopeysm commented Nov 16, 2024

Pfft, I was using :Mooncake instead of AutoMooncake(). 😓 Let me edit to make this better. Edited.

@penelopeysm penelopeysm changed the title Unclear error message when DifferentiationInterface isn't loaded Improve error message when DifferentiationInterface isn't loaded Nov 16, 2024
@tpapp tpapp closed this as completed in #42 Nov 18, 2024
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 a pull request may close this issue.

1 participant