-
Notifications
You must be signed in to change notification settings - Fork 13.3k
autodiff unnecessarily prevents inlining #138920
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
Comments
@rustbot claim |
Hey @ZuseZ4, thanks for the detailed breakdown! |
…-inline, r=ZuseZ4 add autodiff inline closes: rust-lang#138920 r? `@ZuseZ4`
…-inline, r=ZuseZ4 add autodiff inline closes: rust-lang#138920 r? ``@ZuseZ4``
…nline, r=<try> add autodiff inline closes: rust-lang#138920 r? `@ZuseZ4` try-job: dist-aarch64-linux
…nline, r=<try> add autodiff inline closes: rust-lang#138920 r? `@ZuseZ4` try-job: dist-aarch64-linux
…-inline, r=ZuseZ4 add autodiff inline closes: rust-lang#138920 r? `@ZuseZ4` try-job: dist-aarch64-linux
…-inline, r=ZuseZ4 add autodiff inline closes: rust-lang#138920 r? ``@ZuseZ4`` try-job: dist-aarch64-linux
Rollup merge of rust-lang#139308 - Shourya742:2025-03-29-add-autodiff-inline, r=ZuseZ4 add autodiff inline closes: rust-lang#138920 r? ```@ZuseZ4``` try-job: dist-aarch64-linux
Using
std::autodiff
and thereforeRUSTFLAGS=-Zautodiff=Enable
in release mode currently alters the compilation pipeline in the following way:We have to make sure that functions being differentiated are not getting inlined during 1), since we still need them in step 2). Therefore they all receive
noinline
attributes.The problem we now have is that in Step 3), we potentially want to inline the new function which was generated through enzyme/autodiff. However, all function which got differentiated still have the noinline attribute.
We kept track of which function got differentiated, so it should be comparably easy to go through the llvm-ir module, find all functions which got created during step 2), and remove their noonline attribute before we move on to step 3). This will improve performance for smaller functions.
Here is the second llvm_optimize call, we would want to remove noinline before this call (and after the first call 5 lines above).
rust/compiler/rustc_codegen_llvm/src/back/lto.rs
Line 663 in 1df5aff
This is a good issue to get started, so if you're interested please feel free to start a discussion here, I'm happy to help with the design or implementation.
Tracking:
The text was updated successfully, but these errors were encountered: