-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Set lto to 'fat' with autodiff enabled #146528
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
Messes with code I have no business dealing with.
rustbot has assigned @petrochenkov. Use |
The job Click to see the possible cause of the failure (guessed by this bot)
|
r? claim |
Failed to set assignee to
|
@rustbot label C-bug F-autodiff |
LTO is meant to be an optimization and therefor be optional. Why does autodiff needs it to be unconditionally enabled? Does that mean that autodiff just doesn't work without fat LTO? |
Yeah, check out the linked issue. Using autodiff without setting lto="fat" in your Cargo.toml caused it to set derivatives to 0.0. When I tried it more recently, it didn't compile at all. |
@Urgau Enzyme (the llvm plugin doing autodiff for us) needs access to the whole IR, so fat-lto is the simplest solution. That's just based on the chain rule from calculus, you need to see all function (and type) definitions which are used recursively/indirectly. Technically, embed-bc should also work, but there's an issue around how we get the llvm-ir of the std library (IIRC) in the non-fat-lto case. Oli and I spend a few hours a while ago trying to figure that out and we think that some of the logic in rustc is wrong, but we both ran out of time. I'll get back to it at some point. Relatedly, GPU code has the same requirement. #135024 That being sad, it looks like that PR unfortunately raced with #146229, which I think is the better location to enable lto, since we already seem to check there for other reasons to enable lto. |
@ZuseZ4 I don't mind at all, but it looks like it already does that? In the amdgcn spec (rust/compiler/rustc_target/src/spec/targets/amdgcn_amd_amdhsa.rs):
And I assume it would be used here (rust/compiler/rustc_session/src/session.rs):
|
cc @Flakebi Did you forget to check the box for fix requiring lto automatically? (see above) |
When I tested ~2 weeks ago, it was still broken unfortunately, so the explicit lto=fat in Cargo.toml is still needed sometimes (I know the code quoted above sets it, so I don’t know where it’s broken, I didn’t get to investigate further). |
resolves #142796
This took a whole lot longer than I expected it to. A lot longer.