Enzyme.jl icon indicating copy to clipboard operation
Enzyme.jl copied to clipboard

Query for Enzyme compatibility without running the code

Open ChrisRackauckas opened this issue 3 years ago • 4 comments

In DiffEq we're doing a bit of:

try
      Enzyme.autodiff(Enzyme.Duplicated(du, du),
                      u0,p,prob.tspan[1]) do out,u,_p,t
        prob.f(out, u, _p, t)
        nothing
      end
      true
    catch
      false
    end

to see whether Enzyme is compatible with a given function, but it would be nice to be able to do this without actually calling the function.

ChrisRackauckas avatar Jan 24 '22 08:01 ChrisRackauckas

Yeah, @wsmoses minimum improvement here is not to assert, but to report a catch-able error.

vchuravy avatar Jan 24 '22 16:01 vchuravy

https://github.com/wsmoses/Enzyme/pull/438 This should start to enable julia errors rather than having to use llvm unreachable/assertions.

wsmoses avatar Jan 27 '22 06:01 wsmoses

@ChrisRackauckas once https://github.com/wsmoses/Enzyme.jl/pull/193 lands (with corresponding jll bump) the BLAS (and other errors) should come through as proper julia errors, rather than LLVM assertions.

wsmoses avatar Jan 29 '22 07:01 wsmoses

And then how hard is it to do the next step of compiling and throwing an error if the program would through a type-based error (i.e. guaranteed error, rather than something based on values of branches), but not requiring the computation?

ChrisRackauckas avatar Jan 29 '22 10:01 ChrisRackauckas

Closing this since our stance is to give a runtime error where ever possible. Please open individual issues for things that remain compile-time errors.

vchuravy avatar Oct 11 '22 01:10 vchuravy