Enzyme
Enzyme copied to clipboard
Enzyme hangs when using CoDiPack forward AD type in function
This might be related to issue #142.
Enzyme does not finish when applied to the code:
#include <iostream>
#include <codi.hpp>
extern int enzyme_dup;
extern int enzyme_out;
extern int enzyme_const;
template<typename... Args>
void __enzyme_autodiff(void*, Args...);
using Inner = codi::RealForward;
//using Inner = double;
//using Data = int;
using Data = codi::ExternalFunctionUserData;
void func2_prim(Inner const* x, size_t m, Inner* y, size_t n, Data* d) {
y[0] = 42.0 * x[0] * x[0];
}
void test() {
Inner tx[1] = {1.0};
Inner tx_b[1] = {0.0};
Inner ty[1] = {0.0};
Inner ty_b[1] = {0.0};
__enzyme_autodiff(
(void*) func2_prim ,
enzyme_dup, &tx, tx_b,
enzyme_const, (size_t)1,
enzyme_dup, ty, ty_b,
enzyme_const, (size_t)1,
enzyme_const, (Data*)NULL);
}
It works when using the double type. I tried to reproduce this with a simple forward type implementation but this did not trigger the bug.
Clang: clang version 14.0.0
Enzyme: 61332add5 v0.0.71
The output of the crash report: out.txt.zip Full cpp file: e2-33883a.cpp.txt Command line: e2-33883a.sh.txt
Hi, thanks for the report. For your linked issue, 2 years old feels a bit outdated, so it might be worth checking if that one still fails? I do remember that I had one eigen bug that got solved in the meantime.
Also, can you please print the Enzyme Type Analysis? We just discussed yesterday that we should really rewrite that part, I guess it could be the reason here? You can get more output using https://enzyme.mit.edu/getting_started/UsingEnzyme/#enzyme-print-type
(I am on my phone, so I can't check your txt files rn, maybe I missed something there)
Hi,
took me a little longer. I ran the same command with the additional arguments -XClang -enzyme-print-type
. I also created a version where I used c++filt. Hope this helps.
Related issue still fails to this day
@MaxSagebaum Sorry, completely forgot to check the zip once I was back at my laptop. @wsmoses check the _Rb_tree_node_base, that's probably a case which would be solved by handling recursions nicely, right?
Either way, now that the whole zip finished loading, it looks like it doesn't get stuck, but rather crashes, right?
; Function Attrs: nounwind
declare dso_local void @_ZNSt8__detail15_List_node_base7_M_hookEPS0_(%"struct.std::__detail::_List_node_base"* noundef nonnull align 8 dereferenceable(16), %"struct.std::__detail::_List_node_base"* noundef) #2
clang++: /home/msagebaum/Kaiserslautern/Programms/Enzyme/enzyme/Enzyme/EnzymeLogic.cpp:2101: const AugmentedReturn &EnzymeLogic::CreateAugmentedPrimal(llvm::Function *, DIFFE_TYPE, ArrayRef<DIFFE_TYPE>, TypeAnalysis &, bool, bool, const FnTypeInfo &, const std::map<Argument *, bool>, bool, unsigned int, bool, bool): Assertion `0 && "attempting to differentiate function without definition"' failed.
we should add support for std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)
Any updates on the issue?
Given that we miss one of the list functions that you use, there is a good chance that we might miss another list related function or two. Could you please re-run it and post the log after rebuilding Enzyme? This commit should show you not only the next unsupported function, but all unsupported functions, so we know how much is missing and can eventually add support for them together. https://github.com/EnzymeAD/Enzyme/pull/1451
I checked out the newest version of Enzyme and performed the output again. Here are the newest results.
On a side note: I had problems getting the command to run. My final command line was:
$LLVM_DIR/bin/opt input.ll -load=$ENZYME_DIR/lib/LLVMEnzyme-14.so -load-pass-plugin=$ENZYME_DIR/lib/LLVMEnzyme-14.so --passes=enzyme -enzyme-print-type -o output.ll -S
In https://enzyme.mit.edu/getting_started/Faq/ the argument -load-pass-plugin=$ENZYME_DIR/lib/LLVMEnzyme-14.so
is missing. Otherwise I still got that the enzyme pass was missing.