-
Notifications
You must be signed in to change notification settings - Fork 133
recognizing ENZYME_RUNPASS for lib/LLVM Enzyme builds #2245
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be disabled for llvmenzyme thougj? The flag says that the enzyme pass should be injected to be run by default in the pass pipeline
What is the difference between libEnzyme-X.so and LLVMEnzyme-19.so? I thought they would have just different linking behaviour, but the same functionality? We use libEnzyme because it fixed some linking issues I can't remember, so I don't mind only updating it and removing the LLVMEnzyme one (?) |
LLVMEnzyme is an llvm pass plugin, libenzyme is a dynamic library you can link into programs that aren't llvm's opt |
Fair, I vaguely had in mind that at some point I also linked against LLVMEnzyme when using the Enzyme API, but I might have confused something. Also, remember you'll need to merge, and can't just approve things. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not understanding why this is needed here
I want Enzymes opt pass to run befire autodiff, as it is supposed to improve performance. Right now Rust already sets |
Enzyme/enzyme/Enzyme/Enzyme.cpp Line 3662 in 3ea5fe2
|
Why not just run augmentPassBuilder? |
Why have RustEnxyme differ from ClangEnzyme or LLDEnzyem? |
The use you linked is specific to llvm pass loading which doesn't make sense for API users, since its better form to build the pass manager directly (like with the function I mentioned) |
This has been discussed e.g. here. There I had asked which functions I should use in which order. I ended up staring with another llvm dev at the enzyme code and this is what we came up with. From what we saw, we will always run
I don't see how exposing and ffi-wrapping agumentPassBuilder is an improvement over the code I merged after the zulip discussions with other devs which assumes the augmentPassBuilder to implicitly run (which I try to fix here since it doesn't, because cmake dropps the |
Ok, wild guess now, but in an attempt to understand the difference, could it be that you missed the messages/pings where I/Rust people asked about the Enzyme pass? |
I'm still a bit confused how you're intending to use this. In any case, perhaps you can make a second function void augmentAndRegisterEnzyme(PB, bool shouldAugment) which contains the current definition, and then is true if the current Enzyme_runpass is set. That way you can just call the api function without setting a compile time var |
The intention is to have Rust differ as little as possible from Clang/LLD-Enzyme to ease maintenance, since all three are pass based, as opposed to Julia which is Api based., Clang/LLD Enzyme both define this variable to first run augmentPassBuilder and then register Enzyme and run it. So my confusion comes from your recommendation to handle Rust and C++ different here. |
Also for the long term goal, the idea is to have autodiff run as the pass (e.g. because of your recommendation and because it handles higher order derivatives in the right order automatically). For things like custom-derivatives you recommended to not copy c++Enzyme, but rather link against libEnzyme, so we can use the more advanced registerCustomDerivative functions, since they are more granular than the metadata approach. So my understanding is that clang will in the future move to the api for custom derivatices, Enzyme.jl will move to the pass for autodiff (but keep using the api for things like custom derivatives) and then all 3 frontends will behave identical. Since Rust is coming in later, I directly try to do the right approach for each feature. Does that help? |
@wsmoses adding the runtime variant and updated the old one to forward, to make sure they can never get out of sync. |
e91fd91
to
d0bec48
Compare
* Fix non data type * fix * Update compiler.jl
I noticed that the ENZYME_RUNPASS variable is ignored, when you just pass it as
-DENZYME_RUNPASS
to cmake.This might also affect your
BUILD
file, idk.With these changes it now does run the augmentedPassBuilder.