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

Missing rule for LAPACK's dgetrf_64_ #1820

Open
mhauru opened this issue Sep 13, 2024 · 3 comments
Open

Missing rule for LAPACK's dgetrf_64_ #1820

mhauru opened this issue Sep 13, 2024 · 3 comments

Comments

@mhauru
Copy link
Contributor

mhauru commented Sep 13, 2024

MWE:

using Distributions
using Random
using Enzyme: Enzyme
using LinearAlgebra: I

d = MatrixTDist(
    3.1,
    randn(2, 3),
    Array(I, (2, 2)),
    Array(I, (3, 3)),
)
x = randn(2, 3)
f(x) = logpdf(d, x)
Enzyme.gradient(Enzyme.Forward, Enzyme.Const(f), x, Val(1))

Output:

 fallback?
ERROR:
No forward mode derivative found for dgetrf_64_
 at context:   call void @dgetrf_64_(i8* noundef nonnull %6, i8* noundef nonnull %8, i64 %22, i8* noundef nonnull %10, i64 %26, i64 noundef %bitcast_coercion42) #76 [ "jl_roots"({} addrspace(10)* null, {} addrspace(10)* %19, {} addrspace(10)* null, {} addrspace(10)* %2, {} addrspace(10)* null, {} addrspace(10)* null) ], !dbg !140

Stacktrace:
 [1] #getrf!#1
   @ ~/.julia/juliaup/julia-1.10.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/lapack.jl:565


Stacktrace:
  [1] copyto_unaliased!
    @ ./abstractarray.jl:1082
  [2] gemm!
    @ ~/.julia/juliaup/julia-1.10.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/blas.jl:1524
  [3] indexed_iterate (repeats 2 times)
    @ ./tuple.jl:92 [inlined]
  [4] log_proc1
    @ ./special/log.jl:165 [inlined]
  [5] _log
    @ ./special/log.jl:295
  [6] LazyString
    @ ./strings/lazy.jl:41 [inlined]
  [7] gemm!
    @ ~/.julia/juliaup/julia-1.10.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/blas.jl:1519
  [8] macro expansion
    @ ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:7187 [inlined]
  [9] enzyme_call
    @ ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:6794 [inlined]
 [10] ForwardModeThunk
    @ ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:6674 [inlined]
 [11] runtime_generic_fwd(activity::Type{…}, width::Val{…}, RT::Val{…}, f::typeof(logpdf), df::Nothing, primal_1::MatrixTDist{…}, shadow_1_1::Nothing, primal_2::Matrix{…}, shadow_2_1::Matrix{…})
    @ Enzyme.Compiler ~/.julia/packages/Enzyme/TiboG/src/rules/jitrules.jl:223
 [12] f
    @ ./REPL[17]:1 [inlined]
 [13] fwddiffejulia_f_2311wrap
    @ ./REPL[17]:0
 [14] macro expansion
    @ ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:7187 [inlined]
 [15] enzyme_call
    @ ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:6794 [inlined]
 [16] ForwardModeThunk
    @ ~/.julia/packages/Enzyme/TiboG/src/compiler.jl:6674 [inlined]
 [17] autodiff
    @ ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:437 [inlined]
 [18] #112
    @ ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:1197 [inlined]
 [19] ntuple
    @ ./ntuple.jl:19 [inlined]
 [20] gradient(::EnzymeCore.ForwardMode{…}, f::EnzymeCore.Const{…}, x::Matrix{…}, ::Val{…}; shadow::NTuple{…})
    @ Enzyme ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:1196
 [21] gradient(::EnzymeCore.ForwardMode{…}, f::EnzymeCore.Const{…}, x::Matrix{…}, ::Val{…})
    @ Enzyme ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:1195
 [22] top-level scope
    @ REPL[18]:1
Some type information was truncated. Use `show(err)` to see complete types.
@wsmoses
Copy link
Member

wsmoses commented Sep 16, 2024

Can you minimize this?

We should handle all the common ways LU decomposition is used without this rule, so I'm surprised it comes up

@mhauru
Copy link
Contributor Author

mhauru commented Sep 16, 2024

using Random
using Enzyme: Enzyme
using LinearAlgebra: logdet

x = randn(2,2)
Enzyme.autodiff(Enzyme.Forward, Enzyme.Const(logdet), Enzyme.Duplicated(x, zero(x)))

@mhauru
Copy link
Contributor Author

mhauru commented Sep 16, 2024

Or just plain

using Random
using Enzyme: Enzyme
using LinearAlgebra: lu

x = randn(2,2)
f(x) = lu(x, check = false)
Enzyme.autodiff(Enzyme.Forward, Enzyme.Const(f), Enzyme.Duplicated(x, zero(x)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants