Enable autodiff testcases in CI #855
Labels
final-comment-period
The FCP has started, most (if not all) team members are in agreement
major-change
A proposal to make a major change to rustc
T-compiler
Add this label so rfcbot knows to poll the compiler team
to-announce
Announce this issue on triage meeting
Proposal
Adding
std::autodiff
to nightly Rust was originally accepted as MCP here, and as a lang experiment on 2024-05-01. Autodiff is based on an experimental LLVM plugin calledEnzyme
.The implementation of
std::autodiff
was upstreamed over the last year per tracking issue. We now have had a working autodiff implementation in rust-lang/rust for a few months, which is gradually getting improved. Autodiff is available in nightly if the compiler is being build after settingllvm.enzyme = true
in bootstrap.toml. By default, the value is false.In this pr I experimented succesfully with setting
llvm.enzyme = true
in CI, but the final PR merged still had it disabled to give it more time to mature. A few months later, I think it's getting time to enable it on nightly, to allow people to experiment with it. I intend to enable autodiff for all Tier 1 targets which are LLVM based, with the exception of MSVC targets, which are currently not supported to due to an Enzyme bug.This would result in autodiff testcases running in CI, since they are currently guarded behind a
needs-enzyme
configuration, which is true if and only if we build rustc with autodiff enabled.The way in which changes to the test infra are handled is currently under review. I have attached the template from rust-lang/rust-forge#813. This is likely the first usage of this template, so critique on the form should be directed there.
Copied from rust-lang/rust-forge#813
Ecosystem and Integration Test Job/Component Policy
The ecosystem/integration test job/component ("test job/component") proposed for the
rust-lang/rust CI must:
team member, and the MCP is accepted with no blocking concerns.
Please complete the sections below so rust-lang/rust teams can have sufficient context about the
proposed test job/component.
Test job/component rationale
Testing the
std::autodiff
module.I wrote documentation on https://enzyme.mit.edu/index.fcgi/rust, and I'd be happy to move over documentation to the rustc-dev-guide. However, some guidance on which docs are desired and where in the dev guide to add them would be appreciated.
Ecosystem users: people working in the field of Machine Learning, High Performance Computing, Scientific Computing (e.g. simulations), Graphics, Quantum Computing, ...
We have autodiff tests in
tests/ui
,tests/pretty
, andtests/codegen
. Only codegen tests actually invoke Enzyme, ui and pretty tests just test our macro frontend.ui
andpretty
tests test my rustc_builtin_macro expansion, so I think they should only break if someone reworks how such macros work?The
codgen
tests are more likely to break, I would therefore suggest that we treat ui and pretty tests normally, thus if a PR refactors the frontend and they start failing, they should be fixed as part of the PR, I'm happy to help.Per MCP and Lang experiment it was decided to allow automatic differentiation in nightly. We want to have tests even for nightly features.
Because someone changed the autodiff parsing code in a way that changed it's expansion output, without blessing the new output. In that case it's likely an unintended change that shouldn't be merged.
I am not convinced that Enzyme in the current state is reliable enough to block Rust CI. I would suggest that a change to this policy goes through a new MCP.
Test job/component maintainers
@ZuzeZ4
CI infrastructure considerations
Discussed in: https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/MCP.20-.20Enable.20autodiff.20in.20CI/with/508847008
Features and implementation details
Yes,
#![feature(autodiff)]
.Yes, I intend to enable tests and shipping on nightly simultaneously (would something else even possible?)
Yes, I've been working on automatic differentiation for Rust for almost 5 years, it's getting time to see some more public testing.
It depends on the usage of Enzyme and thus LLVM, it would be great to have autodiff for
cranelift
(andgcc
) too. We also alter the compilation pipeline and expose/use theRUSTFLAGS=-Zautodiff=<options>
flag.It is desired to replace Enzyme by an upstream autodiff feature directly in LLVM. It is also desired to implement autodiff based on a reflection system when possible.
Failure protocol: what to do if the job/component breaks/fails?
pinging in the PR, zulip, discord
N/A
All Tier 1 targets building LLVM from source, with the exception of MSVC (due to an Enzyme bug).
By setting
llvm.enzyme = true
inbootstrap.toml
, building rustc, and running the tests.If Enzyme fails to build e.g. due to an LLVM update (not supposed to happen, but still), then
llvm.enzyme
can be set tofalse
. This will disable nightly for some nightly versions until the build gets fixed. It will also cause autodiff tests to be skipped.rustc_builtin_macros
then autodiff should be updated/fixed along with all otherrustc_builtin_macros
.Dependencies, build/test environments and reliability
Enzyme uses
cmake
, which is already in use in CI jobs for building LLVM.No, as of today we have an Enzyme fork under
rust-lang/Enzyme
.I maintain the Enzyme fork (by following upstream closely).
Cloning
rust-lang/Enzyme
might fail. Enzyme is much smaller than LLVM, so the chance of this happening is probably lower.We will start building
rust-lang/Enzyme
in CI.Mentors or Reviewers
@oli-obk is mentoring autodiff on the compiler side,
@traviscross serves as a lang liaison.
Manuel Drehwald (@ZuseZ4) will continue with the implementation work.
Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
The text was updated successfully, but these errors were encountered: